This commit is contained in:
Marcel Konrad
2018-02-17 18:57:33 +01:00
parent 9ba0331404
commit 9552b91665
38 changed files with 549 additions and 297 deletions

View File

@@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -26,7 +27,7 @@ public class GuiSlider<T> extends GuiButton
private final Container frame;
private final ButtonStorage<SliderStorage> storage;
public GuiSlider(Content container, Container frame, Object key, int x, int y, int width, int height, String name, float min, float max, float start, ISliderResponder responder)
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)
{
super(Integer.MAX_VALUE, x, y, width, height, null);
this.frame = frame;
@@ -34,35 +35,50 @@ public class GuiSlider<T> extends GuiButton
this.name = name;
this.responder = responder;
this.storage = container.getStorage(key);
if(this.storage.getObject() == null || this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max)
{
this.storage.setObject(new SliderStorage(min, max, min == max ? 0 : ((start - min) / (max - min))));
}
this.initStorage(Math.round(min), Math.round(max), Math.round(start));
this.displayString = this.getDisplayString();
}
private void setFloat(float value)
private void initStorage(double min, double max, double start)
{
this.storage.getObject().setFloat(value);
if(this.storage.getObject() == null || this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max)
{
if(this.storage.getObject() == null)
{
if(min == max)
{
this.storage.setObject(new SliderStorage(min, max, 0));
}
else
{
this.storage.setObject(new SliderStorage(min, max, (start - min) / (max - min)));
}
}
else
{
this.storage.setObject(new SliderStorage(min, max, (int) MathHelper.clamp(this.getValue(), min, max)));
}
}
}
private float getFloat()
private void setPosition(double position)
{
return this.storage.getObject().getFloat();
this.storage.getObject().setPosition(position);
}
private double getPosition()
{
return this.storage.getObject().getPosition();
}
private void setValue(int value)
{
SliderStorage slider = this.storage.getObject();
this.storage.getObject().setFloat((value - slider.getMin()) / (slider.getMax() - slider.getMin()));
this.storage.getObject().setValue(value);
}
private int getValue()
{
SliderStorage slider = this.storage.getObject();
return (int) (slider.getMin() + (slider.getMax() - slider.getMin()) * this.getFloat());
return this.storage.getObject().getValue();
}
private String getDisplayString()
@@ -118,7 +134,7 @@ public class GuiSlider<T> extends GuiButton
sliderValue = 1.0F;
}
this.setFloat(sliderValue);
this.setPosition(sliderValue);
this.displayString = this.getDisplayString();
this.responder.setValue(this.key, this.getValue());
}
@@ -139,8 +155,8 @@ public class GuiSlider<T> extends GuiButton
GlStateManager.enableBlend();
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
this.drawTexturedModalRect(this.x + (int) (this.getPosition() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
this.drawTexturedModalRect(this.x + (int) (this.getPosition() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
GlStateManager.disableBlend();
GlStateManager.popMatrix();

View File

@@ -6,34 +6,56 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class SliderStorage
{
private final float min;
private final float max;
private float value;
private final double min;
private final double max;
private double position;
public SliderStorage(float min, float max, float value)
public SliderStorage(double min, double max, double position)
{
this.min = min;
this.max = max;
this.value = value;
this.position = position;
}
public float getMin()
public SliderStorage(double min, double max, int value)
{
this.min = min;
this.max = max;
this.position = this.valueToPosition(value);
}
public double getMin()
{
return this.min;
}
public float getMax()
public double getMax()
{
return this.max;
}
public float getFloat()
public double getPosition()
{
return this.value;
return this.position;
}
public void setFloat(float value)
public void setPosition(double position)
{
this.value = value;
this.position = position;
}
public int getValue()
{
return (int) (this.min + (this.max - this.min) * this.position);
}
public void setValue(int value)
{
this.position = this.valueToPosition(value);
}
private double valueToPosition(int value)
{
return (value - this.min) / (this.max - this.min);
}
}

View File

@@ -6,13 +6,14 @@ import java.util.List;
import exopandora.worldhandler.config.ConfigButcher;
import exopandora.worldhandler.config.ConfigSettings;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.main.Main;
import exopandora.worldhandler.main.WorldHandler;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.fml.client.config.DummyConfigElement;
import net.minecraftforge.fml.client.config.DummyConfigElement.DummyCategoryElement;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.IConfigElement;
import net.minecraftforge.fml.relauncher.Side;
@@ -45,9 +46,10 @@ public class GuiConfigWorldHandler extends GuiConfig
{
List<IConfigElement> list = new ArrayList();
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.sliders"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSliders.CATEGORY)).getChildElements()));
return list;
}

View File

@@ -76,6 +76,7 @@ public class GuiWorldHandlerContainer extends Container
this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
this.tabHalf = this.tabWidth / 2D;
this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
this.content.init(this);
}
@Override

View File

@@ -12,6 +12,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IContent
{
default void init(Container container)
{
}
default void initGui(Container container, int x, int y)
{

View File

@@ -63,6 +63,12 @@ public class ElementColorMenu extends Element
{
string.setColor(storage.getIndex());
}
@Override
public String getId()
{
return logic.getId();
}
}));
container.add(new GuiButtonWorldHandler(this.ids[1], this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? ChatFormatting.ITALIC : ChatFormatting.RESET) + "I"));

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.element.impl;
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;
@@ -132,7 +133,7 @@ public class ElementPageList<T, K> extends Element
@Override
public void draw()
{
Minecraft.getMinecraft().fontRenderer.drawString((this.storage.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, 0x4F4F4F);
Minecraft.getMinecraft().fontRenderer.drawString((this.storage.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor());
}
private int getTotalPages()

View File

@@ -19,4 +19,9 @@ public interface ILogicColorMenu
{
return true;
}
default String getId()
{
return "color";
}
}

View File

@@ -185,12 +185,6 @@ public class ContentAdvancements extends Content
return I18n.format("gui.worldhandler.tab.player.advancements");
}
@Override
public String[] getHeadline()
{
return new String[] {null, I18n.format("gui.worldhandler.generic.options")};
}
@Override
public Content getActiveContent()
{

View File

@@ -91,12 +91,6 @@ public class ContentContinue extends ContentChild
this.commandField.drawTextBox();
}
@Override
public String[] getHeadline()
{
return new String[]{I18n.format("gui.worldhandler.continue.question")};
}
@Override
public void keyTyped(Container container, char typedChar, int keyCode)
{

View File

@@ -1,6 +1,7 @@
package exopandora.worldhandler.gui.content.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -10,6 +11,7 @@ import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderCustomItem;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.gui.button.GuiButtonList;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiSlider;
@@ -49,24 +51,50 @@ public class ContentCustomItem extends Content
private GuiButtonList colorButton;
private final List<EnumAttributes> attributes = Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.PLAYER).stream()).collect(Collectors.toList());
@Override
public ICommandBuilder getCommandBuilder()
{
return this.builderCutomItem;
}
@Override
public void init(Container container)
{
for(EnumAttributes attribute : this.builderCutomItem.getAttributes())
{
double ammount = this.builderCutomItem.getAttributeAmmount(attribute);
if(ammount > ConfigSliders.getMaxItemAttributes())
{
this.builderCutomItem.setAttribute(attribute, ConfigSliders.getMaxItemAttributes());
}
}
for(Enchantment enchantment : this.builderCutomItem.getEnchantments())
{
short level = this.builderCutomItem.getEnchantmentLevel(enchantment);
if(level > ConfigSliders.getMaxItemEnchantment())
{
this.builderCutomItem.setEnchantment(enchantment, (short) ConfigSliders.getMaxItemEnchantment());
}
}
}
@Override
public void initGui(Container container, int x, int y)
{
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.item_id"));
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.item_id"));
this.itemField.setValidator(Predicates.<String>notNull());
this.itemField.setText(this.item);
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.lore_1"));
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_1"));
this.itemLore1Field.setValidator(Predicates.<String>notNull());
this.itemLore1Field.setText(this.builderCutomItem.getLore1());
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.lore_2"));
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_2"));
this.itemLore2Field.setValidator(Predicates.<String>notNull());
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
@@ -74,7 +102,7 @@ public class ContentCustomItem extends Content
{
if(this.startPage == 1)
{
ElementColorMenu colors = new ElementColorMenu(this, x, y, "gui.worldhandler.items.give_custom_item.start.custom_name", this.builderCutomItem.getName(), new int[] {10, 11, 12, 13, 14, 15});
ElementColorMenu colors = new ElementColorMenu(this, x, y, "gui.worldhandler.items.custom_item.start.custom_name", this.builderCutomItem.getName(), new int[] {10, 11, 12, 13, 14, 15});
container.add(colors);
}
}
@@ -103,7 +131,7 @@ public class ContentCustomItem extends Content
@Override
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, ResourceLocation value, Container container)
{
container.add(new GuiSlider<ResourceLocation>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, 0, 100, 0, new SimpleResponder<ResourceLocation>(response ->
container.add(new GuiSlider<ResourceLocation>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, 0, ConfigSliders.getMaxItemEnchantment(), 0, new SimpleResponder<ResourceLocation>(response ->
{
builderCutomItem.setEnchantment(Enchantment.REGISTRY.getObject(value), response.shortValue());
})));
@@ -131,7 +159,7 @@ public class ContentCustomItem extends Content
}
else if(this.selectedPage.equals("attributes"))
{
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.PLAYER).stream()).collect(Collectors.toList()), null, 114, 20, 3, this, new int[] {13, 14, 15}, new ILogicPageList<EnumAttributes, Object>()
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, this.attributes, null, 114, 20, 3, this, new int[] {13, 14, 15}, new ILogicPageList<EnumAttributes, Object>()
{
@Override
public String translate(EnumAttributes key)
@@ -154,7 +182,7 @@ public class ContentCustomItem extends Content
@Override
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, EnumAttributes value, Container container)
{
container.add(new GuiSlider<EnumAttributes>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, value.getMin(), value.getMax(), value.getStart(), new AttributeResponder(response ->
container.add(new GuiSlider<EnumAttributes>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, -ConfigSliders.getMaxItemAttributes(), ConfigSliders.getMaxItemAttributes(), 0, new AttributeResponder(response ->
{
builderCutomItem.setAttribute(value, response);
})));
@@ -193,9 +221,9 @@ public class ContentCustomItem extends Content
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(button3 = new GuiButtonWorldHandler(3, x, y, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start")));
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.enchantment")));
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.attributes")));
container.add(button3 = new GuiButtonWorldHandler(3, x, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start")));
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.enchantment")));
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.attributes")));
if(this.selectedPage.equals("start"))
{
@@ -218,7 +246,7 @@ public class ContentCustomItem extends Content
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
{
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.give_custom_item")));
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.custom_item.custom_item")));
}
else
{
@@ -321,28 +349,13 @@ public class ContentCustomItem extends Content
@Override
public String getTitle()
{
return I18n.format("gui.worldhandler.title.items.give_custom_item");
return I18n.format("gui.worldhandler.title.items.custom_item");
}
@Override
public String getTabTitle()
{
return I18n.format("gui.worldhandler.tab.items.give_custom_item");
}
@Override
public String[] getHeadline()
{
String[] headline = new String[2];
headline[0] = I18n.format("gui.worldhandler.generic.browse");
if(this.selectedPage.equals("start"))
{
headline[1] = I18n.format("gui.worldhandler.generic.options");
}
return headline;
return I18n.format("gui.worldhandler.tab.items.custom_item");
}
@Override

View File

@@ -394,12 +394,6 @@ public class ContentEditBlocks extends Content
return I18n.format("gui.worldhandler.tab.blocks.edit_blocks");
}
@Override
public String[] getHeadline()
{
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
}
@Override
public Content getActiveContent()
{

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl;
import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderExperience;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.gui.button.EnumTooltip;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiSlider;
@@ -31,19 +32,28 @@ public class ContentExperience extends Content
return this.builderExperience;
}
@Override
public void init(Container container)
{
if(this.builderExperience.getLevel() > ConfigSliders.getMaxExperience())
{
this.builderExperience.setLevel((int) ConfigSliders.getMaxExperience());
}
}
@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 GuiSlider<String>(this, container, "experience", x + 116 / 2, y, 114, 20, I18n.format("gui.worldhandler.title.player.experience"), 0, 100, 0, new SimpleResponder<String>(value ->
container.add(new GuiSlider<String>(this, container, "experience", x + 116 / 2, y, 114, 20, I18n.format("gui.worldhandler.title.player.experience"), 0, ConfigSliders.getMaxExperience(), 0, new SimpleResponder<String>(value ->
{
this.builderExperience.setLevel(value);
})));
container.add(addButton = new GuiButtonWorldHandler(3, x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add")));
container.add(removeButton = new GuiButtonWorldHandler(4, x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove")));
container.add(this.addButton = new GuiButtonWorldHandler(3, x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add")));
container.add(this.removeButton = new GuiButtonWorldHandler(4, x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove")));
container.add(new GuiButtonWorldHandler(5, x + 116 / 2, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), EnumTooltip.TOP_RIGHT));
boolean enabled = this.builderExperience.getLevel() > 0;

View File

@@ -184,12 +184,6 @@ public class ContentGamerules extends Content
return I18n.format("gui.worldhandler.tab.world.gamerules");
}
@Override
public String[] getHeadline()
{
return new String[] {null, I18n.format("gui.worldhandler.generic.options")};
}
@Override
public Content getActiveContent()
{

View File

@@ -306,12 +306,6 @@ public class ContentMultiplayer extends Content
return I18n.format("gui.worldhandler.tab.multiplayer");
}
@Override
public String[] getHeadline()
{
return new String[]{I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
}
@Override
public Content getActiveContent()
{

View File

@@ -38,15 +38,18 @@ public class ContentNoteEditor extends Content
{
private final BuilderNoteEditor builderNoteEditor = new BuilderNoteEditor();
private boolean isActive;
@Override
public ICommandBuilder getCommandBuilder()
{
return this.isActive() ? this.builderNoteEditor : null;
return this.isActive ? this.builderNoteEditor : null;
}
@Override
public void initGui(Container container, int x, int y)
public void init(Container container)
{
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK);
this.builderNoteEditor.setPosition(BlockHelper.getFocusedBlockPos());
}
@@ -56,9 +59,9 @@ public class ContentNoteEditor extends Content
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")));
if(this.isActive())
if(this.isActive)
{
BlockPos pos = BlockHelper.getFocusedBlockPos();
BlockPos pos = this.builderNoteEditor.getBlockPos();
SoundEvent sound = this.getSoundEvent(pos.down());
container.add(new GuiButtonKeyboard(4, x - 3 + 15, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), Orientation.NORMAL, 0.53F, container, this, pos, sound));
@@ -95,15 +98,6 @@ public class ContentNoteEditor extends Content
}
}
@Override
public void updateScreen(Container container)
{
if(!this.isActive())
{
container.initGui();
}
}
@Override
public void actionPerformed(Container container, GuiButton button)
{
@@ -192,7 +186,7 @@ public class ContentNoteEditor extends Content
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(this.isActive())
if(this.isActive)
{
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("worldhandler:textures/misc/note.png"));
@@ -273,11 +267,6 @@ public class ContentNoteEditor extends Content
return SoundEvents.BLOCK_NOTE_HARP;
}
private boolean isActive()
{
return BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK);
}
@Override
public Category getCategory()
{

View File

@@ -218,12 +218,6 @@ public class ContentPlayer extends Content
return I18n.format("gui.worldhandler.tab.player.player");
}
@Override
public String[] getHeadline()
{
return new String[]{I18n.format("gui.worldhandler.generic.browse")};
}
@Override
public Content getActiveContent()
{

View File

@@ -6,6 +6,7 @@ import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
import exopandora.worldhandler.builder.impl.BuilderPotionEffect;
import exopandora.worldhandler.builder.impl.BuilderPotionItem;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.gui.button.EnumTooltip;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiSlider;
@@ -37,6 +38,25 @@ public class ContentPotions extends ContentChild
return new BuilderMultiCommand(this.builderPotion, this.builderPotionItem);
}
@Override
public void init(Container container)
{
if(this.builderPotion.getAmplifier() > ConfigSliders.getMaxPotionAmplifier())
{
this.builderPotion.setAmplifier((byte) ConfigSliders.getMaxPotionAmplifier());
}
for(Potion potion : this.builderPotionItem.getPotions())
{
byte amplifier = this.builderPotionItem.getAmplifier(potion);
if(amplifier > ConfigSliders.getMaxPotionAmplifier())
{
this.builderPotionItem.setAmplifier(potion, (byte) ConfigSliders.getMaxPotionAmplifier());
}
}
}
@Override
public void initGui(Container container, int x, int y)
{
@@ -113,7 +133,7 @@ public class ContentPotions extends ContentChild
container.add(new GuiButtonWorldHandler(8, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potions.effect.ambient", (this.builderPotionItem.getAmbient(potion) ? I18n.format("gui.worldhandler.generic.on") : I18n.format("gui.worldhandler.generic.off")))));
container.add(new GuiButtonWorldHandler(9, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potions.effect.particles", (this.builderPotion.getHideParticles() ? I18n.format("gui.worldhandler.generic.off") : I18n.format("gui.worldhandler.generic.on")))));
container.add(new GuiSlider<Potion>(this, container, "potions_amplifier" + potion, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect.amplifier"), 0, 100, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "potions_amplifier" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect.amplifier"), 0, ConfigSliders.getMaxPotionAmplifier(), 0, new SimpleResponder<Potion>(value ->
{
this.builderPotion.setAmplifier(value.byteValue());
this.builderPotionItem.setAmplifier(potion, value.byteValue());
@@ -123,17 +143,17 @@ public class ContentPotions extends ContentChild
{
Potion potion = this.builderPotion.getEffectAsPotion();
container.add(new GuiSlider<Potion>(this, container, "seconds" + potion, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potion.time.seconds"), 0, 59, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "seconds" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format("gui.worldhandler.potion.time.seconds"), 0, 59, 0, new SimpleResponder<Potion>(value ->
{
this.builderPotion.setSeconds(value.intValue());
this.builderPotionItem.setSeconds(potion, value.intValue());
})));
container.add(new GuiSlider<Potion>(this, container, "minutes" + potion, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 59, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "minutes" + potion.getRegistryName(), x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 59, 0, new SimpleResponder<Potion>(value ->
{
this.builderPotion.setMinutes(value.intValue());
this.builderPotionItem.setMinutes(potion, value.intValue());
})));
container.add(new GuiSlider<Potion>(this, container, "hours" + potion, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potion.time.hours"), 0, 99, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "hours" + potion.getRegistryName(), x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potion.time.hours"), 0, 99, 0, new SimpleResponder<Potion>(value ->
{
this.builderPotion.setHours(value.intValue());
this.builderPotionItem.setHours(potion, value.intValue());

View File

@@ -6,6 +6,7 @@ import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers;
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumPoints;
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumTag;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.gui.button.EnumTooltip;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiSlider;
@@ -42,6 +43,15 @@ public class ContentScoreboardPlayers extends ContentScoreboard
return this.builderPlayers;
}
@Override
public void init(Container container)
{
if(this.builderPlayers.getPoints() > ConfigSliders.getMaxPlayerPoints())
{
this.builderPlayers.setPoints((int) ConfigSliders.getMaxPlayerPoints());
}
}
@Override
public void initGui(Container container, int x, int y)
{
@@ -78,7 +88,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
if(this.selectedPlayer.equals("add|set|remove"))
{
container.add(new GuiSlider<String>(this, container, "points", x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points"), 0, 100, 0, new SimpleResponder<String>(value ->
container.add(new GuiSlider<String>(this, container, "points", x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points"), 0, ConfigSliders.getMaxPlayerPoints(), 0, new SimpleResponder<String>(value ->
{
this.builderPlayers.setPoints(value);
})));

View File

@@ -45,19 +45,26 @@ public class ContentSignEditor extends Content
private final BuilderSignEditor builderSignEditor = new BuilderSignEditor();
private boolean isActive;
@Override
public ICommandBuilder getCommandBuilder()
{
return this.isActive() ? this.builderSignEditor : null;
return this.isActive ? this.builderSignEditor : null;
}
@Override
public void init(Container container)
{
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
this.builderSignEditor.setPosition(BlockHelper.getFocusedBlockPos());
}
@Override
public void initGui(Container container, int x, int y)
{
if(this.isActive())
{
this.builderSignEditor.setPosition(BlockHelper.getFocusedBlockPos());
if(this.isActive)
{
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.commmand"));
this.commandField.setValidator(Predicates.notNull());
this.commandField.setText(this.builderSignEditor.getCommand(this.selectedLine));
@@ -76,6 +83,12 @@ public class ContentSignEditor extends Content
{
return editColor;
}
@Override
public String getId()
{
return "color" + selectedLine;
}
});
container.add(colors);
@@ -93,7 +106,7 @@ public class ContentSignEditor extends Content
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")));
if(this.isActive())
if(this.isActive)
{
container.add(button3 = new GuiButtonWorldHandler(3, x, y, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_1")));
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_2")));
@@ -117,15 +130,6 @@ public class ContentSignEditor extends Content
}
}
@Override
public void updateScreen(Container container)
{
if(!this.isActive())
{
container.initGui();
}
}
@Override
public void actionPerformed(Container container, GuiButton button)
{
@@ -162,7 +166,7 @@ public class ContentSignEditor extends Content
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(this.isActive())
if(this.isActive)
{
if(!this.editColor)
{
@@ -190,15 +194,10 @@ public class ContentSignEditor extends Content
}
}
private boolean isActive()
{
return BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
}
@Override
public void keyTyped(Container container, char charTyped, int keyCode)
{
if(this.isActive())
if(this.isActive)
{
if(this.commandField.textboxKeyTyped(charTyped, keyCode))
{
@@ -211,7 +210,7 @@ public class ContentSignEditor extends Content
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
{
if(this.isActive())
if(this.isActive)
{
this.commandField.mouseClicked(mouseX, mouseY, mouseButton);
}
@@ -235,17 +234,6 @@ public class ContentSignEditor extends Content
return I18n.format("gui.worldhandler.tab.blocks.sign_editor");
}
@Override
public String[] getHeadline()
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
{
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
}
return null;
}
@Override
public Content getActiveContent()
{

View File

@@ -13,6 +13,7 @@ import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderSummon;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.gui.button.GuiButtonItem;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiSlider;
@@ -57,12 +58,45 @@ public class ContentSummon extends Content
private final BuilderSummon builderSummon = new BuilderSummon();
private final List<EnumAttributes> attributes = Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.MOB).stream()).collect(Collectors.toList());
@Override
public ICommandBuilder getCommandBuilder()
{
return this.builderSummon;
}
@Override
public void init(Container container)
{
for(EnumAttributes attribute : this.builderSummon.getAttributes())
{
double ammount = this.builderSummon.getAttributeAmmount(attribute);
if(ammount > ConfigSliders.getMaxSummonAttributes())
{
this.builderSummon.setAttribute(attribute, ConfigSliders.getMaxSummonAttributes());
}
}
for(Potion potion : this.builderSummon.getPotions())
{
byte amplifier = this.builderSummon.getAmplifier(potion);
if(amplifier > ConfigSliders.getMaxSummonPotionAmplifier())
{
this.builderSummon.setAmplifier(potion, (byte) ConfigSliders.getMaxSummonPotionAmplifier());
}
int minutes = this.builderSummon.getMinutes(potion);
if(minutes > ConfigSliders.getMaxSummonPotionMinutes())
{
this.builderSummon.setMinutes(potion, (int) ConfigSliders.getMaxSummonPotionMinutes());
}
}
}
@Override
public void initGui(Container container, int x, int y)
{
@@ -82,7 +116,7 @@ public class ContentSummon extends Content
if(this.page.equals("attributes"))
{
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.MOB).stream()).collect(Collectors.toList()), null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<EnumAttributes, Object>()
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, this.attributes, null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<EnumAttributes, Object>()
{
@Override
public String translate(EnumAttributes key)
@@ -105,7 +139,7 @@ public class ContentSummon extends Content
@Override
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, EnumAttributes value, Container container)
{
container.add(new GuiSlider<EnumAttributes>(Contents.SUMMON, container, value, x, y, width, height, display, value.getMin(), value.getMax(), value.getStart(), new AttributeResponder(response ->
container.add(new GuiSlider<EnumAttributes>(Contents.SUMMON, container, value, x, y, width, height, display, -ConfigSliders.getMaxSummonAttributes(), ConfigSliders.getMaxSummonAttributes(), 0, new AttributeResponder(response ->
{
builderSummon.setAttribute(value, response);
})));
@@ -208,11 +242,11 @@ public class ContentSummon extends Content
if(count == this.potionPage)
{
container.add(new GuiSlider<Potion>(this, container, "amplifier" + potion, x + 118, y, 114, 20, I18n.format(potion.getName()), 0, 100, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "amplifier" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format(potion.getName()), 0, ConfigSliders.getMaxSummonPotionAmplifier(), 0, new SimpleResponder<Potion>(value ->
{
this.builderSummon.setAmplifier(potion, value.byteValue());
})));
container.add(new GuiSlider<Potion>(this, container, "duration" + potion, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 100, 0, new SimpleResponder<Potion>(value ->
container.add(new GuiSlider<Potion>(this, container, "duration" + potion.getRegistryName(), x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, ConfigSliders.getMaxSummonPotionMinutes(), 0, new SimpleResponder<Potion>(value ->
{
this.builderSummon.setMinutes(potion, value);
})));
@@ -627,8 +661,6 @@ public class ContentSummon extends Content
{
String[] headline = new String[2];
headline[0] = I18n.format("gui.worldhandler.generic.browse");
if(this.page.equals("potionEffects"))
{
headline[1] = (this.potionPage + 1) + "/" + (Potion.REGISTRY.getKeys().size() - 2);
@@ -637,10 +669,6 @@ public class ContentSummon extends Content
{
headline[1] = (this.equipmentPage + 1) + "/2";
}
else if(this.page.equals("main"))
{
headline[1] = I18n.format("gui.worldhandler.generic.options");
}
return headline;
}

View File

@@ -219,12 +219,6 @@ public class ContentWorldInfo extends Content
return I18n.format("gui.worldhandler.tab.world.world");
}
@Override
public String[] getHeadline()
{
return new String[] {I18n.format("gui.worldhandler.generic.browse")};
}
@Override
public Content getActiveContent()
{

View File

@@ -25,10 +25,4 @@ public abstract class ContentScoreboard extends Content
{
return I18n.format("gui.worldhandler.title.scoreboard");
}
@Override
public String[] getHeadline()
{
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
}
}