From def22e1ebb778721d82302c584986eb268abc624 Mon Sep 17 00:00:00 2001 From: Marcel Konrad Date: Fri, 22 Jun 2018 00:16:32 +0200 Subject: [PATCH] Update variable names --- .../gui/button/GuiButtonList.java | 38 +- .../worldhandler/gui/button/GuiSlider.java | 36 +- .../button/logic/ColorListButtonLogic.java | 8 +- .../gui/button/logic/IListButtonLogic.java | 12 +- .../ButtonValues.java} | 4 +- .../SliderValues.java} | 10 +- .../worldhandler/gui/category/Category.java | 2 +- .../impl/GuiWorldHandlerContainer.java | 32 +- .../worldhandler/gui/content/Content.java | 22 +- .../worldhandler/gui/content/Contents.java | 8 +- .../element/impl/ElementClickList.java | 62 +-- .../element/impl/ElementColorMenu.java | 6 +- .../content/element/impl/ElementPageList.java | 30 +- .../gui/content/impl/ContentAdvancements.java | 10 +- .../gui/content/impl/ContentEditBlocks.java | 10 +- .../gui/content/impl/ContentPlaysound.java | 470 ++++++++++++++++++ 16 files changed, 621 insertions(+), 139 deletions(-) rename src/main/java/exopandora/worldhandler/gui/button/{storage/ButtonStorage.java => persistence/ButtonValues.java} (85%) rename src/main/java/exopandora/worldhandler/gui/button/{storage/SliderStorage.java => persistence/SliderValues.java} (79%) create mode 100644 src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlaysound.java diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java index e8dd642..0addb1e 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java +++ b/src/main/java/exopandora/worldhandler/gui/button/GuiButtonList.java @@ -4,7 +4,7 @@ import com.mojang.realmsclient.gui.ChatFormatting; import exopandora.worldhandler.format.TextFormatting; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import net.minecraft.client.Minecraft; @@ -17,21 +17,21 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class GuiButtonList extends GuiButtonWorldHandler { private final IListButtonLogic logic; - private final ButtonStorage storage; + private final ButtonValues persistence; private int mouseX; private int mouseY; - public GuiButtonList(int id, int x, int y, int width, int height, Content container, IListButtonLogic logic) + public GuiButtonList(int id, int x, int y, int width, int height, Content content, IListButtonLogic logic) { - this(id, x, y, width, height, null, container, logic); + this(id, x, y, width, height, null, content, logic); } - public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content container, IListButtonLogic logic) + public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content content, IListButtonLogic logic) { super(id, x, y, width, height, null, null, tooltipType); this.logic = logic; - this.storage = container.getStorage(this.logic.getId()); - this.updateStorageObject(); + this.persistence = content.getPersistence(this.logic.getId()); + this.updatePersistenceObject(); } @Override @@ -46,7 +46,7 @@ public class GuiButtonList extends GuiButtonWorldHandler this.mouseX = mouseX; this.mouseY = mouseY; - this.displayString = this.logic.getDisplayString(this.storage); + this.displayString = this.logic.getDisplayString(this.persistence); if(this.displayString != null && !this.displayString.isEmpty()) { @@ -77,7 +77,7 @@ public class GuiButtonList extends GuiButtonWorldHandler { if(this.tooltipType != null) { - this.displayTooltip = this.logic.getTooltipString(this.storage); + this.displayTooltip = this.logic.getTooltipString(this.persistence); } super.drawTooltip(mouseX, mouseY, width, height); @@ -102,34 +102,34 @@ public class GuiButtonList extends GuiButtonWorldHandler { if(this.isHoveringLeft(this.mouseX, this.mouseY)) { - if(this.storage.getIndex() > 0) + if(this.persistence.getIndex() > 0) { - this.storage.decrementIndex(); + this.persistence.decrementIndex(); } else { - this.storage.setIndex(this.logic.getMax() - 1); + this.persistence.setIndex(this.logic.getMax() - 1); } } else if(this.isHoveringRight(this.mouseX, this.mouseY)) { - if(this.storage.getIndex() < this.logic.getMax() - 1) + if(this.persistence.getIndex() < this.logic.getMax() - 1) { - this.storage.incrementIndex(); + this.persistence.incrementIndex(); } else { - this.storage.setIndex(0); + this.persistence.setIndex(0); } } - this.updateStorageObject(); - this.logic.actionPerformed(container, button, this.storage); + this.updatePersistenceObject(); + this.logic.actionPerformed(container, button, this.persistence); } - private void updateStorageObject() + private void updatePersistenceObject() { - this.storage.setObject(this.logic.getObject(this.storage.getIndex())); + this.persistence.setObject(this.logic.getObject(this.persistence.getIndex())); } public IListButtonLogic getLogic() diff --git a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java index 3b3d9db..835da31 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java +++ b/src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java @@ -2,8 +2,8 @@ package exopandora.worldhandler.gui.button; import exopandora.worldhandler.config.ConfigSkin; import exopandora.worldhandler.gui.button.logic.ISliderResponder; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; -import exopandora.worldhandler.gui.button.storage.SliderStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; +import exopandora.worldhandler.gui.button.persistence.SliderValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.helper.ResourceHelper; @@ -25,64 +25,64 @@ public class GuiSlider extends GuiButton private final String name; private final ISliderResponder responder; private final Container frame; - private final ButtonStorage storage; + private final ButtonValues persistence; - public GuiSlider(Content container, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder) + public GuiSlider(Content content, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder) { super(Integer.MAX_VALUE, x, y, width, height, null); this.frame = frame; this.key = key; this.name = name; this.responder = responder; - this.storage = container.getStorage(key); - this.initStorage(Math.round(min), Math.round(max), Math.round(start)); + this.persistence = content.getPersistence(key); + this.initValues(Math.round(min), Math.round(max), Math.round(start)); this.displayString = this.getDisplayString(); } - private void initStorage(double min, double max, double start) + private void initValues(double min, double max, double start) { - if(this.storage.getObject() == null) + if(this.persistence.getObject() == null) { if(min == max) { - this.storage.setObject(new SliderStorage(min, max, 0.0D)); + this.persistence.setObject(new SliderValues(min, max, 0.0D)); } else { - this.storage.setObject(new SliderStorage(min, max, (start - min) / (max - min))); + this.persistence.setObject(new SliderValues(min, max, (start - min) / (max - min))); } } - else if(this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max) + else if(this.persistence.getObject().getMin() != min || this.persistence.getObject().getMax() != max) { - this.storage.setObject(new SliderStorage(min, max, (int) MathHelper.clamp(this.getValue(), min, max))); + this.persistence.setObject(new SliderValues(min, max, (int) MathHelper.clamp(this.getValue(), min, max))); } } private void setPosition(double position) { - this.storage.getObject().setPosition(position); + this.persistence.getObject().setPosition(position); } private double getPosition() { - return this.storage.getObject().getPosition(); + return this.persistence.getObject().getPosition(); } private void setValue(int value) { - this.storage.getObject().setValue(value); + this.persistence.getObject().setValue(value); } private int getValue() { - return this.storage.getObject().getValue(); + return this.persistence.getObject().getValue(); } private String getDisplayString() { return this.responder.getText(this.key, I18n.format(this.name), this.getValue()); } - + @Override protected int getHoverState(boolean mouseOver) { @@ -188,7 +188,7 @@ public class GuiSlider extends GuiButton return false; } - + @Override public void mouseReleased(int mouseX, int mouseY) { diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java index 3711650..a2350b6 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java +++ b/src/main/java/exopandora/worldhandler/gui/button/logic/ColorListButtonLogic.java @@ -5,7 +5,7 @@ import java.util.Arrays; import com.mojang.realmsclient.gui.ChatFormatting; import exopandora.worldhandler.format.EnumColor; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -26,15 +26,15 @@ public abstract class ColorListButtonLogic implements IListButtonLogic } @Override - public String getTooltipString(ButtonStorage storage) + public String getTooltipString(ButtonValues values) { return null; } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - EnumColor color = EnumColor.getColorFromId(storage.getIndex()); + EnumColor color = EnumColor.getColorFromId(values.getIndex()); return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat()); } diff --git a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java b/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java index a5e1db4..0f3ce55 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java +++ b/src/main/java/exopandora/worldhandler/gui/button/logic/IListButtonLogic.java @@ -1,6 +1,6 @@ package exopandora.worldhandler.gui.button.logic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import net.minecraft.client.gui.GuiButton; import net.minecraftforge.fml.relauncher.Side; @@ -9,19 +9,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public interface IListButtonLogic { - void actionPerformed(Container container, GuiButton button, ButtonStorage storage); + void actionPerformed(Container container, GuiButton button, ButtonValues values); int getMax(); T getObject(int index); - String getDisplayString(ButtonStorage storage); + String getDisplayString(ButtonValues values); - default String getTooltipString(ButtonStorage storage) + default String getTooltipString(ButtonValues values) { - if(storage != null && storage.getObject() != null) + if(values != null && values.getObject() != null) { - return storage.getObject().toString() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")"; + return values.getObject().toString() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")"; } return null; diff --git a/src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java similarity index 85% rename from src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java rename to src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java index b8a6dc6..531ddab 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/storage/ButtonStorage.java +++ b/src/main/java/exopandora/worldhandler/gui/button/persistence/ButtonValues.java @@ -1,10 +1,10 @@ -package exopandora.worldhandler.gui.button.storage; +package exopandora.worldhandler.gui.button.persistence; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ButtonStorage +public class ButtonValues { private int index; private T object; diff --git a/src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java b/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java similarity index 79% rename from src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java rename to src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java index 594a505..01b54c3 100644 --- a/src/main/java/exopandora/worldhandler/gui/button/storage/SliderStorage.java +++ b/src/main/java/exopandora/worldhandler/gui/button/persistence/SliderValues.java @@ -1,29 +1,29 @@ -package exopandora.worldhandler.gui.button.storage; +package exopandora.worldhandler.gui.button.persistence; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class SliderStorage +public class SliderValues { private final double min; private final double max; private double position; - private SliderStorage(double min, double max) + private SliderValues(double min, double max) { this.min = min; this.max = max; } - public SliderStorage(double min, double max, double position) + public SliderValues(double min, double max, double position) { this(min, max); this.position = position; } - public SliderStorage(double min, double max, int value) + public SliderValues(double min, double max, int value) { this(min, max); this.position = this.valueToPosition(value); diff --git a/src/main/java/exopandora/worldhandler/gui/category/Category.java b/src/main/java/exopandora/worldhandler/gui/category/Category.java index 716955d..502da52 100644 --- a/src/main/java/exopandora/worldhandler/gui/category/Category.java +++ b/src/main/java/exopandora/worldhandler/gui/category/Category.java @@ -61,7 +61,7 @@ public class Category public static void registerCategories() { registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER)); - registerCategory(1, "entities", new Category(Contents.SUMMON)); + registerCategory(1, "entities", new Category(Contents.SUMMON, Contents.PLAYSOUND)); registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT)); registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR)); registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES)); diff --git a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java index d988f2b..665799f 100644 --- a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java +++ b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandlerContainer.java @@ -12,7 +12,6 @@ import javax.annotation.Nullable; import com.google.common.base.Predicates; import com.mojang.realmsclient.gui.ChatFormatting; -import exopandora.worldhandler.Main; import exopandora.worldhandler.WorldHandler; import exopandora.worldhandler.builder.impl.BuilderDifficulty; import exopandora.worldhandler.builder.impl.BuilderDifficulty.EnumDifficulty; @@ -144,7 +143,7 @@ public class GuiWorldHandlerContainer extends Container if(!this.content.getActiveContent().equals(tab)) { - this.finalButtons.add(new GuiButtonTab(-16, (int)(backgroundX + xOffset), backgroundY - 20, (int)this.tabWidth + (int)Math.ceil(this.tabEpsilon / this.tabSize), 21, index)); + this.finalButtons.add(new GuiButtonTab(-16, (int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, index)); } }); @@ -343,7 +342,6 @@ public class GuiWorldHandlerContainer extends Container break elements; } } - this.content.actionPerformed(this, button); break; } @@ -351,7 +349,7 @@ public class GuiWorldHandlerContainer extends Container private void defaultColor() { - this.defaultColor(1); + this.defaultColor(1.0F); } private void defaultColor(float alpha) @@ -445,8 +443,8 @@ public class GuiWorldHandlerContainer extends Container } this.bindBackground(); - this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight); - this.drawTexturedModalRect((int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight); + this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight); + this.drawTexturedModalRect((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight); if(!ConfigSkin.areSharpEdgesEnabled()) { @@ -460,7 +458,7 @@ public class GuiWorldHandlerContainer extends Container for(int x = 0; x < factor; x++) { - this.drawTexturedModalRect((int)(backgroundX + this.tabWidth + xOffset - x - 1), (int)(backgroundY + x + 1), (int)(this.tabWidth - x - 1), x + 1, x + 1, 1); + this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1); } } @@ -472,7 +470,7 @@ public class GuiWorldHandlerContainer extends Container for(int x = 0; x < factor; x++) { - this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1); + this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1); } } @@ -486,7 +484,7 @@ public class GuiWorldHandlerContainer extends Container for(int x = 0; x < width; x += interval) { this.defaultColor(1.0F - (x / (width + 5.0F * interval))); - this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1); + this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1); } } @@ -499,7 +497,7 @@ public class GuiWorldHandlerContainer extends Container for(int x = 0; x < width; x += interval) { this.defaultColor(1.0F - (x / (width + 5.0F * interval))); - this.drawTexturedModalRect((int)(backgroundX + Math.ceil(xOffset) + x + offset), (int)(backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1); + this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1); } } } @@ -531,17 +529,20 @@ public class GuiWorldHandlerContainer extends Container } } - this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY - 13), color); + this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color); }); this.defaultColor(); //VERSION LABEL + final String label = "$mcversion-$version"; final int hexAlpha = (int) (0xFF * 0.2) << 24; final int color = ConfigSkin.getLabelColor() + hexAlpha; + final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2; + final int versionHeight = this.height - 10; - this.fontRenderer.drawString("$mcversion-$version", this.width - this.fontRenderer.getStringWidth("$mcversion-$version") - 2, this.height - 10, color); + this.fontRenderer.drawString(label, versionWidth, versionHeight, color); //TITLE @@ -648,6 +649,13 @@ public class GuiWorldHandlerContainer extends Container } } } + + //VERSION LABEL TOOLTIP + + if(mouseX >= versionWidth && mouseY >= versionHeight) + { + GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer); + } } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/Content.java b/src/main/java/exopandora/worldhandler/gui/content/Content.java index cd08d5d..032d6f6 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Content.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Content.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; import exopandora.worldhandler.Main; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.content.impl.ContentAdvancements; import exopandora.worldhandler.gui.content.impl.ContentButcher; import exopandora.worldhandler.gui.content.impl.ContentChangeWorld; @@ -19,6 +19,7 @@ import exopandora.worldhandler.gui.content.impl.ContentMain; import exopandora.worldhandler.gui.content.impl.ContentMultiplayer; import exopandora.worldhandler.gui.content.impl.ContentNoteEditor; import exopandora.worldhandler.gui.content.impl.ContentPlayer; +import exopandora.worldhandler.gui.content.impl.ContentPlaysound; import exopandora.worldhandler.gui.content.impl.ContentPotions; import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives; import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers; @@ -45,6 +46,7 @@ public abstract class Content implements IContent //ENTITIES registerContent(3, "summon", new ContentSummon()); + registerContent(21, "playsound", new ContentPlaysound()); //ITEMS registerContent(5, "custom_item", new ContentCustomItem()); @@ -88,24 +90,24 @@ public abstract class Content implements IContent REGISTRY.register(id, textualID, content); } - private Map storage; + private Map persistence; - public ButtonStorage getStorage(Object id) + public ButtonValues getPersistence(Object id) { - if(this.storage == null) + if(this.persistence == null) { - this.storage = new HashMap(); + this.persistence = new HashMap(); } - if(this.storage.containsKey(id)) + if(this.persistence.containsKey(id)) { - return this.storage.get(id); + return this.persistence.get(id); } - ButtonStorage storage = new ButtonStorage(); + ButtonValues values = new ButtonValues(); - this.storage.put(id, storage); + this.persistence.put(id, values); - return storage; + return values; } } diff --git a/src/main/java/exopandora/worldhandler/gui/content/Contents.java b/src/main/java/exopandora/worldhandler/gui/content/Contents.java index 376aa6b..dbbddfe 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Contents.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Contents.java @@ -15,6 +15,7 @@ public class Contents public static final Content MULTIPLAYER; public static final Content SUMMON; + public static final Content PLAYSOUND; public static final Content CUSTOM_ITEM; public static final Content ENCHANTMENT; @@ -47,6 +48,7 @@ public class Contents MULTIPLAYER = Contents.getRegisteredContainer("multiplayer"); SUMMON = Contents.getRegisteredContainer("summon"); + PLAYSOUND = Contents.getRegisteredContainer("playsound"); CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item"); ENCHANTMENT = Contents.getRegisteredContainer("enchantment"); @@ -75,13 +77,13 @@ public class Contents private static T getRegisteredContainer(String name) { - Content container = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name)); + Content content = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name)); - if(container == null) + if(content == null) { throw new IllegalStateException("Invalid Container requested: " + name); } - return (T) container; + return (T) content; } } \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java index b7da6df..0758d8a 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementClickList.java @@ -7,7 +7,7 @@ import javax.annotation.Nullable; import exopandora.worldhandler.gui.button.EnumTooltip; import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; @@ -26,16 +26,16 @@ public class ElementClickList extends Element private final ILogicClickList logic; private GuiButtonList button1; private GuiButtonList button2; - private final Content master; + private final Content content; - public ElementClickList(int x, int y, List list, int buttonId1, int buttonId2, Content container, ILogicClickList logic) + public ElementClickList(int x, int y, List list, int buttonId1, int buttonId2, Content content, ILogicClickList logic) { super(x, y); this.list = list; this.buttonId1 = buttonId1; this.buttonId2 = buttonId2; this.logic = logic; - this.master = container; + this.content = content; } @Override @@ -47,12 +47,12 @@ public class ElementClickList extends Element @Override public void initButtons(Container container) { - container.add(this.button1 = new GuiButtonList(this.buttonId1, this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.master, new IListButtonLogic() + container.add(this.button1 = new GuiButtonList(this.buttonId1, this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.content, new IListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - master.getStorage(listButtonLogic2.getId()).setIndex(0); + content.getPersistence(listButtonLogic2.getId()).setIndex(0); container.initButtons(); } @@ -69,17 +69,17 @@ public class ElementClickList extends Element } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return logic.translate1(storage.getObject().getKey()); + return logic.translate1(values.getObject().getKey()); } @Override - public String getTooltipString(ButtonStorage storage) + public String getTooltipString(ButtonValues values) { - if(storage != null && storage.getObject() != null) + if(values != null && values.getObject() != null) { - return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")"; + return values.getObject().getKey() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")"; } return null; @@ -92,17 +92,17 @@ public class ElementClickList extends Element } })); - final Node node = this.getStorage1().getObject(); + final Node node = this.getValues1().getObject(); this.logic.consumeKey1(node.getKey()); if(node.getEntries() != null) { - container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2)); - this.logic.consumeKey2(node.getKey(), node.getEntries().get(this.getStorage2().getIndex()).getKey()); + container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.content, this.listButtonLogic2)); + this.logic.consumeKey2(node.getKey(), node.getEntries().get(this.getValues2().getIndex()).getKey()); } else { - container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2)); + container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.content, this.listButtonLogic2)); this.button2.enabled = false; } } @@ -110,7 +110,7 @@ public class ElementClickList extends Element private final IListButtonLogic listButtonLogic2 = new IListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { container.initButtons(); } @@ -118,9 +118,9 @@ public class ElementClickList extends Element @Override public int getMax() { - if(getStorage1().getObject() != null) + if(getValues1().getObject() != null) { - return getStorage1().getObject().getEntries().size(); + return getValues1().getObject().getEntries().size(); } return 0; @@ -129,31 +129,31 @@ public class ElementClickList extends Element @Override public Node getObject(int index) { - if(getStorage1().getObject().getEntries() != null) + if(getValues1().getObject().getEntries() != null) { - return getStorage1().getObject().getEntries().get(index); + return getValues1().getObject().getEntries().get(index); } return null; } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - if(storage.getObject() != null) + if(values.getObject() != null) { - return logic.translate2(getStorage1().getObject().getKey(), storage.getObject().getKey()); + return logic.translate2(getValues1().getObject().getKey(), values.getObject().getKey()); } return null; } @Override - public String getTooltipString(ButtonStorage storage) + public String getTooltipString(ButtonValues values) { - if(getStorage1().getObject().getEntries() != null) + if(getValues1().getObject().getEntries() != null) { - return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + getStorage1().getObject().getEntries().size() + ")"; + return values.getObject().getKey() + " (" + (values.getIndex() + 1) + "/" + getValues1().getObject().getEntries().size() + ")"; } return null; @@ -167,22 +167,22 @@ public class ElementClickList extends Element }; @Nullable - private ButtonStorage getStorage1() + private ButtonValues getValues1() { if(this.button1 != null) { - return this.master.getStorage(this.button1.getLogic().getId()); + return this.content.getPersistence(this.button1.getLogic().getId()); } return null; } @Nullable - private ButtonStorage getStorage2() + private ButtonValues getValues2() { if(this.button2 != null) { - return this.master.getStorage(this.button2.getLogic().getId()); + return this.content.getPersistence(this.button2.getLogic().getId()); } return null; diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java index 50b3a71..6a8082a 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementColorMenu.java @@ -7,7 +7,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.GuiTextFieldTooltip; import exopandora.worldhandler.gui.button.logic.ColorListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; @@ -59,9 +59,9 @@ public class ElementColorMenu extends Element container.add(this.colorList = new GuiButtonList(this.ids[0], this.x + 118, this.y + 24, 114, 20, this.content, new ColorListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - string.setColor(storage.getIndex()); + string.setColor(values.getIndex()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java index b76bd1b..d7eae58 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java +++ b/src/main/java/exopandora/worldhandler/gui/content/element/impl/ElementPageList.java @@ -5,7 +5,7 @@ import java.util.List; import exopandora.worldhandler.config.ConfigSkin; import exopandora.worldhandler.format.TextFormatting; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.container.Container; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.gui.content.element.Element; @@ -24,9 +24,9 @@ public class ElementPageList extends Element private final int width; private final int height; private final int[] ids; - private final ButtonStorage storage; + private final ButtonValues values; - public ElementPageList(int x, int y, List list, K initial, int width, int height, int length, Content container, int[] ids, ILogicPageList logic) + public ElementPageList(int x, int y, List list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList logic) { super(x, y); this.list = list; @@ -34,15 +34,15 @@ public class ElementPageList extends Element this.width = width; this.height = height; this.logic = logic; - this.storage = container.getStorage(logic.getId()); + this.values = content.getPersistence(logic.getId()); this.ids = ids; this.list.sort((a, b) -> this.logic.translate(a).compareTo(this.logic.translate(b))); - if(this.storage.getObject() == null) + if(this.values.getObject() == null) { - this.storage.setObject(0); - this.storage.setIndex(Math.max(0, this.list.indexOf(this.logic.convert(initial)))); + this.values.setObject(0); + this.values.setIndex(Math.max(0, this.list.indexOf(this.logic.convert(initial)))); if(initial == null) { @@ -69,8 +69,8 @@ public class ElementPageList extends Element GuiButtonWorldHandler left = new GuiButtonWorldHandler(this.ids[0], this.x, this.y + (this.height + 4) * this.length, buttonWidth + 1, this.height, "<"); GuiButtonWorldHandler right = new GuiButtonWorldHandler(this.ids[1], this.x + 5 + buttonWidth, this.y + (this.height + 4) * this.length, buttonWidth, this.height, ">"); - left.enabled = this.storage.getObject() > 0; - right.enabled = this.storage.getObject() < this.getTotalPages() - 1; + left.enabled = this.values.getObject() > 0; + right.enabled = this.values.getObject() < this.getTotalPages() - 1; container.add(left); container.add(right); @@ -80,12 +80,12 @@ public class ElementPageList extends Element for(int x = 0; x < length; x++) { - int index = this.storage.getObject() * length + x; + int index = this.values.getObject() * length + x; if(index < this.list.size()) { T entry = this.list.get(index); - this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.storage.getIndex() != index, entry, container); + this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.values.getIndex() != index, entry, container); } else { @@ -101,13 +101,13 @@ public class ElementPageList extends Element { if(button.id == this.ids[0]) { - this.storage.setObject(this.storage.getObject() - 1); + this.values.setObject(this.values.getObject() - 1); container.initGui(); return true; } else if(button.id == this.ids[1]) { - this.storage.setObject(this.storage.getObject() + 1); + this.values.setObject(this.values.getObject() + 1); container.initGui(); return true; } @@ -119,7 +119,7 @@ public class ElementPageList extends Element if(TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer).equals(button.displayString)) { - this.storage.setIndex(x); + this.values.setIndex(x); this.logic.onClick(entry); container.initGui(); return true; @@ -133,7 +133,7 @@ public class ElementPageList extends Element @Override public void draw() { - Minecraft.getMinecraft().fontRenderer.drawString((this.storage.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor()); + Minecraft.getMinecraft().fontRenderer.drawString((this.values.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor()); } private int getTotalPages() diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java index 8d52a7e..4dfd8f6 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentAdvancements.java @@ -17,7 +17,7 @@ import exopandora.worldhandler.gui.button.EnumTooltip; import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.category.Categories; import exopandora.worldhandler.gui.category.Category; import exopandora.worldhandler.gui.container.Container; @@ -109,9 +109,9 @@ public class ContentAdvancements extends Content private final EnumMode[] values = Arrays.stream(EnumMode.values()).filter(mode -> !mode.equals(EnumMode.EVERYTHING)).toArray(EnumMode[]::new); @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - builderAdvancement.setMode(storage.getObject()); + builderAdvancement.setMode(values.getObject()); } @Override @@ -127,9 +127,9 @@ public class ContentAdvancements extends Content } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return I18n.format("gui.worldhandler.advancements." + storage.getObject().toString()); + return I18n.format("gui.worldhandler.advancements." + values.getObject().toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java index f1f13e2..4e26113 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEditBlocks.java @@ -14,7 +14,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList; import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; import exopandora.worldhandler.gui.button.GuiTextFieldTooltip; import exopandora.worldhandler.gui.button.logic.IListButtonLogic; -import exopandora.worldhandler.gui.button.storage.ButtonStorage; +import exopandora.worldhandler.gui.button.persistence.ButtonValues; import exopandora.worldhandler.gui.category.Categories; import exopandora.worldhandler.gui.category.Category; import exopandora.worldhandler.gui.container.Container; @@ -178,9 +178,9 @@ public class ContentEditBlocks extends Content container.add(this.cloneButton = new GuiButtonList(9, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic() { @Override - public void actionPerformed(Container container, GuiButton button, ButtonStorage storage) + public void actionPerformed(Container container, GuiButton button, ButtonValues values) { - builderClone.setMask(storage.getObject()); + builderClone.setMask(values.getObject()); } @Override @@ -196,9 +196,9 @@ public class ContentEditBlocks extends Content } @Override - public String getDisplayString(ButtonStorage storage) + public String getDisplayString(ButtonValues values) { - return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + storage.getObject().toString()); + return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + values.getObject().toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlaysound.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlaysound.java new file mode 100644 index 0000000..62faaf8 --- /dev/null +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPlaysound.java @@ -0,0 +1,470 @@ +package exopandora.worldhandler.gui.content.impl; + +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Stack; +import java.util.function.Consumer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.vector.Vector3f; + +import exopandora.worldhandler.gui.button.GuiButtonWorldHandler; +import exopandora.worldhandler.gui.category.Categories; +import exopandora.worldhandler.gui.category.Category; +import exopandora.worldhandler.gui.container.Container; +import exopandora.worldhandler.gui.content.Content; +import exopandora.worldhandler.gui.content.Contents; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.model.ModelBox; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; + +public class ContentPlaysound extends Content +{ + @Override + public void initButtons(Container container, int x, int y) + { + container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"))); + container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"))); + + container.add(new GuiButtonWorldHandler(2, x + 118 / 2, y + 72, 114, 20, "Test")); + } + + @Override + public void actionPerformed(Container container, GuiButton button) + { + if(button.id == 2) + { + try + { + GlStateManager.pushMatrix(); + FloatBuffer buffer = BufferUtils.createFloatBuffer(16); + buffer.clear(); + buffer.put(new float[] {1, 0, 0, 1, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 0}); + buffer.rewind(); + + System.out.println("-----------------"); + for(int x = 0; x < buffer.capacity(); x++) + { + if(x % 4 == 0 && x > 0) + { + System.out.println(); + } + System.out.printf("%02.2f ", buffer.get(x)); + } + System.out.println(); + + GL11.glLoadMatrix(buffer); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + + GlStateManager.rotate(90, 0, 1, 0); +// GlStateManager.translate(1, 1, 1); + + float[] array = new float[buffer.capacity()]; + GlStateManager.getFloat(GL11.GL_MODELVIEW_MATRIX, buffer); + buffer.get(array); + + System.out.println("-----------------"); + for(int x = 0; x < array.length; x++) + { + if(x % 4 == 0 && x > 0) + { + System.out.println(); + } + System.out.printf("%02.2f ", array[x]); + } + System.out.println(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + } + + private Vector3f low = null; + private Vector3f high = null; + + @Override + public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks) + { + int width = x + 232 / 2; + int height = y + 50; + + container.drawRect(width - 20, height - 40, width + 20, height, 0xFFFFFFFF); + + Class entityClass = EntityList.getClass(new ResourceLocation("witch")); + + try + { + Entity entity = EntityList.newEntity(entityClass, Minecraft.getMinecraft().world); +// entity.ticksExisted++; + +// if(entity instanceof EntityLiving) +// { +// ((EntityLiving) entity).onInitialSpawn(new DifficultyInstance(EnumDifficulty.NORMAL, 0, 0, 0), null); +// } + + if(entity instanceof EntityLivingBase) + { + int maxWidth = 40; + int maxHeight = 40; + + int xScale = 0; + int yScale = 0; + + Render render = Minecraft.getMinecraft().getRenderManager().entityRenderMap.get(entity.getClass()); + + if(render instanceof RenderLiving) + { + final RenderLiving living = (RenderLiving) render; + living.getMainModel().setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, entity); + + System.out.println("--------------"); + + this.high = new Vector3f(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); + this.low = new Vector3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); + + this.iterateModel(this.getBaseModels(living.getMainModel().boxList), new Stack(), vectors -> + { + for(int i = 0; i < vectors.length; i++) + { + this.low = new Vector3f(Math.min(this.low.x, vectors[i].x), Math.min(this.low.y, vectors[i].y), Math.min(this.low.z, vectors[i].z)); + this.high = new Vector3f(Math.max(this.high.x, vectors[i].x), Math.max(this.high.y, vectors[i].y), Math.max(this.high.z, vectors[i].z)); + } + }); + +// System.out.println(this.high.y - this.low.y); + + float widthInBlocks = Math.abs(this.high.x - this.low.x) / 16; + float heightInBlocks = Math.abs(this.high.y - this.low.y) / 16; + +// System.out.println("Height: " + heightInBlocks); +// System.out.println("Ent: " + entity.height); +// System.out.println("High: " + this.high); +// System.out.println("Low: " + this.low); + + xScale = MathHelper.floor(maxWidth / widthInBlocks); + yScale = MathHelper.floor(maxHeight / heightInBlocks); + } + +// xScale = MathHelper.floor(maxWidth / entity.width); +// yScale = MathHelper.floor(maxHeight / entity.height); + +// System.out.println(low); +// System.out.println(high); + int scale = Math.min(xScale, yScale); + int yAdjust = scale == xScale ? (maxHeight - scale) / 2 : 0; + +// System.out.println(scale); + GuiInventory.drawEntityOnScreen(width, height - yAdjust, scale, (float) width - mouseX, (float) height - mouseY - entity.getEyeHeight() * yScale - yAdjust, (EntityLivingBase) entity); + } + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + private void iterateModel(List list, Stack shifts, Consumer consumer) + { + for(ModelRenderer model : list) + { + if(!model.isHidden) + { + if(model.showModel) + { + /* + * offset = box width/height/depth + * point = box offset x/y/z + * rotation = rotation + */ + Vector3f modelOffset = new Vector3f(model.offsetX, model.offsetY, model.offsetZ); + Vector3f modelRotationAngle = new Vector3f(model.rotateAngleX, model.rotateAngleY, model.rotateAngleZ); + Vector3f modelRotationPoint = new Vector3f(model.rotationPointX, model.rotationPointY, model.rotationPointZ); + + shifts.push(new ModelShifts(modelOffset, modelRotationAngle, modelRotationPoint)); + + if(model.childModels != null) + { + this.iterateModel(model.childModels, shifts, consumer); + } + + for(ModelBox box : model.cubeList) + { + if(box != null) + { + Vector3f[] vectors = new Vector3f[] + { + new Vector3f(box.posX1, box.posY1, box.posZ1), + new Vector3f(box.posX2, box.posY1, box.posZ1), + new Vector3f(box.posX2, box.posY1, box.posZ2), + new Vector3f(box.posX1, box.posY1, box.posZ2), + new Vector3f(box.posX1, box.posY2, box.posZ1), + new Vector3f(box.posX2, box.posY2, box.posZ1), + new Vector3f(box.posX2, box.posY2, box.posZ2), + new Vector3f(box.posX1, box.posY2, box.posZ2) + }; + +// System.out.println(shifts.size()); + + for(int x = 0; x < 2; x++) + { + for(ModelShifts shift : shifts) + { + this.translate(shift.getOffset(), x, vectors); +// GlStateManager.translate(shift.getOffset().x, shift.getOffset().y, shift.getOffset().z); + + if(shift.getAngle().equals(ORIGIN)) + { + if(!shift.getPoint().equals(ORIGIN)) + { + this.translate(shift.getPoint(), x, vectors); +// GlStateManager.translate(shift.getPoint().x, shift.getPoint().y, shift.getPoint().z); + } + } + else + { + this.translate(shift.getPoint(), x, vectors); +// GlStateManager.translate(shift.getPoint().x, shift.getPoint().y, shift.getPoint().z); + + GlStateManager.pushMatrix(); + FloatBuffer buffer = BufferUtils.createFloatBuffer(16); + buffer.clear(); + this.loadMatrix(buffer, x, vectors); + + if(shift.getAngle().y != 0.0F) + { + GlStateManager.rotate(-shift.getAngle().y * RADIANT, 0.0F, 0.0F, 1.0F); + } + + if(shift.getAngle().z != 0.0F) + { + GlStateManager.rotate(-shift.getAngle().z * RADIANT, 0.0F, 1.0F, 0.0F); + } + + if(shift.getAngle().x != 0.0F) + { + GlStateManager.rotate(-shift.getAngle().x * RADIANT, 1.0F, 0.0F, 0.0F); + } + + this.getMatrix(buffer, x, vectors); + GlStateManager.popMatrix(); + } + } + } + + for(Vector3f vec : vectors) + { + System.out.println(vec.x + "\t" + -vec.y + "\t" + vec.z); + } + + consumer.accept(vectors); + } + } + + shifts.pop(); + } + } + } + } + + private void translate(Vector3f translation, int vectorArrayIndex, Vector3f[] vectors) + { + int arrayPartLength = 4; + int arrayPart = vectorArrayIndex * arrayPartLength; + int arrayPartMax = arrayPart + arrayPartLength; + + for(int y = arrayPart; y < arrayPartMax; y++) + { + Vector3f.add(vectors[y], translation, vectors[y]); + } + } + + private void loadMatrix(FloatBuffer buffer, int vectorArrayIndex, Vector3f[] vectors) + { + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + + for(int y = 0; y < buffer.capacity(); y++) + { + final int index = vectorArrayIndex * 4 + y % 4; + + if(y < 4) + { + buffer.put(vectors[index].x); + } + else if(y >= 4 && y < 8) + { + buffer.put(vectors[index].y); + } + else if(y >= 8 && y < 12) + { + buffer.put(vectors[index].z); + } + else + { + buffer.put(0); + } + } + + buffer.rewind(); + GL11.glLoadMatrix(buffer); + } + + private void getMatrix(FloatBuffer buffer, int vectorArrayIndex, Vector3f[] vectors) + { + float[] array = new float[buffer.capacity()]; + GlStateManager.getFloat(GL11.GL_MODELVIEW_MATRIX, buffer); + buffer.get(array); + + for(int y = 0; y < array.length; y++) + { + final int index = vectorArrayIndex * 4 + y % 4; + + if(y < 4) + { + vectors[index].x = array[y]; + } + else if(y >= 4 && y < 8) + { + vectors[index].y = array[y]; + } + else if(y >= 8 && y < 12) + { + vectors[index].z = array[y]; + } + } + } + + private static final class ModelShifts + { + private final Vector3f offset; + private final Vector3f angle; + private final Vector3f point; + + public ModelShifts(Vector3f offset, Vector3f angle, Vector3f point) + { + this.offset = offset; + this.angle = angle; + this.point = point; + } + + public Vector3f getOffset() + { + return this.offset; + } + + public Vector3f getAngle() + { + return this.angle; + } + + public Vector3f getPoint() + { + return this.point; + } + } + + //TODO + @Deprecated + private void printGLMatrix() + { + FloatBuffer buffer = BufferUtils.createFloatBuffer(16); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, buffer); + float[] array = new float[buffer.capacity()]; + buffer.get(array); + + System.out.println(); + + for(int x = 0; x < buffer.capacity(); x += 4) + { + System.out.println(String.format("%02.2f %02.2f %02.2f %02.2f", array[x], array[x + 1], array[x + 2], array[x + 3])); + } + } + + private static final float RADIANT = (float) (180F / Math.PI); + private static final Vector3f ORIGIN = new Vector3f(); + + private List getBaseModels(List list) + { + Set baseModels = this.getModels(list); + baseModels.removeAll(this.getAllChildren(list)); + return new ArrayList(baseModels); + } + + private Set getAllChildren(List list) + { + Set result = new HashSet(); + + for(ModelRenderer model : list) + { + if(model.childModels != null) + { + result.addAll(this.getModels(model.childModels)); + } + } + + return result; + } + + private Set getModels(List list) + { + Set result = new HashSet(); + + for(ModelRenderer model : list) + { + if(!result.contains(model)) + { + result.add(model); + } + + if(model.childModels != null) + { + result.addAll(this.getModels(model.childModels)); + } + } + + return result; + } + + @Override + public Category getCategory() + { + return Categories.ENTITIES; + } + + @Override + public String getTitle() + { + return "Playsound"; + } + + @Override + public String getTabTitle() + { + return "Playsound"; + } + + @Override + public Content getActiveContent() + { + return Contents.PLAYSOUND; + } +}