Wither skeleton sword and helmet server config
This commit is contained in:
parent
6f2adfd6d3
commit
df7465a59f
@ -76,4 +76,12 @@ object ServerConfig : AbstractConfig("misc") {
|
||||
builder.pop()
|
||||
}
|
||||
}
|
||||
|
||||
val WITHER_SKELETON_HELMET_CHANCE: Double by builder
|
||||
.comment("Chance of Wither Skeleton spawning with Netherite Helmet AND Withered Steel sword")
|
||||
.defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.1, 0.0, 1.0)
|
||||
|
||||
val WITHER_SKELETON_SWORD_CHANCE: Double by builder
|
||||
.comment("Chance of Wither Skeleton spawning with Withered Steel sword")
|
||||
.defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.24, 0.0, 1.0)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.neoforged.bus.api.SubscribeEvent
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent
|
||||
import ru.dbotthepony.mc.otm.config.ServerConfig
|
||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
||||
import ru.dbotthepony.mc.otm.registry.game.MItems
|
||||
|
||||
@ -16,15 +17,17 @@ object WitheredSkeletonSpawnHandler {
|
||||
val entity = event.entity
|
||||
|
||||
if (entity is WitherSkeleton) {
|
||||
val giveHelmet = event.level.otmRandom.nextFloat() < 0.1f
|
||||
val giveSword = event.level.otmRandom.nextFloat() < 0.24f
|
||||
val giveHelmet = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE
|
||||
val giveSword = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE
|
||||
|
||||
if (giveHelmet) {
|
||||
entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET))
|
||||
if (!entity.hasItemInSlot(EquipmentSlot.HEAD))
|
||||
entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET))
|
||||
}
|
||||
|
||||
if (giveSword || giveHelmet) {
|
||||
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||
if (!entity.hasItemInSlot(EquipmentSlot.MAINHAND) || entity.getItemBySlot(EquipmentSlot.MAINHAND).item == Items.STONE_SWORD)
|
||||
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user