Update WitheredSkeletonSpawnHandler implementation

This commit is contained in:
DBotThePony 2025-03-09 16:12:24 +07:00
parent 67ea3b977b
commit e97967903b
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -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))
}
}