diff options
Diffstat (limited to 'src/main/kotlin/gui/entity/ModifyHorse.kt')
| -rw-r--r-- | src/main/kotlin/gui/entity/ModifyHorse.kt | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/main/kotlin/gui/entity/ModifyHorse.kt b/src/main/kotlin/gui/entity/ModifyHorse.kt index 7c8baa7..a870bf1 100644 --- a/src/main/kotlin/gui/entity/ModifyHorse.kt +++ b/src/main/kotlin/gui/entity/ModifyHorse.kt @@ -2,29 +2,26 @@ package moe.nea.firmament.gui.entity import com.google.gson.JsonNull import com.google.gson.JsonObject -import kotlin.experimental.and -import kotlin.experimental.inv -import kotlin.experimental.or -import net.minecraft.entity.EntityType -import net.minecraft.entity.EquipmentSlot -import net.minecraft.entity.LivingEntity -import net.minecraft.entity.SpawnReason -import net.minecraft.entity.passive.AbstractHorseEntity -import net.minecraft.item.ItemStack -import net.minecraft.item.Items +import net.minecraft.world.entity.EntityType +import net.minecraft.world.entity.EquipmentSlot +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.EntitySpawnReason +import net.minecraft.world.entity.animal.horse.AbstractHorse +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import moe.nea.firmament.gui.entity.EntityRenderer.fakeWorld object ModifyHorse : EntityModifier { override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { - require(entity is AbstractHorseEntity) - var entity: AbstractHorseEntity = entity + require(entity is AbstractHorse) + var entity: AbstractHorse = entity info["kind"]?.let { entity = when (it.asString) { - "skeleton" -> EntityType.SKELETON_HORSE.create(fakeWorld, SpawnReason.LOAD)!! - "zombie" -> EntityType.ZOMBIE_HORSE.create(fakeWorld, SpawnReason.LOAD)!! - "mule" -> EntityType.MULE.create(fakeWorld, SpawnReason.LOAD)!! - "donkey" -> EntityType.DONKEY.create(fakeWorld, SpawnReason.LOAD)!! - "horse" -> EntityType.HORSE.create(fakeWorld, SpawnReason.LOAD)!! + "skeleton" -> EntityType.SKELETON_HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!! + "zombie" -> EntityType.ZOMBIE_HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!! + "mule" -> EntityType.MULE.create(fakeWorld, EntitySpawnReason.LOAD)!! + "donkey" -> EntityType.DONKEY.create(fakeWorld, EntitySpawnReason.LOAD)!! + "horse" -> EntityType.HORSE.create(fakeWorld, EntitySpawnReason.LOAD)!! else -> error("Unknown horse kind $it") } } @@ -48,12 +45,14 @@ object ModifyHorse : EntityModifier { } -fun AbstractHorseEntity.setIsSaddled(shouldBeSaddled: Boolean) { - this.equipStack(EquipmentSlot.SADDLE, - if (shouldBeSaddled) ItemStack(Items.SADDLE) - else ItemStack.EMPTY) +fun AbstractHorse.setIsSaddled(shouldBeSaddled: Boolean) { + this.setItemSlot( + EquipmentSlot.SADDLE, + if (shouldBeSaddled) ItemStack(Items.SADDLE) + else ItemStack.EMPTY + ) } -fun AbstractHorseEntity.setHorseArmor(itemStack: ItemStack) { - this.equipBodyArmor(itemStack) +fun AbstractHorse.setHorseArmor(itemStack: ItemStack) { + bodyArmorItem = itemStack } |
