Update WitheredSkeletonSpawnHandler implementation
This commit is contained in:
parent
67ea3b977b
commit
e97967903b
@ -6,23 +6,24 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
import net.neoforged.bus.api.SubscribeEvent
|
||||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent
|
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent
|
||||||
|
import ru.dbotthepony.mc.otm.core.otmRandom
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MItems
|
import ru.dbotthepony.mc.otm.registry.game.MItems
|
||||||
|
|
||||||
|
|
||||||
object WitheredSkeletonSpawnHandler {
|
object WitheredSkeletonSpawnHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun onEntityJoin(event: EntityJoinLevelEvent) {
|
fun onEntityJoin(event: EntityJoinLevelEvent) {
|
||||||
val entity = event.entity
|
val entity = event.entity
|
||||||
if (entity is WitherSkeleton){
|
|
||||||
|
|
||||||
val giveHelmet = entity.random.nextFloat() < 0.1f
|
if (entity is WitherSkeleton) {
|
||||||
val giveSword = entity.random.nextFloat() < 0.24f
|
val giveHelmet = event.level.otmRandom.nextFloat() < 0.1f
|
||||||
|
val giveSword = event.level.otmRandom.nextFloat() < 0.24f
|
||||||
|
|
||||||
if (giveHelmet) {
|
if (giveHelmet) {
|
||||||
entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET))
|
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))
|
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user