diff options
| author | Roman / Nea <roman.graef@gmail.com> | 2022-04-18 17:33:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 17:33:32 +0200 |
| commit | 2692193e54e4dd6c0117dcdb85368dc83bb04f1a (patch) | |
| tree | 96f01454c404ac04a46ea0d9bf684c7dc5619a57 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures | |
| parent | 9fe86ccb4d30b78826e513a6576027ca6e4c1600 (diff) | |
| download | notenoughupdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.tar.gz notenoughupdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.tar.bz2 notenoughupdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.zip | |
Mob loot recipe PR (#81)
* entity renderer (somewhat functionaL)
* more modifiers and entities
* Fix cookie fuckup
* add neu repo as resource pack, cause why not at this point
* add tabs, because i can
* add extra skin parts and make less tabs
* hot tall men
* fix texture offsets and also parts:true
* some untested changes
* still broken, but better (just like me (stop being edgy nea ( no u ))))
* stuff (with er skeletons
* niceities
* skytils interop
* horseys
* horseys ouch
* panos
* stupid tests :angery:
* NPE
* add drop chance
* colored leather armo
* finish off
* move shit into hover cause items look pretty terrible
* Update 2.1.md
* better recipe display name
* always show mobs toggle
* moving parts
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures')
11 files changed, 511 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java new file mode 100644 index 00000000..5884512f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java @@ -0,0 +1,30 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityAgeable; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityArmorStand; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityZombie; + +public class AgeModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + boolean baby = info.has("baby") && info.get("baby").getAsBoolean(); + if (base instanceof EntityAgeable) { + ((AccessorEntityAgeable) base).setGrowingAgeDirect(baby ? -1 : 1); + return base; + } + if (base instanceof EntityZombie) { + ((EntityZombie) base).setChild(baby); + return base; + } + if (base instanceof EntityArmorStand) { + ((AccessorEntityArmorStand) base).setSmallDirect(baby); + return base; + } + System.out.println("Cannot apply age to a non ageable entity: " + base); + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java new file mode 100644 index 00000000..17dce66d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java @@ -0,0 +1,17 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; + +public class ChargedModifier extends EntityViewerModifier { + + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (base instanceof EntityCreeper) { + base.getDataWatcher().updateObject(17, (byte) 1); + return base; + } + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java new file mode 100644 index 00000000..e9075e47 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java @@ -0,0 +1,177 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.*; +import net.minecraft.entity.passive.*; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +public class EntityViewer extends GuiScreen { + + public static Map<String, Supplier<? extends EntityLivingBase>> validEntities = new HashMap<String, Supplier<? extends EntityLivingBase>>() {{ + put("Zombie", () -> new EntityZombie(null)); + put("Chicken", () -> new EntityChicken(null)); + put("Slime", () -> new EntitySlime(null)); + put("Wolf", () -> new EntityWolf(null)); + put("Skeleton", () -> new EntitySkeleton(null)); + put("Creeper", () -> new EntityCreeper(null)); + put("Ocelot", () -> new EntityOcelot(null)); + put("Blaze", () -> new EntityBlaze(null)); + put("Rabbit", () -> new EntityRabbit(null)); + put("Sheep", () -> new EntitySheep(null)); + put("Horse", () -> new EntityHorse(null)); + put("Eisengolem", () -> new EntityIronGolem(null)); + put("Silverfish", () -> new EntitySilverfish(null)); + put("Witch", () -> new EntityWitch(null)); + put("Endermite", () -> new EntityEndermite(null)); + put("Snowman", () -> new EntitySnowman(null)); + put("Villager", () -> new EntityVillager(null)); + put("Guardian", () -> new EntityGuardian(null)); + put("ArmorStand", () -> new EntityArmorStand(null)); + put("Squid", () -> new EntitySquid(null)); + put("Bat", () -> new EntityBat(null)); + put("Spider", () -> new EntitySpider(null)); + put("CaveSpider", () -> new EntityCaveSpider(null)); + put("Pigman", () -> new EntityPigZombie(null)); + put("Ghast", () -> new EntityGhast(null)); + put("MagmaCube", () -> new EntityMagmaCube(null)); + put("Wither", () -> new EntityWither(null)); + put("Enderman", () -> new EntityEnderman(null)); + put("Mooshroom", ()-> new EntityMooshroom(null)); + put("WitherSkeleton", () -> { + EntitySkeleton skeleton = new EntitySkeleton(null); + skeleton.setSkeletonType(1); + return skeleton; + }); + put("Cow", () -> new EntityCow(null)); + put("Dragon", ()-> new EntityDragon(null)); + put("Player", () -> new GUIClientPlayer()); + }}; + + public static Map<String, EntityViewerModifier> validModifiers = new HashMap<String, EntityViewerModifier>() {{ + put("playerdata", new SkinModifier()); + put("equipment", new EquipmentModifier()); + put("riding", new RidingModifier()); + put("charged", new ChargedModifier()); + put("witherdata", new WitherModifier()); + put("invisible", new InvisibleModifier()); + put("age", new AgeModifier()); + put("horse", new HorseModifier()); + }}; + + public int guiLeft = 0; + public int guiTop = 0; + public int xSize = 176; + public int ySize = 166; + + private final String label; + private final EntityLivingBase entity; + private static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates", "textures/gui/entity_viewer.png"); + + public EntityViewer(String label, EntityLivingBase entity) { + this.label = label; + this.entity = entity; + } + + public static EntityLivingBase constructEntity(ResourceLocation resourceLocation) { + Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; + try (Reader is = new InputStreamReader( + Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream(), StandardCharsets.UTF_8)) { + return constructEntity(gson.fromJson(is, JsonObject.class)); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + public static EntityLivingBase constructEntity(JsonObject info) { + List<JsonObject> modifiers = info.has("modifiers") ? + StreamSupport.stream(info.get("modifiers").getAsJsonArray().spliterator(), false) + .map(JsonElement::getAsJsonObject).collect(Collectors.toList()) + : Collections.emptyList(); + return EntityViewer.constructEntity(info.get("entity").getAsString(), modifiers); + } + + public static EntityLivingBase constructEntity(String string, String[] modifiers) { + Gson gson = NotEnoughUpdates.INSTANCE.manager.gson; + return constructEntity(string, Arrays.stream(modifiers).map(it -> gson.fromJson(it, JsonObject.class)).collect(Collectors.toList())); + } + + public static EntityLivingBase constructEntity(String string, List<JsonObject> modifiers) { + Supplier<? extends EntityLivingBase> aClass = validEntities.get(string); + if (aClass == null) { + System.err.println("Could not find entity of type: " + string); + return null; + } + try { + EntityLivingBase entity = aClass.get(); + for (JsonObject modifier : modifiers) { + String type = modifier.get("type").getAsString(); + EntityViewerModifier entityViewerModifier = validModifiers.get(type); + entity = entityViewerModifier.applyModifier(entity, modifier); + if (entity == null) break; + } + return entity; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + this.guiLeft = (width - this.xSize) / 2; + this.guiTop = (height - this.ySize) / 2; + + + Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize); + + + Utils.drawStringScaledMaxWidth(label, fontRenderer, guiLeft + 10, guiTop + 10, false, 100, 0xFF00FF); + renderEntity(entity, guiLeft + 90, guiTop + 75, mouseX, mouseY); + } + + public static void renderEntity(EntityLivingBase entity, int posX, int posY, int mouseX, int mouseY) { + GlStateManager.color(1F, 1F, 1F, 1F); + + int scale = 30; + float bottomOffset = 0F; + EntityLivingBase stack = entity; + while (true) { + + stack.ticksExisted = Minecraft.getMinecraft().thePlayer.ticksExisted; + GuiInventory.drawEntityOnScreen(posX, (int) (posY - bottomOffset * scale), scale, posX - mouseX, (int) (posY - stack.getEyeHeight() * scale - mouseY), stack); + bottomOffset += stack.getMountedYOffset(); + if (!(stack.riddenByEntity instanceof EntityLivingBase)) { + break; + } + stack = (EntityLivingBase) stack.riddenByEntity; + } + + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java new file mode 100644 index 00000000..bab6c354 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewerModifier.java @@ -0,0 +1,8 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; + +public abstract class EntityViewerModifier { + public abstract EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info); +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java new file mode 100644 index 00000000..3011e479 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java @@ -0,0 +1,72 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; + +public class EquipmentModifier extends EntityViewerModifier { + + private ItemStack createItem(String item) { + NEUManager manager = NotEnoughUpdates.INSTANCE.manager; + String[] split = item.split("#"); + if (split.length == 2) { + switch (split[0].intern()) { + case "LEATHER_LEGGINGS": + return coloredLeatherArmor(Items.leather_leggings, split[1]); + case "LEATHER_HELMET": + return coloredLeatherArmor(Items.leather_helmet, split[1]); + case "LEATHER_CHESTPLATE": + return coloredLeatherArmor(Items.leather_chestplate, split[1]); + case "LEATHER_BOOTS": + return coloredLeatherArmor(Items.leather_boots, split[1]); + default: + throw new RuntimeException("Unknown leather piece: " + item); + } + } + return manager.createItem(item); + } + + private ItemStack coloredLeatherArmor(ItemArmor item, String colorHex) { + ItemStack is = new ItemStack(item); + item.setColor(is, Integer.parseInt(colorHex, 16)); + return is; + } + + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (info.has("hand")) + setCurrentItemOrArmor(base, 0, createItem(info.get("hand").getAsString())); + if (info.has("helmet")) + setCurrentItemOrArmor(base, 4, createItem(info.get("helmet").getAsString())); + if (info.has("chestplate")) + setCurrentItemOrArmor(base, 3, createItem(info.get("chestplate").getAsString())); + if (info.has("leggings")) + setCurrentItemOrArmor(base, 2, createItem(info.get("leggings").getAsString())); + if (info.has("feet")) + setCurrentItemOrArmor(base, 1, createItem(info.get("feet").getAsString())); + return base; + } + + public void setCurrentItemOrArmor(EntityLivingBase entity, int slot, ItemStack itemStack) { + if (entity instanceof EntityPlayer) { + setPlayerCurrentItemOrArmor((EntityPlayer) entity, slot, itemStack); + } else { + entity.setCurrentItemOrArmor(slot, itemStack); + } + } + + // Biscuit person needs to learn how to code and not fuck up valid vanilla behaviour + public static void setPlayerCurrentItemOrArmor(EntityPlayer player, int slot, ItemStack itemStack) { + if (slot == 0) { + player.inventory.mainInventory[player.inventory.currentItem] = itemStack; + } else { + player.inventory.armorInventory[slot - 1] = itemStack; + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java new file mode 100644 index 00000000..bbff2db1 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/GUIClientPlayer.java @@ -0,0 +1,40 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.util.ResourceLocation; + +import java.util.UUID; + +public class GUIClientPlayer extends AbstractClientPlayer { + public GUIClientPlayer() { + super(null, new GameProfile(UUID.randomUUID(), "GuiPlayer")); + } + + ResourceLocation overrideSkin = DefaultPlayerSkin.getDefaultSkinLegacy(); + ResourceLocation overrideCape = null; + boolean overrideIsSlim = false; + NetworkPlayerInfo playerInfo = new NetworkPlayerInfo(this.getGameProfile()) { + @Override + public String getSkinType() { + return overrideIsSlim ? "slim" : "default"; + } + + @Override + public ResourceLocation getLocationSkin() { + return overrideSkin; + } + + @Override + public ResourceLocation getLocationCape() { + return overrideCape; + } + }; + + @Override + protected NetworkPlayerInfo getPlayerInfo() { + return playerInfo; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java new file mode 100644 index 00000000..7fd2dadd --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/HorseModifier.java @@ -0,0 +1,66 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class HorseModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (!(base instanceof EntityHorse)) + return null; + EntityHorse horse = (EntityHorse) base; + if (info.has("kind")) { + String type = info.get("kind").getAsString().intern(); + switch (type) { + case "skeleton": + horse.setHorseType(4); + break; + case "zombie": + horse.setHorseType(3); + break; + case "mule": + horse.setHorseType(2); + break; + case "donkey": + horse.setHorseType(1); + break; + case "horse": + horse.setHorseType(0); + break; + default: + throw new IllegalArgumentException("Unknown horse type: " + type); + } + } + if (info.has("armor")) { + JsonElement el = info.get("armor"); + if (el.isJsonNull()) { + horse.setHorseArmorStack(null); + } else { + Item item; + switch (el.getAsString().intern()) { + case "iron": + item = Items.iron_horse_armor; + break; + case "golden": + item = Items.golden_horse_armor; + break; + case "diamond": + item = Items.diamond_horse_armor; + break; + default: + throw new IllegalArgumentException("Unknown horse armor: " + el.getAsString()); + } + horse.setHorseArmorStack(new ItemStack(item)); + } + } + if (info.has("saddled")) { + horse.setHorseSaddled(info.get("saddled").getAsBoolean()); + } + return horse; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java new file mode 100644 index 00000000..c2138b3f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/InvisibleModifier.java @@ -0,0 +1,12 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; + +public class InvisibleModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + base.setInvisible(!info.has("invisible") || info.get("invisible").getAsBoolean()); + return base; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java new file mode 100644 index 00000000..9879542a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/RidingModifier.java @@ -0,0 +1,14 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; + +public class RidingModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + EntityLivingBase newEntity = EntityViewer.constructEntity(info); + if (newEntity == null) return null; + newEntity.mountEntity(base); + return base; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java new file mode 100644 index 00000000..55e8a432 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/SkinModifier.java @@ -0,0 +1,46 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.util.ResourceLocation; + +import java.util.Map; + +public class SkinModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (base instanceof GUIClientPlayer) { + GUIClientPlayer player = (GUIClientPlayer) base; + if (info.has("cape")) { + player.overrideCape = new ResourceLocation(info.get("cape").getAsString()); + } + if (info.has("skin")) { + player.overrideSkin = new ResourceLocation(info.get("skin").getAsString()); + } + if (info.has("slim")) { + player.overrideIsSlim = info.get("slim").getAsBoolean(); + } + if (info.has("parts")) { + JsonElement parts = info.get("parts"); + byte partBitField = player.getDataWatcher().getWatchableObjectByte(10); + if (parts.isJsonPrimitive() && parts.getAsJsonPrimitive().isBoolean()) { + partBitField = parts.getAsBoolean() ? (byte) -1 : 0; + } else { + JsonObject obj = parts.getAsJsonObject(); + for (Map.Entry<String, JsonElement> part : obj.entrySet()) { + EnumPlayerModelParts modelPart = EnumPlayerModelParts.valueOf(part.getKey()); + if (part.getValue().getAsBoolean()) { + partBitField |= modelPart.getPartMask(); + } else { + partBitField &= ~modelPart.getPartMask(); + } + } + } + player.getDataWatcher().updateObject(10, partBitField); + } + } + return base; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java new file mode 100644 index 00000000..c5580f17 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java @@ -0,0 +1,29 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityWither; + +public class WitherModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (!(base instanceof EntityWither)) + return null; + EntityWither wither = (EntityWither) base; + if (info.has("tiny")) { + if (info.get("tiny").getAsBoolean()) { + wither.setInvulTime(800); + } else { + wither.setInvulTime(0); + } + } + if (info.has("armored")) { + if (info.get("armored").getAsBoolean()) { + wither.setHealth(1); + } else { + wither.setHealth(wither.getMaxHealth()); + } + } + return base; + } +} |
