From dabd9ecad04c6a31311355cbe1b5f73ec18fe8b0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 13 May 2018 18:43:49 +0200 Subject: [PATCH 1/6] Rewrite the settings gui and add it to the liteloader panel --- .../minelittlepony/LiteModMineLittlePony.java | 11 +- .../com/minelittlepony/MineLittlePony.java | 3 +- .../com/minelittlepony/PonySettingPanel.java | 192 ------------------ .../java/com/minelittlepony/gui/Checkbox.java | 22 ++ .../minelittlepony/gui/GuiPonySettings.java | 100 +++++++++ .../com/minelittlepony/gui/IActionable.java | 5 + .../com/minelittlepony/gui/IGUIAction.java | 6 + .../java/com/minelittlepony/gui/Label.java | 37 ++++ .../minelittlepony/gui/PonySettingsPanel.java | 103 ++++++++++ .../java/com/minelittlepony/gui/Slider.java | 38 ++++ .../minelittlepony/pony/data/PonyLevel.java | 10 +- 11 files changed, 332 insertions(+), 195 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/PonySettingPanel.java create mode 100644 src/main/java/com/minelittlepony/gui/Checkbox.java create mode 100644 src/main/java/com/minelittlepony/gui/GuiPonySettings.java create mode 100644 src/main/java/com/minelittlepony/gui/IActionable.java create mode 100644 src/main/java/com/minelittlepony/gui/IGUIAction.java create mode 100644 src/main/java/com/minelittlepony/gui/Label.java create mode 100644 src/main/java/com/minelittlepony/gui/PonySettingsPanel.java create mode 100644 src/main/java/com/minelittlepony/gui/Slider.java diff --git a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java index 2a9d5612..aa8893da 100644 --- a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java @@ -1,13 +1,17 @@ package com.minelittlepony; +import com.minelittlepony.gui.PonySettingsPanel; +import com.mumfrey.liteloader.Configurable; import com.mumfrey.liteloader.InitCompleteListener; import com.mumfrey.liteloader.Tickable; import com.mumfrey.liteloader.core.LiteLoader; +import com.mumfrey.liteloader.modconfig.ConfigPanel; + import net.minecraft.client.Minecraft; import java.io.File; -public class LiteModMineLittlePony implements Tickable, InitCompleteListener { +public class LiteModMineLittlePony implements Tickable, InitCompleteListener, Configurable { private MineLittlePony mlp; @@ -39,4 +43,9 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { mlp.onTick(minecraft, inGame); } + + @Override + public Class getConfigPanelClass() { + return PonySettingsPanel.class; + } } diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index ba43cf3f..86d447eb 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -1,5 +1,6 @@ package com.minelittlepony; +import com.minelittlepony.gui.GuiPonySettings; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyDataSerialzier; @@ -81,7 +82,7 @@ public class MineLittlePony { void onTick(Minecraft minecraft, boolean inGame) { if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) { - minecraft.displayGuiScreen(new PonySettingPanel()); + minecraft.displayGuiScreen(new GuiPonySettings()); } boolean skins = minecraft.currentScreen instanceof GuiSkins diff --git a/src/main/java/com/minelittlepony/PonySettingPanel.java b/src/main/java/com/minelittlepony/PonySettingPanel.java deleted file mode 100644 index 3cfdb6f4..00000000 --- a/src/main/java/com/minelittlepony/PonySettingPanel.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.minelittlepony; - -import com.minelittlepony.pony.data.PonyLevel; -import com.mumfrey.liteloader.client.gui.GuiCheckbox; -import com.mumfrey.liteloader.core.LiteLoader; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; - -import java.io.IOException; - -/** - * In-Game options menu. - * - * TODO: What a mess - */ -public class PonySettingPanel extends GuiScreen { - - private static final String _PREFIX = "minelp.options."; - private static final String TITLE = _PREFIX + "title"; - private static final String PONY_LEVEL = _PREFIX + "ponylevel"; - private static final String PONY = PONY_LEVEL + ".ponies"; - private static final String HUMAN = PONY_LEVEL + ".humans"; - private static final String BOTH = PONY_LEVEL + ".both"; - private static final String OPTIONS = _PREFIX + "options"; - private static final String HD = _PREFIX + "hd"; - private static final String SIZES = _PREFIX + "sizes"; - private static final String SNUZZLES = _PREFIX + "snuzzles"; - private static final String SHOW_SCALE = _PREFIX + "showscale"; - - private static final String MOB_PREFIX = "minelp.mobs."; - - private static final String MOB_TITLE = MOB_PREFIX + "title"; - private static final String VILLAGERS = MOB_PREFIX + "villagers"; - private static final String ZOMBIES = MOB_PREFIX + "zombies"; - private static final String ZOMBIE_PIGMEN = MOB_PREFIX + "zombiepigmen"; - private static final String SKELETONS = MOB_PREFIX + "skeletons"; - private static final String ILLAGERS = MOB_PREFIX + "illagers"; - private static final String GUARDIANS = MOB_PREFIX + "guardians"; - - private static final int PONY_ID = 0; - private static final int HUMAN_ID = 1; - private static final int BOTH_ID = 2; - private static final int HD_ID = 3; - private static final int SIZES_ID = 4; - private static final int SNUZZLES_ID = 5; - private static final int SHOW_SCALE_ID = 6; - - private static final int VILLAGERS_ID = 7; - private static final int ZOMBIES_ID = 8; - private static final int ZOMBIE_PIGMEN_ID = 9; - private static final int SKELETONS_ID = 10; - private static final int ILLAGER_ID = 11; - private static final int GUARDIAN_ID = 12; - - private PonyConfig config; - - private GuiCheckbox ponies; - private GuiCheckbox humans; - private GuiCheckbox both; - - public PonySettingPanel() { - config = MineLittlePony.getConfig(); - } - - @SuppressWarnings("UnusedAssignment") - @Override - public void initGui() { - final int LEFT = width / 10 + 16; - GuiCheckbox pony, human, both, hd, sizes, snuzzles, showscale, villager, zombie, pigmen, skeleton, illager, guardian; - int row = 32; - buttonList.add(pony = ponies = new GuiCheckbox(PONY_ID, LEFT, row += 15, I18n.format(PONY))); - buttonList.add(human = humans = new GuiCheckbox(HUMAN_ID, LEFT, row += 15, I18n.format(HUMAN))); - buttonList.add(both = this.both = new GuiCheckbox(BOTH_ID, LEFT, row += 15, I18n.format(BOTH))); - row += 15; - buttonList.add(hd = new GuiCheckbox(HD_ID, LEFT, row += 15, I18n.format(HD))); - buttonList.add(snuzzles = new GuiCheckbox(SNUZZLES_ID, LEFT, row += 15, I18n.format(SNUZZLES))); - buttonList.add(sizes = new GuiCheckbox(SIZES_ID, LEFT, row += 15, I18n.format(SIZES))); - buttonList.add(showscale = new GuiCheckbox(SHOW_SCALE_ID, LEFT, row += 15, I18n.format(SHOW_SCALE))); - - final int RIGHT = width - width / 3; - row = 32; - buttonList.add(villager = new GuiCheckbox(VILLAGERS_ID, RIGHT, row += 15, I18n.format(VILLAGERS))); - buttonList.add(zombie = new GuiCheckbox(ZOMBIES_ID, RIGHT, row += 15, I18n.format(ZOMBIES))); - buttonList.add(pigmen = new GuiCheckbox(ZOMBIE_PIGMEN_ID, RIGHT, row += 15, I18n.format(ZOMBIE_PIGMEN))); - buttonList.add(skeleton = new GuiCheckbox(SKELETONS_ID, RIGHT, row += 15, I18n.format(SKELETONS))); - buttonList.add(illager = new GuiCheckbox(ILLAGER_ID, RIGHT, row += 15, I18n.format(ILLAGERS))); - buttonList.add(guardian = new GuiCheckbox(GUARDIAN_ID, RIGHT, row += 15, I18n.format(GUARDIANS))); - - switch (config.getPonyLevel()) { - default: - case PONIES: - pony.checked = true; - break; - case HUMANS: - human.checked = true; - break; - case BOTH: - both.checked = true; - break; - } - hd.checked = config.hd; - sizes.checked = config.sizes; - snuzzles.checked = config.snuzzles; - showscale.checked = config.showscale; - villager.checked = config.villagers; - zombie.checked = config.zombies; - pigmen.checked = config.pigzombies; - skeleton.checked = config.skeletons; - illager.checked = config.illagers; - guardian.checked = config.guardians; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawDefaultBackground(); - - drawCenteredString(mc.fontRenderer, I18n.format(TITLE), width / 2, 12, -1); - - drawString(mc.fontRenderer, I18n.format(MOB_TITLE), width - width / 3 - 16, 32, -1); - drawString(mc.fontRenderer, I18n.format(PONY_LEVEL), width / 10, 32, -1); - drawString(mc.fontRenderer, I18n.format(OPTIONS), width / 10, 94, -1); - - super.drawScreen(mouseX, mouseY, partialTicks); - } - - @Override - protected void actionPerformed(GuiButton button) throws IOException { - if (button instanceof GuiCheckbox) { - boolean checked = !((GuiCheckbox) button).checked; - ((GuiCheckbox) button).checked = checked; - - switch (button.id) { - case PONY_ID: - config.setPonyLevel(PonyLevel.PONIES); - ponies.checked = true; - humans.checked = false; - both.checked = false; - break; - case HUMAN_ID: - config.setPonyLevel(PonyLevel.HUMANS); - humans.checked = true; - ponies.checked = false; - both.checked = false; - break; - case BOTH_ID: - config.setPonyLevel(PonyLevel.BOTH); - both.checked = true; - ponies.checked = false; - humans.checked = false; - break; - case HD_ID: - config.hd = checked; - break; - case SIZES_ID: - config.sizes = checked; - break; - case SNUZZLES_ID: - config.snuzzles = checked; - break; - case SHOW_SCALE_ID: - config.showscale = checked; - break; - - case VILLAGERS_ID: - config.villagers = checked; - break; - case ZOMBIES_ID: - config.zombies = checked; - break; - case ZOMBIE_PIGMEN_ID: - config.pigzombies = checked; - break; - case SKELETONS_ID: - config.skeletons = checked; - break; - case ILLAGER_ID: - config.illagers = checked; - break; - case GUARDIAN_ID: - config.guardians = checked; - break; - } - } - } - - @Override - public void onGuiClosed() { - LiteLoader.getInstance().writeConfig(config); - MineLittlePony.getInstance().getRenderManager().initializeMobRenderers(mc.getRenderManager(), config); - } -} diff --git a/src/main/java/com/minelittlepony/gui/Checkbox.java b/src/main/java/com/minelittlepony/gui/Checkbox.java new file mode 100644 index 00000000..51a2421f --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/Checkbox.java @@ -0,0 +1,22 @@ +package com.minelittlepony.gui; + +import com.mumfrey.liteloader.client.gui.GuiCheckbox; + +import net.minecraft.client.resources.I18n; + +public class Checkbox extends GuiCheckbox implements IActionable { + + private final IGUIAction action; + + public Checkbox(int x, int y, String displayString, boolean value, IGUIAction callback) { + super(0, x, y, I18n.format(displayString)); + action = callback; + checked = value; + } + + @Override + public void perform() { + checked = action.perform(!checked); + } + +} diff --git a/src/main/java/com/minelittlepony/gui/GuiPonySettings.java b/src/main/java/com/minelittlepony/gui/GuiPonySettings.java new file mode 100644 index 00000000..ada4bf93 --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/GuiPonySettings.java @@ -0,0 +1,100 @@ +package com.minelittlepony.gui; + +import java.io.IOException; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.PonyConfig; +import com.minelittlepony.pony.data.PonyLevel; +import com.mumfrey.liteloader.core.LiteLoader; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; + +/** + * In-Game options menu. + * + */ +public class GuiPonySettings extends GuiScreen { + + private static final String OPTIONS_PREFIX = "minelp.options."; + + private static final String PONY_LEVEL = OPTIONS_PREFIX + "ponylevel"; + + private static final String MOB_PREFIX = "minelp.mobs."; + + private PonyConfig config; + + public GuiPonySettings() { + config = MineLittlePony.getConfig(); + } + + @Override + public void initGui() { + final int LEFT = width / 10; + final int RIGHT = mustScroll() ? LEFT : width - width / 3 - 16; + + int row = mustScroll() ? 0 : 32; + + if (!mustScroll()) { + addButton(new Label(width / 2, 12, getTitle(), -1, true)); + } + + addButton(new Label(LEFT, row += 15, PONY_LEVEL, -1)); + addButton(new Slider(LEFT, row += 15, 0, 2, config.getPonyLevel().ordinal(), (int id, String name, float value) -> { + return I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase()); + }, v -> { + PonyLevel level = PonyLevel.valueFor(v); + config.setPonyLevel(level); + return (float)level.ordinal(); + })); + + row += 15; + addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1)); + addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "hd", config.hd, v -> config.hd = v)); + addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "snuzzles", config.snuzzles, v -> config.snuzzles = v)); + addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "sizes", config.sizes, v -> config.sizes = v)); + addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "showscale", config.showscale, v -> config.showscale = v)); + + if (mustScroll()) { + row += 15; + } else { + row = 32; + } + + addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "villagers", config.villagers, v -> config.villagers = v)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "zombies", config.zombies, v -> config.zombies = v)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "zombiepigmen", config.pigzombies, v -> config.pigzombies = v)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "skeletons", config.skeletons, v -> config.skeletons = v)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "illagers", config.illagers, v -> config.illagers = v)); + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "guardians", config.guardians, v -> config.guardians = v)); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + if (button instanceof IActionable) { + ((IActionable)button).perform(); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public void onGuiClosed() { + LiteLoader.getInstance().writeConfig(config); + MineLittlePony.getInstance().getRenderManager().initializeMobRenderers(mc.getRenderManager(), config); + } + + protected String getTitle() { + return OPTIONS_PREFIX + "title"; + } + + protected boolean mustScroll() { + return false; + } +} diff --git a/src/main/java/com/minelittlepony/gui/IActionable.java b/src/main/java/com/minelittlepony/gui/IActionable.java new file mode 100644 index 00000000..2417ac40 --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/IActionable.java @@ -0,0 +1,5 @@ +package com.minelittlepony.gui; + +public interface IActionable { + void perform(); +} diff --git a/src/main/java/com/minelittlepony/gui/IGUIAction.java b/src/main/java/com/minelittlepony/gui/IGUIAction.java new file mode 100644 index 00000000..cd5e4364 --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/IGUIAction.java @@ -0,0 +1,6 @@ +package com.minelittlepony.gui; + +@FunctionalInterface +public interface IGUIAction { + T perform(T value); +} diff --git a/src/main/java/com/minelittlepony/gui/Label.java b/src/main/java/com/minelittlepony/gui/Label.java new file mode 100644 index 00000000..e7a3949b --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/Label.java @@ -0,0 +1,37 @@ +package com.minelittlepony.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.I18n; + +public class Label extends GuiButton { + + private boolean center; + + private int color; + + private String text; + + public Label(int x, int y, String translationString, int color) { + this(x, y, translationString, color, false); + } + + public Label(int x, int y, String translationString, int color, boolean center) { + super(0, x, y, ""); + this.color = color; + this.center = center; + this.text = translationString; + } + + public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { + return false; + } + + public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + if (center) { + drawCenteredString(mc.fontRenderer, I18n.format(text), x, y, color); + } else { + drawString(mc.fontRenderer, I18n.format(text), x, y, color); + } + } +} diff --git a/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java b/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java new file mode 100644 index 00000000..7c884907 --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java @@ -0,0 +1,103 @@ +package com.minelittlepony.gui; + +import java.io.IOException; + +import com.mumfrey.liteloader.modconfig.ConfigPanel; +import com.mumfrey.liteloader.modconfig.ConfigPanelHost; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.I18n; + +/** + * Boilerplate because LiteLoader has to be such a 'special flower' -_- + */ +public class PonySettingsPanel extends GuiPonySettings implements ConfigPanel { + + private int contentHeight; + + @Override + public String getPanelTitle() { + return I18n.format(getTitle()); + } + + @Override + public int getContentHeight() { + return contentHeight + 40; + } + + @Override + protected T addButton(T button) { + if (button.y > contentHeight) { + contentHeight = button.y; + } + return super.addButton(button); + } + + @Override + public void onPanelShown(ConfigPanelHost host) { + mc = Minecraft.getMinecraft(); + width = host.getWidth(); + initGui(); + } + + @Override + public void onPanelResize(ConfigPanelHost host) { + width = host.getWidth(); + this.buttonList.clear(); + initGui(); + } + + @Override + public void onPanelHidden() { + onGuiClosed(); + } + + @Override + public void onTick(ConfigPanelHost host) { + updateScreen(); + } + + @Override + public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) { + drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) { + try { + mouseClicked(mouseX, mouseY, mouseButton); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) { + mouseReleased(mouseX, mouseY, mouseButton); + } + + @Override + public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) { + + } + + @Override + public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) { + try { + keyTyped(keyChar, keyCode); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void drawWorldBackground(int tint) { + + } + + protected boolean mustScroll() { + return true; + } + +} diff --git a/src/main/java/com/minelittlepony/gui/Slider.java b/src/main/java/com/minelittlepony/gui/Slider.java new file mode 100644 index 00000000..a5f4ac41 --- /dev/null +++ b/src/main/java/com/minelittlepony/gui/Slider.java @@ -0,0 +1,38 @@ +package com.minelittlepony.gui; + +import net.minecraft.client.gui.GuiSlider; +import net.minecraft.client.gui.GuiPageButtonList.GuiResponder; + +public class Slider extends GuiSlider { + + private static Responder callback; + + public Slider(int x, int y, float minIn, float maxIn, float defaultValue, GuiSlider.FormatHelper formatter, IGUIAction action) { + super(callback = new Responder(action), 0, x, y, "", minIn, maxIn, defaultValue, formatter); + callback.owner = this; + callback = null; + } + + private static final class Responder implements GuiResponder { + + private final IGUIAction action; + + private Slider owner; + + private Responder(IGUIAction callback) { + action = callback; + } + + @Override + public void setEntryValue(int id, boolean value) { } + + @Override + public void setEntryValue(int id, float value) { + owner.setSliderValue(action.perform(value), false); + } + + @Override + public void setEntryValue(int id, String value) { } + + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/PonyLevel.java b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java index 9297fc15..cf26cde3 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyLevel.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java @@ -3,5 +3,13 @@ package com.minelittlepony.pony.data; public enum PonyLevel { PONIES, HUMANS, - BOTH + BOTH; + + public static PonyLevel valueFor(float index) { + PonyLevel[] values = values(); + if (index < 0) { + index = 0; + } + return values[(int)Math.round(index) % values.length]; + } } From 23b2618f1eb025fd9c53df425b9f16e2593ae0ea Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 15 May 2018 16:24:47 +0200 Subject: [PATCH 2/6] Fixed buttons triggering their actions twice on the Liteloader pane --- src/main/java/com/minelittlepony/gui/PonySettingsPanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java b/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java index 7c884907..d0b173b5 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java +++ b/src/main/java/com/minelittlepony/gui/PonySettingsPanel.java @@ -38,13 +38,14 @@ public class PonySettingsPanel extends GuiPonySettings implements ConfigPanel { public void onPanelShown(ConfigPanelHost host) { mc = Minecraft.getMinecraft(); width = host.getWidth(); + buttonList.clear(); initGui(); } @Override public void onPanelResize(ConfigPanelHost host) { width = host.getWidth(); - this.buttonList.clear(); + buttonList.clear(); initGui(); } From e56611c3fc6a0f5d22804426186734953e1dcb9e Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 15 May 2018 16:25:11 +0200 Subject: [PATCH 3/6] Docs! --- src/main/java/com/minelittlepony/gui/IActionable.java | 7 +++++++ src/main/java/com/minelittlepony/gui/IGUIAction.java | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/com/minelittlepony/gui/IActionable.java b/src/main/java/com/minelittlepony/gui/IActionable.java index 2417ac40..3ad22158 100644 --- a/src/main/java/com/minelittlepony/gui/IActionable.java +++ b/src/main/java/com/minelittlepony/gui/IActionable.java @@ -1,5 +1,12 @@ package com.minelittlepony.gui; +/** + * An element that can perform an action. + */ +@FunctionalInterface public interface IActionable { + /** + * Does whatever. + */ void perform(); } diff --git a/src/main/java/com/minelittlepony/gui/IGUIAction.java b/src/main/java/com/minelittlepony/gui/IGUIAction.java index cd5e4364..48aa5efa 100644 --- a/src/main/java/com/minelittlepony/gui/IGUIAction.java +++ b/src/main/java/com/minelittlepony/gui/IGUIAction.java @@ -1,6 +1,15 @@ package com.minelittlepony.gui; +/** + * Response actions for UI events. + */ @FunctionalInterface public interface IGUIAction { + /** + * Performs this action now. + * + * @param value New Value of the field being changed + * @return Adjusted value the field must take on + */ T perform(T value); } From bc65369964768436ac616a019fc897e1d0bd7648 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 15 May 2018 16:26:52 +0200 Subject: [PATCH 4/6] Reorganise how settings work, and renderers change immediately when you toggle an option --- .../java/com/minelittlepony/PonyConfig.java | 14 ++- .../com/minelittlepony/PonyRenderManager.java | 118 +++--------------- .../minelittlepony/gui/GuiPonySettings.java | 19 ++- .../render/ponies/MobRenderers.java | 82 ++++++++++++ .../settings/SensibleConfig.java | 60 +++++++++ 5 files changed, 179 insertions(+), 114 deletions(-) create mode 100644 src/main/java/com/minelittlepony/render/ponies/MobRenderers.java create mode 100644 src/main/java/com/minelittlepony/settings/SensibleConfig.java diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index 1f72a40b..b4f969d4 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -2,22 +2,32 @@ package com.minelittlepony; import com.google.gson.annotations.Expose; import com.minelittlepony.pony.data.PonyLevel; +import com.minelittlepony.settings.SensibleConfig; import com.mumfrey.liteloader.modconfig.ConfigStrategy; import com.mumfrey.liteloader.modconfig.Exposable; import com.mumfrey.liteloader.modconfig.ExposableOptions; /** - * Storage contained for MineLP client settings. + * Storage container for MineLP client settings. * */ @ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned) -public class PonyConfig implements Exposable { +public class PonyConfig extends SensibleConfig implements Exposable { @Expose private PonyLevel ponylevel = PonyLevel.PONIES; + @Expose public boolean sizes = true; @Expose public boolean snuzzles = true; @Expose public boolean hd = true; @Expose public boolean showscale = true; + + public enum PonySettings implements Setting { + SIZES, + SNUZZLES, + HD, + SHOWSCALE; + } + @Expose public boolean villagers = true; @Expose public boolean zombies = true; @Expose public boolean pigzombies = true; diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 76c143ae..d7c9fba0 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -9,36 +9,12 @@ import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.model.player.PlayerModels; import com.minelittlepony.render.LevitatingItemRenderer; import com.minelittlepony.render.player.RenderPonyPlayer; -import com.minelittlepony.render.ponies.RenderPonyGuardian; -import com.minelittlepony.render.ponies.RenderPonyIllager; -import com.minelittlepony.render.ponies.RenderPonyPigman; -import com.minelittlepony.render.ponies.RenderPonySkeleton; -import com.minelittlepony.render.ponies.RenderPonyVex; -import com.minelittlepony.render.ponies.RenderPonyVillager; -import com.minelittlepony.render.ponies.RenderPonyWitch; -import com.minelittlepony.render.ponies.RenderPonyZombie; -import com.minelittlepony.render.ponies.RenderPonyZombieVillager; +import com.minelittlepony.render.ponies.MobRenderers; import com.mumfrey.liteloader.util.ModUtilities; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.EntityElderGuardian; -import net.minecraft.entity.monster.EntityEvoker; -import net.minecraft.entity.monster.EntityGiantZombie; -import net.minecraft.entity.monster.EntityGuardian; -import net.minecraft.entity.monster.EntityHusk; -import net.minecraft.entity.monster.EntityIllusionIllager; -import net.minecraft.entity.monster.EntityPigZombie; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.EntityStray; -import net.minecraft.entity.monster.EntityVex; -import net.minecraft.entity.monster.EntityVindicator; -import net.minecraft.entity.monster.EntityWitch; -import net.minecraft.entity.monster.EntityWitherSkeleton; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraft.entity.passive.EntityVillager; /** * Render manager responsible for replacing and restoring entity renderers when the client settings change. @@ -80,92 +56,32 @@ public class PonyRenderManager { * Registers all entity model replacements. (except for players). */ public void initializeMobRenderers(RenderManager manager, PonyConfig config) { - - if (config.villagers) { - pushNewRenderer(manager, EntityVillager.class, new RenderPonyVillager(manager)); - pushNewRenderer(manager, EntityWitch.class, new RenderPonyWitch(manager)); - pushNewRenderer(manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager)); - MineLittlePony.logger.info("Villagers are now ponies."); - } else { - restoreRenderer(EntityVillager.class); - restoreRenderer(EntityWitch.class); - restoreRenderer(EntityZombieVillager.class); - } - - if (config.zombies) { - pushNewRenderer(manager, EntityZombie.class, new RenderPonyZombie<>(manager)); - pushNewRenderer(manager, EntityHusk.class, new RenderPonyZombie.Husk(manager)); - pushNewRenderer(manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager)); - MineLittlePony.logger.info("Zombies are now ponies."); - } else { - restoreRenderer(EntityZombie.class); - restoreRenderer(EntityHusk.class); - restoreRenderer(EntityGiantZombie.class); - } - - if (config.pigzombies) { - pushNewRenderer(manager, EntityPigZombie.class, new RenderPonyPigman(manager)); - MineLittlePony.logger.info("Zombie pigmen are now ponies."); - } else { - restoreRenderer(EntityPigZombie.class); - } - - if (config.skeletons) { - pushNewRenderer(manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager)); - pushNewRenderer(manager, EntityStray.class, new RenderPonySkeleton.Stray(manager)); - pushNewRenderer(manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager)); - MineLittlePony.logger.info("Skeletons are now ponies."); - } else { - restoreRenderer(EntitySkeleton.class); - restoreRenderer(EntityStray.class); - restoreRenderer(EntityWitherSkeleton.class); - } - - if (config.illagers) { - pushNewRenderer(manager, EntityVex.class, new RenderPonyVex(manager)); - pushNewRenderer(manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager)); - pushNewRenderer(manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager)); - pushNewRenderer(manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager)); - MineLittlePony.logger.info("Illagers are now ponies."); - } else { - restoreRenderer(EntityVex.class); - restoreRenderer(EntityEvoker.class); - restoreRenderer(EntityVindicator.class); - restoreRenderer(EntityIllusionIllager.class); - } - - if (config.guardians) { - pushNewRenderer(manager, EntityGuardian.class, new RenderPonyGuardian(manager)); - pushNewRenderer(manager, EntityElderGuardian.class, new RenderPonyGuardian.Elder(manager)); - MineLittlePony.logger.info("Guardians are now ponies."); - } else { - restoreRenderer(EntityGuardian.class); - restoreRenderer(EntityElderGuardian.class); + for (MobRenderers i : MobRenderers.values()) { + i.apply(this, manager); } } /** - * Pushes a new renderer replacement storing the original internally. This change can be undone with {@link #restoreRenderer(Class)} + * + * Replaces an entity renderer depending on whether we want ponies or not. + * + * @param state True if we want ponies (the original will be stored) * @param manager The render manager * @param type The type to replace * @param renderer The replacement value * @param The entity type */ @SuppressWarnings("unchecked") - public void pushNewRenderer(RenderManager manager, Class type, Render renderer) { - if (!renderMap.containsKey(type)) { - renderMap.put(type, manager.getEntityClassRenderObject(type)); - } - ModUtilities.addRenderer((Class)type, renderer); - } - - /** - * Restores a renderer to its previous value. - */ - @SuppressWarnings("unchecked") - public void restoreRenderer(Class type) { - if (renderMap.containsKey(type)) { - ModUtilities.addRenderer(type, (Render)renderMap.get(type)); + public void switchRenderer(boolean state, RenderManager manager, Class type, Render renderer) { + if (state) { + if (!renderMap.containsKey(type)) { + renderMap.put(type, manager.getEntityClassRenderObject(type)); + } + ModUtilities.addRenderer((Class)type, renderer); + } else { + if (renderMap.containsKey(type)) { + ModUtilities.addRenderer(type, (Render)renderMap.get(type)); + } } } diff --git a/src/main/java/com/minelittlepony/gui/GuiPonySettings.java b/src/main/java/com/minelittlepony/gui/GuiPonySettings.java index ada4bf93..f11f25f2 100644 --- a/src/main/java/com/minelittlepony/gui/GuiPonySettings.java +++ b/src/main/java/com/minelittlepony/gui/GuiPonySettings.java @@ -4,7 +4,9 @@ import java.io.IOException; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyConfig; +import com.minelittlepony.PonyConfig.PonySettings; import com.minelittlepony.pony.data.PonyLevel; +import com.minelittlepony.render.ponies.MobRenderers; import com.mumfrey.liteloader.core.LiteLoader; import net.minecraft.client.gui.GuiButton; @@ -51,10 +53,9 @@ public class GuiPonySettings extends GuiScreen { row += 15; addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1)); - addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "hd", config.hd, v -> config.hd = v)); - addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "snuzzles", config.snuzzles, v -> config.snuzzles = v)); - addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "sizes", config.sizes, v -> config.sizes = v)); - addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + "showscale", config.showscale, v -> config.showscale = v)); + for (PonySettings i : PonySettings.values()) { + addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(), i)); + } if (mustScroll()) { row += 15; @@ -63,12 +64,9 @@ public class GuiPonySettings extends GuiScreen { } addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "villagers", config.villagers, v -> config.villagers = v)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "zombies", config.zombies, v -> config.zombies = v)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "zombiepigmen", config.pigzombies, v -> config.pigzombies = v)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "skeletons", config.skeletons, v -> config.skeletons = v)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "illagers", config.illagers, v -> config.illagers = v)); - addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + "guardians", config.guardians, v -> config.guardians = v)); + for (MobRenderers i : MobRenderers.values()) { + addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(), i)); + } } @Override @@ -87,7 +85,6 @@ public class GuiPonySettings extends GuiScreen { @Override public void onGuiClosed() { LiteLoader.getInstance().writeConfig(config); - MineLittlePony.getInstance().getRenderManager().initializeMobRenderers(mc.getRenderManager(), config); } protected String getTitle() { diff --git a/src/main/java/com/minelittlepony/render/ponies/MobRenderers.java b/src/main/java/com/minelittlepony/render/ponies/MobRenderers.java new file mode 100644 index 00000000..e7f17034 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/MobRenderers.java @@ -0,0 +1,82 @@ +package com.minelittlepony.render.ponies; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.PonyRenderManager; +import com.minelittlepony.settings.SensibleConfig.Setting; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.monster.*; +import net.minecraft.entity.passive.*; + +/** + * Central location where new entity renderers are registered and applied. + * + * Due to the limitations in Mumfrey's framework, needs to be paired with a field in PonyConfig. + */ +public enum MobRenderers implements Setting { + VILLAGERS { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntityVillager.class, new RenderPonyVillager(manager)); + pony.switchRenderer(state, manager, EntityWitch.class, new RenderPonyWitch(manager)); + pony.switchRenderer(state, manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager)); + } + }, + ZOMBIES { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntityZombie.class, new RenderPonyZombie<>(manager)); + pony.switchRenderer(state, manager, EntityHusk.class, new RenderPonyZombie.Husk(manager)); + pony.switchRenderer(state, manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager)); + } + }, + PIGZOMBIES { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntityPigZombie.class, new RenderPonyPigman(manager)); + } + }, + SKELETONS { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager)); + pony.switchRenderer(state, manager, EntityStray.class, new RenderPonySkeleton.Stray(manager)); + pony.switchRenderer(state, manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager)); + } + }, + ILLAGERS { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntityVex.class, new RenderPonyVex(manager)); + pony.switchRenderer(state, manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager)); + pony.switchRenderer(state, manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager)); + pony.switchRenderer(state, manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager)); + } + }, + GUARDIANS { + @Override + public void register(boolean state, PonyRenderManager pony, RenderManager manager) { + pony.switchRenderer(state, manager, EntityGuardian.class, new RenderPonyGuardian(manager)); + pony.switchRenderer(state, manager, EntityElderGuardian.class, new RenderPonyGuardian.Elder(manager)); + } + }; + + @Override + public void set(boolean value) { + Setting.super.set(value); + apply(MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager()); + } + + public void apply(PonyRenderManager pony, RenderManager manager) { + boolean state = get(); + register(state, pony, manager); + if (state) { + MineLittlePony.logger.info(name() + " are now ponies."); + } else { + MineLittlePony.logger.info(name() + " are no longer ponies."); + } + } + + public abstract void register(boolean state, PonyRenderManager pony, RenderManager manager); +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/settings/SensibleConfig.java b/src/main/java/com/minelittlepony/settings/SensibleConfig.java new file mode 100644 index 00000000..a12f1f3f --- /dev/null +++ b/src/main/java/com/minelittlepony/settings/SensibleConfig.java @@ -0,0 +1,60 @@ +package com.minelittlepony.settings; + +import com.minelittlepony.gui.IGUIAction; + +/** + * A sensible config container that actually lets us programatically index values by a key. + * + * Reflection because Mumfrey pls. + * + */ +// Mumfrey pls. +public abstract class SensibleConfig { + + private static SensibleConfig instance; + + public SensibleConfig() { + instance = this; + } + + public interface Setting extends IGUIAction { + String name(); + + /** + * Gets the config value associated with this entry. + */ + default boolean get() { + return instance.getValue(this); + } + + + /** + * Sets the config value associated with this entry. + */ + default void set(boolean value) { + instance.setValue(this, value); + } + + @Override + default Boolean perform(Boolean v) { + set(v); + return v; + } + } + + public boolean getValue(Setting key) { + try { + return this.getClass().getField(key.name().toLowerCase()).getBoolean(this); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ignored) { + return true; + } + } + + public boolean setValue(Setting key, boolean value) { + try { + this.getClass().getField(key.name().toLowerCase()).setBoolean(this, value); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ignored) { + } + return value; + } +} From 9899a01aae63009c59e950e9527983e391bbd8f3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 15 May 2018 16:31:15 +0200 Subject: [PATCH 5/6] Correct translation strings for zombie pigmen. You should've named your config variable correctly. --- src/main/resources/assets/minelittlepony/lang/en_us.lang | 2 +- src/main/resources/assets/minelittlepony/lang/fr_fr.lang | 2 +- src/main/resources/assets/minelittlepony/lang/ru_ru.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/minelittlepony/lang/en_us.lang b/src/main/resources/assets/minelittlepony/lang/en_us.lang index 94b57348..cd6be664 100644 --- a/src/main/resources/assets/minelittlepony/lang/en_us.lang +++ b/src/main/resources/assets/minelittlepony/lang/en_us.lang @@ -12,7 +12,7 @@ minelp.options.showscale=Use show-accurate scaling minelp.mobs.title=Mob Settings minelp.mobs.villagers=Ponify villagers minelp.mobs.zombies=Ponify zombies -minelp.mobs.zombiepigmen=Ponify zombie pigmen +minelp.mobs.pigzombies=Ponify zombie pigmen minelp.mobs.skeletons=Ponify skeletons minelp.mobs.illagers=Ponify illagers minelp.mobs.guardians=Ponify guardians diff --git a/src/main/resources/assets/minelittlepony/lang/fr_fr.lang b/src/main/resources/assets/minelittlepony/lang/fr_fr.lang index 617b82b7..0dcff50f 100644 --- a/src/main/resources/assets/minelittlepony/lang/fr_fr.lang +++ b/src/main/resources/assets/minelittlepony/lang/fr_fr.lang @@ -15,7 +15,7 @@ minelp.options.showscale=Utiliser échelle fidéle á MLP minelp.mobs.title=Options de mobs minelp.mobs.villagers=Ponifier villageois minelp.mobs.zombies=Ponifier zombies -minelp.mobs.zombiepigmen=Ponifier cochon-zombie +minelp.mobs.pigzombies=Ponifier cochon-zombie minelp.mobs.skeletons=Ponifier squelettes minelp.mobs.illagers=Ponifier illagers minelp.mobs.guardians=Ponifier gardien diff --git a/src/main/resources/assets/minelittlepony/lang/ru_ru.lang b/src/main/resources/assets/minelittlepony/lang/ru_ru.lang index 51cb3714..2d981d2c 100644 --- a/src/main/resources/assets/minelittlepony/lang/ru_ru.lang +++ b/src/main/resources/assets/minelittlepony/lang/ru_ru.lang @@ -12,5 +12,5 @@ minelp.options.showscale=Использовать более точное мас minelp.mobs.title=Пони-мобы minelp.mobs.villagers=Пони-житель minelp.mobs.zombies=Пони-зомби -minelp.mobs.zombiepigmen=Пони-свинозомби +minelp.mobs.pigzombies=Пони-свинозомби minelp.mobs.skeletons=Пони-скелеты From 0393daa0ba11465db1d804256697b361950bbe10 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 2 Jun 2018 18:05:33 +0200 Subject: [PATCH 6/6] Fix merge conflicts --- .../com/minelittlepony/model/armour/ModelPonyArmor.java | 2 +- .../minelittlepony/model/capabilities/IModelPart.java | 7 +++++++ .../com/minelittlepony/model/components/PonyTail.java | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index d1cfd238..afcec982 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -97,7 +97,7 @@ public class ModelPonyArmor extends AbstractPonyModel { flankGuard.showModel = invisible; saddle.showModel = invisible; bipedHead.showModel = invisible; - tail.isHidden = true; + tail.setVisible(false); neck.isHidden = true; upperTorso.isHidden = true; snout.isHidden = true; diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelPart.java b/src/main/java/com/minelittlepony/model/capabilities/IModelPart.java index bf8c0af3..f1bddfe3 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModelPart.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelPart.java @@ -19,4 +19,11 @@ public interface IModelPart { * Renders this model component. */ void render(float scale); + + /** + * Sets whether this part should be rendered. + */ + default void setVisible(boolean visible) { + + } } diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index daaabff9..c7a50f41 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -17,6 +17,8 @@ public class PonyTail extends PlaneRenderer implements IModelPart { private int tailStop = 0; + public boolean isHidden = false; + public PonyTail(AbstractPonyModel model) { super(model); theModel = model; @@ -72,6 +74,11 @@ public class PonyTail extends PlaneRenderer implements IModelPart { rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F; } + @Override + public void setVisible(boolean visible) { + isHidden = !visible; + } + private class TailSegment extends PlaneRenderer { private final int index; @@ -103,7 +110,7 @@ public class PonyTail extends PlaneRenderer implements IModelPart { @Override public void render(float scale) { - if (index < tailStop) { + if (!isHidden && index < tailStop) { super.render(scale); } }