diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt index 6ceaea61b..d1faa29ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt @@ -6,23 +6,24 @@ 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.core.otmRandom import ru.dbotthepony.mc.otm.registry.game.MItems object WitheredSkeletonSpawnHandler { - @SubscribeEvent fun onEntityJoin(event: EntityJoinLevelEvent) { val entity = event.entity - if (entity is WitherSkeleton){ - val giveHelmet = entity.random.nextFloat() < 0.1f - val giveSword = entity.random.nextFloat() < 0.24f + if (entity is WitherSkeleton) { + val giveHelmet = event.level.otmRandom.nextFloat() < 0.1f + val giveSword = event.level.otmRandom.nextFloat() < 0.24f if (giveHelmet) { entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET)) - entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD)) - } else if (giveSword) { + } + + if (giveSword || giveHelmet) { entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD)) } }