Refactoring
This commit is contained in:
@@ -1,164 +1,164 @@
|
||||
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.persistence.ButtonValues;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ElementPageList<T, K> extends Element
|
||||
{
|
||||
private final List<T> list;
|
||||
private final ILogicPageList<T, K> logic;
|
||||
private final int length;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int[] ids;
|
||||
private final ButtonValues<Integer> values;
|
||||
|
||||
public ElementPageList(int x, int y, List<T> list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList<T, K> logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.length = length;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.logic = logic;
|
||||
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.values.getObject() == null)
|
||||
{
|
||||
this.values.setObject(0);
|
||||
this.values.setIndex(Math.max(0, this.list.indexOf(this.logic.convert(initial))));
|
||||
|
||||
if(initial == null)
|
||||
{
|
||||
this.logic.onClick(this.list.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
boolean extended = (this.list.size() == this.length + 1);
|
||||
|
||||
if(!extended)
|
||||
{
|
||||
int buttonWidth = (this.width - 4) / 2;
|
||||
|
||||
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.values.getObject() > 0;
|
||||
right.enabled = this.values.getObject() < this.getTotalPages() - 1;
|
||||
|
||||
container.add(left);
|
||||
container.add(right);
|
||||
}
|
||||
|
||||
int length = (extended ? this.length + 1 : this.length);
|
||||
|
||||
for(int x = 0; x < 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.values.getIndex() != index, entry, container);
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.ids[0])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value - Math.min(10, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value - 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value + Math.min(10, this.getTotalPages() - 1 - value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value + 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[2])
|
||||
{
|
||||
for(int x = 0; x < this.list.size(); x++)
|
||||
{
|
||||
T entry = this.list.get(x);
|
||||
|
||||
if(TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer).equals(button.displayString))
|
||||
{
|
||||
this.values.setIndex(x);
|
||||
this.logic.onClick(entry);
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawString((this.values.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
|
||||
private int getTotalPages()
|
||||
{
|
||||
return (int) Math.ceil((float) this.list.size() / this.length);
|
||||
}
|
||||
}
|
||||
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.persistence.ButtonValues;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ElementPageList<T, K> extends Element
|
||||
{
|
||||
private final List<T> list;
|
||||
private final ILogicPageList<T, K> logic;
|
||||
private final int length;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int[] ids;
|
||||
private final ButtonValues<Integer> values;
|
||||
|
||||
public ElementPageList(int x, int y, List<T> list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList<T, K> logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.length = length;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.logic = logic;
|
||||
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.values.getObject() == null)
|
||||
{
|
||||
this.values.setObject(0);
|
||||
this.values.setIndex(Math.max(0, this.list.indexOf(this.logic.getObject(initial))));
|
||||
|
||||
if(initial == null)
|
||||
{
|
||||
this.logic.onClick(this.list.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
boolean extended = (this.list.size() == this.length + 1);
|
||||
|
||||
if(!extended)
|
||||
{
|
||||
int buttonWidth = (this.width - 4) / 2;
|
||||
|
||||
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.values.getObject() > 0;
|
||||
right.enabled = this.values.getObject() < this.getTotalPages() - 1;
|
||||
|
||||
container.add(left);
|
||||
container.add(right);
|
||||
}
|
||||
|
||||
int length = (extended ? this.length + 1 : this.length);
|
||||
|
||||
for(int x = 0; x < 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.values.getIndex() != index, entry, container);
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.ids[0])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value - Math.min(10, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value - 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value + Math.min(10, this.getTotalPages() - 1 - value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value + 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[2])
|
||||
{
|
||||
for(int x = 0; x < this.list.size(); x++)
|
||||
{
|
||||
T entry = this.list.get(x);
|
||||
|
||||
if(TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer).equals(button.displayString))
|
||||
{
|
||||
this.values.setIndex(x);
|
||||
this.logic.onClick(entry);
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawString((this.values.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
|
||||
private int getTotalPages()
|
||||
{
|
||||
return (int) Math.ceil((float) this.list.size() / this.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogicPageList<T, K> extends ILogic
|
||||
{
|
||||
String translate(T key);
|
||||
String getRegistryName(T key);
|
||||
|
||||
void onClick(T clicked);
|
||||
void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, T value, Container container);
|
||||
|
||||
T convert(K object);
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogicPageList<T, K> extends ILogic
|
||||
{
|
||||
String translate(T key);
|
||||
String getRegistryName(T key);
|
||||
|
||||
void onClick(T clicked);
|
||||
void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, T value, Container container);
|
||||
|
||||
T getObject(K object);
|
||||
}
|
||||
@@ -1,199 +1,199 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumMode;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
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.persistence.ButtonValues;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.AdvancementHelper;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentAdvancements extends Content
|
||||
{
|
||||
private final AdvancementHelper helper = new AdvancementHelper();
|
||||
private final BuilderAdvancement builderAdvancement = new BuilderAdvancement(EnumMode.values()[0]);
|
||||
|
||||
private GuiButtonList modeButton;
|
||||
|
||||
private final List<Advancement> advancements = Lists.newArrayList(new AdvancementManager(null).getAdvancements()).parallelStream().filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderAdvancement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
ElementPageList<Advancement, String> list = new ElementPageList<Advancement, String>(x, y, this.advancements, null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<Advancement, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(Advancement key)
|
||||
{
|
||||
return I18n.format(key.getDisplay().getTitle().getUnformattedText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Advancement clicked)
|
||||
{
|
||||
builderAdvancement.setAdvancement(clicked.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(Advancement key)
|
||||
{
|
||||
return key.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, Advancement value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button;
|
||||
container.add(button = new GuiButtonWorldHandler(id, x, y, width, height, display, value.getId().toString(), EnumTooltip.TOP_RIGHT));
|
||||
button.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement convert(String object)
|
||||
{
|
||||
return helper.ADVANCEMENT_MANAGER.getAdvancement(Type.parseResourceLocation(object));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "advancements";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(list);
|
||||
}
|
||||
|
||||
@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(this.modeButton = new GuiButtonList(2, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic<EnumMode>()
|
||||
{
|
||||
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, ButtonValues<EnumMode> values)
|
||||
{
|
||||
builderAdvancement.setMode(values.getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
return this.values.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMode getObject(int index)
|
||||
{
|
||||
return this.values[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonValues<EnumMode> values)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.advancements." + values.getObject().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "mode";
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(3, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.advancements.grant")));
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.advancements.revoke")));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.actions.reset")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.modeButton.actionPerformed(container, button);
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.GRANT));
|
||||
break;
|
||||
case 4:
|
||||
WorldHandler.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.REVOKE));
|
||||
break;
|
||||
case 5:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderAdvancement.getBuilder(EnumActionType.REVOKE, EnumMode.EVERYTHING)).withParent(Contents.ADVANCEMENTS)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.ADVANCEMENTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderAdvancement.setPlayer(username);
|
||||
}
|
||||
}
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumMode;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
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.persistence.ButtonValues;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.AdvancementHelper;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentAdvancements extends Content
|
||||
{
|
||||
private final AdvancementHelper helper = new AdvancementHelper();
|
||||
private final BuilderAdvancement builderAdvancement = new BuilderAdvancement(EnumMode.values()[0]);
|
||||
|
||||
private GuiButtonList modeButton;
|
||||
|
||||
private final List<Advancement> advancements = Lists.newArrayList(new AdvancementManager(null).getAdvancements()).parallelStream().filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderAdvancement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
ElementPageList<Advancement, String> list = new ElementPageList<Advancement, String>(x, y, this.advancements, null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<Advancement, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(Advancement key)
|
||||
{
|
||||
return I18n.format(key.getDisplay().getTitle().getUnformattedText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Advancement clicked)
|
||||
{
|
||||
builderAdvancement.setAdvancement(clicked.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(Advancement key)
|
||||
{
|
||||
return key.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, Advancement value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button;
|
||||
container.add(button = new GuiButtonWorldHandler(id, x, y, width, height, display, value.getId().toString(), EnumTooltip.TOP_RIGHT));
|
||||
button.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement getObject(String object)
|
||||
{
|
||||
return helper.ADVANCEMENT_MANAGER.getAdvancement(Type.parseResourceLocation(object));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "advancements";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(list);
|
||||
}
|
||||
|
||||
@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(this.modeButton = new GuiButtonList(2, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic<EnumMode>()
|
||||
{
|
||||
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, ButtonValues<EnumMode> values)
|
||||
{
|
||||
builderAdvancement.setMode(values.getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
return this.values.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMode getObject(int index)
|
||||
{
|
||||
return this.values[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonValues<EnumMode> values)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.advancements." + values.getObject().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "mode";
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(3, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.advancements.grant")));
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.advancements.revoke")));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.actions.reset")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.modeButton.actionPerformed(container, button);
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.GRANT));
|
||||
break;
|
||||
case 4:
|
||||
WorldHandler.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.REVOKE));
|
||||
break;
|
||||
case 5:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderAdvancement.getBuilder(EnumActionType.REVOKE, EnumMode.EVERYTHING)).withParent(Contents.ADVANCEMENTS)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.player.advancements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.ADVANCEMENTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderAdvancement.setPlayer(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,372 +1,372 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.responder.AttributeResponder;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementColorMenu;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentCustomItem extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip itemField;
|
||||
private GuiTextFieldTooltip itemLore1Field;
|
||||
private GuiTextFieldTooltip itemLore2Field;
|
||||
|
||||
private final BuilderCustomItem builderCutomItem = new BuilderCustomItem();
|
||||
|
||||
private int startPage;
|
||||
|
||||
private String selectedPage = "start";
|
||||
private String item;
|
||||
|
||||
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.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.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.custom_item.start.lore_2"));
|
||||
this.itemLore2Field.setValidator(Predicates.<String>notNull());
|
||||
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
|
||||
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if(this.selectedPage.equals("enchant"))
|
||||
{
|
||||
ElementPageList<ResourceLocation, String> enchantments = new ElementPageList<ResourceLocation, String>(x + 118, y, new ArrayList<ResourceLocation>(Enchantment.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {10, 11, 12}, new ILogicPageList<ResourceLocation, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@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, ConfigSliders.getMaxItemEnchantment(), 0, new SimpleResponder<ResourceLocation>(response ->
|
||||
{
|
||||
builderCutomItem.setEnchantment(Enchantment.REGISTRY.getObject(value), response.shortValue());
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation convert(String object)
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return new ResourceLocation(object.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "enchantments";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(enchantments);
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
return I18n.format("attribute.name." + key.getAttribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes clicked)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(EnumAttributes key)
|
||||
{
|
||||
return key.getAttribute();
|
||||
}
|
||||
|
||||
@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, -ConfigSliders.getMaxItemAttributes(), ConfigSliders.getMaxItemAttributes(), 0, new AttributeResponder(response ->
|
||||
{
|
||||
builderCutomItem.setAttribute(value, response);
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAttributes convert(Object object)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "attributes";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonWorldHandler button10;
|
||||
GuiButtonWorldHandler button11;
|
||||
|
||||
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.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"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
|
||||
container.add(button7 = new GuiButtonWorldHandler(6, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button8 = new GuiButtonWorldHandler(7, x + 118 + 60, y + 72, 55, 20, ">"));
|
||||
|
||||
button7.enabled = this.startPage != 0;
|
||||
button8.enabled = this.startPage != 1;
|
||||
}
|
||||
else if(this.selectedPage.equals("enchant"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
}
|
||||
|
||||
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.custom_item.custom_item")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
}
|
||||
|
||||
button6.enabled = ResourceHelper.isRegisteredItem(this.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
this.selectedPage = "start";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedPage = "enchant";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedPage = "attributes";
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
this.startPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
this.startPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderCutomItem, this.builderCutomItem.getName().isSpecial());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 0)
|
||||
{
|
||||
this.itemField.drawTextBox();
|
||||
this.itemLore1Field.drawTextBox();
|
||||
this.itemLore2Field.drawTextBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
if(this.itemField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.item = this.itemField.getText();
|
||||
this.builderCutomItem.setItem(this.item);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.itemLore1Field.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.builderCutomItem.setLore1(this.itemLore1Field.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.itemLore2Field.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.builderCutomItem.setLore2(this.itemLore2Field.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 0)
|
||||
{
|
||||
this.itemField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.itemLore1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.itemLore2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.CUSTOM_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderCutomItem.setPlayer(username);
|
||||
}
|
||||
}
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.responder.AttributeResponder;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementColorMenu;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentCustomItem extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip itemField;
|
||||
private GuiTextFieldTooltip itemLore1Field;
|
||||
private GuiTextFieldTooltip itemLore2Field;
|
||||
|
||||
private final BuilderCustomItem builderCutomItem = new BuilderCustomItem();
|
||||
|
||||
private int startPage;
|
||||
|
||||
private String selectedPage = "start";
|
||||
private String item;
|
||||
|
||||
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.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.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.custom_item.start.lore_2"));
|
||||
this.itemLore2Field.setValidator(Predicates.<String>notNull());
|
||||
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
|
||||
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if(this.selectedPage.equals("enchant"))
|
||||
{
|
||||
ElementPageList<ResourceLocation, String> enchantments = new ElementPageList<ResourceLocation, String>(x + 118, y, new ArrayList<ResourceLocation>(Enchantment.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {10, 11, 12}, new ILogicPageList<ResourceLocation, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@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, ConfigSliders.getMaxItemEnchantment(), 0, new SimpleResponder<ResourceLocation>(response ->
|
||||
{
|
||||
builderCutomItem.setEnchantment(Enchantment.REGISTRY.getObject(value), response.shortValue());
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(String object)
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return new ResourceLocation(object.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "enchantments";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(enchantments);
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
return I18n.format("attribute.name." + key.getAttribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes clicked)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(EnumAttributes key)
|
||||
{
|
||||
return key.getAttribute();
|
||||
}
|
||||
|
||||
@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, -ConfigSliders.getMaxItemAttributes(), ConfigSliders.getMaxItemAttributes(), 0, new AttributeResponder(response ->
|
||||
{
|
||||
builderCutomItem.setAttribute(value, response);
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAttributes getObject(Object object)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "attributes";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonWorldHandler button10;
|
||||
GuiButtonWorldHandler button11;
|
||||
|
||||
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.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"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
|
||||
container.add(button7 = new GuiButtonWorldHandler(6, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button8 = new GuiButtonWorldHandler(7, x + 118 + 60, y + 72, 55, 20, ">"));
|
||||
|
||||
button7.enabled = this.startPage != 0;
|
||||
button8.enabled = this.startPage != 1;
|
||||
}
|
||||
else if(this.selectedPage.equals("enchant"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
}
|
||||
|
||||
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.custom_item.custom_item")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
}
|
||||
|
||||
button6.enabled = ResourceHelper.isRegisteredItem(this.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
this.selectedPage = "start";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedPage = "enchant";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedPage = "attributes";
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
this.startPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
this.startPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderCutomItem, this.builderCutomItem.getName().isSpecial());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 0)
|
||||
{
|
||||
this.itemField.drawTextBox();
|
||||
this.itemLore1Field.drawTextBox();
|
||||
this.itemLore2Field.drawTextBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
if(this.itemField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.item = this.itemField.getText();
|
||||
this.builderCutomItem.setItem(this.item);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.itemLore1Field.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.builderCutomItem.setLore1(this.itemLore1Field.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.itemLore2Field.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.builderCutomItem.setLore2(this.itemLore2Field.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 0)
|
||||
{
|
||||
this.itemField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.itemLore1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.itemLore2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.items.custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.CUSTOM_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderCutomItem.setPlayer(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,143 +1,143 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderEnchantment;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentEnchantment extends Content
|
||||
{
|
||||
private final BuilderEnchantment builderEnchantment = new BuilderEnchantment();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderEnchantment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
ElementPageList<ResourceLocation, String> enchantments = new ElementPageList<ResourceLocation, String>(x, y, new ArrayList<ResourceLocation>(Enchantment.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {3, 4, 5}, new ILogicPageList<ResourceLocation, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
builderEnchantment.setEnchantment(clicked);
|
||||
builderEnchantment.setLevel(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, ResourceLocation value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registry, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation convert(String object)
|
||||
{
|
||||
return Type.parseResourceLocation(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "enchantments";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(enchantments);
|
||||
}
|
||||
|
||||
@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, "enchantment", x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.enchantment.level"), 1, Enchantment.REGISTRY.getObject(this.builderEnchantment.getEnchantment()).getMaxLevel(), 1, new SimpleResponder<String>(value ->
|
||||
{
|
||||
this.builderEnchantment.setLevel(value.intValue());
|
||||
})));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.enchantment.enchant")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderEnchantment);
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.ENCHANTMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderEnchantment.setPlayer(username);
|
||||
}
|
||||
}
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderEnchantment;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentEnchantment extends Content
|
||||
{
|
||||
private final BuilderEnchantment builderEnchantment = new BuilderEnchantment();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderEnchantment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
ElementPageList<ResourceLocation, String> enchantments = new ElementPageList<ResourceLocation, String>(x, y, new ArrayList<ResourceLocation>(Enchantment.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {3, 4, 5}, new ILogicPageList<ResourceLocation, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
builderEnchantment.setEnchantment(clicked);
|
||||
builderEnchantment.setLevel(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, ResourceLocation value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registry, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(String object)
|
||||
{
|
||||
return Type.parseResourceLocation(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "enchantments";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(enchantments);
|
||||
}
|
||||
|
||||
@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, "enchantment", x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.enchantment.level"), 1, Enchantment.REGISTRY.getObject(this.builderEnchantment.getEnchantment()).getMaxLevel(), 1, new SimpleResponder<String>(value ->
|
||||
{
|
||||
this.builderEnchantment.setLevel(value.intValue());
|
||||
})));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.enchantment.enchant")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderEnchantment);
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.items.enchantment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.ENCHANTMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderEnchantment.setPlayer(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,199 +1,199 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamerule;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.world.GameRules.ValueType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentGamerules extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip valueField;
|
||||
|
||||
private boolean booleanValue;
|
||||
private String value;
|
||||
|
||||
private final BuilderGamerule builderGamerule = new BuilderGamerule();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderGamerule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.value"));
|
||||
this.valueField.setValidator(Predicates.notNull());
|
||||
this.valueField.setText(this.value);
|
||||
this.valueField.setCursorPositionEnd();
|
||||
|
||||
ElementPageList<String, String> rules = new ElementPageList<String, String>(x, y, Arrays.asList(Minecraft.getMinecraft().world.getGameRules().getRules()), null, 114, 20, 3, this, new int[] {5, 6, 7}, new ILogicPageList<String, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(String key)
|
||||
{
|
||||
String translated = I18n.format(key);
|
||||
|
||||
if(!translated.equals(key))
|
||||
{
|
||||
return translated;
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.gamerules.rule." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String clicked)
|
||||
{
|
||||
builderGamerule.setRule(clicked);
|
||||
booleanValue = Minecraft.getMinecraft().world.getGameRules().areSameType(clicked, ValueType.BOOLEAN_VALUE);
|
||||
|
||||
if(booleanValue)
|
||||
{
|
||||
builderGamerule.setValue(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
builderGamerule.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(String key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, String value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "gamerules";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(rules);
|
||||
}
|
||||
|
||||
@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")));
|
||||
|
||||
if(this.booleanValue)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable")));
|
||||
container.add(new GuiButtonWorldHandler(3, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(true)));
|
||||
break;
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(false)));
|
||||
break;
|
||||
case 4:
|
||||
WorldHandler.sendCommand(this.builderGamerule);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(!this.booleanValue)
|
||||
{
|
||||
this.valueField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.valueField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.value = this.valueField.getText();
|
||||
this.builderGamerule.setValue(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(!this.booleanValue)
|
||||
{
|
||||
this.valueField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.WORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.GAMERULES;
|
||||
}
|
||||
}
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamerule;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
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 exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.world.GameRules.ValueType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentGamerules extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip valueField;
|
||||
|
||||
private boolean booleanValue;
|
||||
private String value;
|
||||
|
||||
private final BuilderGamerule builderGamerule = new BuilderGamerule();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderGamerule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.value"));
|
||||
this.valueField.setValidator(Predicates.notNull());
|
||||
this.valueField.setText(this.value);
|
||||
this.valueField.setCursorPositionEnd();
|
||||
|
||||
ElementPageList<String, String> rules = new ElementPageList<String, String>(x, y, Arrays.asList(Minecraft.getMinecraft().world.getGameRules().getRules()), null, 114, 20, 3, this, new int[] {5, 6, 7}, new ILogicPageList<String, String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(String key)
|
||||
{
|
||||
String translated = I18n.format(key);
|
||||
|
||||
if(!translated.equals(key))
|
||||
{
|
||||
return translated;
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.gamerules.rule." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String clicked)
|
||||
{
|
||||
builderGamerule.setRule(clicked);
|
||||
booleanValue = Minecraft.getMinecraft().world.getGameRules().areSameType(clicked, ValueType.BOOLEAN_VALUE);
|
||||
|
||||
if(booleanValue)
|
||||
{
|
||||
builderGamerule.setValue(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
builderGamerule.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(String key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, String value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(String object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "gamerules";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(rules);
|
||||
}
|
||||
|
||||
@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")));
|
||||
|
||||
if(this.booleanValue)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable")));
|
||||
container.add(new GuiButtonWorldHandler(3, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(true)));
|
||||
break;
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(false)));
|
||||
break;
|
||||
case 4:
|
||||
WorldHandler.sendCommand(this.builderGamerule);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(!this.booleanValue)
|
||||
{
|
||||
this.valueField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.valueField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.value = this.valueField.getText();
|
||||
this.builderGamerule.setValue(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(!this.booleanValue)
|
||||
{
|
||||
this.valueField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.WORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.world.gamerules");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.GAMERULES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,262 +1,262 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentPotions extends ContentChild
|
||||
{
|
||||
private int potionPage;
|
||||
|
||||
private final BuilderPotionEffect builderPotion = new BuilderPotionEffect();
|
||||
private final BuilderPotionItem builderPotionItem = new BuilderPotionItem();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
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)
|
||||
{
|
||||
ElementPageList<ResourceLocation, Potion> potions = new ElementPageList<ResourceLocation, Potion>(x, y, new ArrayList(Potion.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {15, 16, 17}, new ILogicPageList<ResourceLocation, Potion>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Potion.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
builderPotion.setEffect(clicked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, ResourceLocation value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation convert(Potion object)
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return object.getRegistryName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "potions";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(potions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonWorldHandler button10;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
|
||||
if(this.potionPage == 0)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(5, x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.potions.effect.give")));
|
||||
container.add(new GuiButtonWorldHandler(6, x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove")));
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove_all")));
|
||||
}
|
||||
else if(this.potionPage == 1)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
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.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());
|
||||
})));
|
||||
}
|
||||
else if(this.potionPage == 2)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
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.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.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());
|
||||
})));
|
||||
}
|
||||
else if(this.potionPage == 3)
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(10, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect")));
|
||||
container.add(button7 = new GuiButtonWorldHandler(14, x + 118, y + 24, 56, 20, I18n.format("gui.worldhandler.potions.effect.tipped_arrow")));
|
||||
container.add(button8 = new GuiButtonWorldHandler(11, x + 178, y + 24, 55, 20, I18n.format("gui.worldhandler.potions.effect.bottle"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button9 = new GuiButtonWorldHandler(13, x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.potions.effect.splash"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button10 = new GuiButtonWorldHandler(12, x + 178, y + 48, 55, 20, I18n.format("gui.worldhandler.potions.effect.lingering"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
boolean enabled = this.builderPotion.getAmplifier() >= 0;
|
||||
|
||||
button6.enabled = enabled;
|
||||
button7.enabled = enabled;
|
||||
button8.enabled = enabled;
|
||||
button9.enabled = enabled;
|
||||
button10.enabled = enabled;
|
||||
}
|
||||
|
||||
if(this.potionPage > 0)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button6 = new GuiButtonWorldHandler(5, x + 118 + 60, y + 72, 55, 20, ">"));
|
||||
|
||||
button6.enabled = this.potionPage < 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
switch(button.id)
|
||||
{
|
||||
case 4:
|
||||
this.potionPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.potionPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
WorldHandler.sendCommand(this.builderPotion.getRemoveCommand());
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
WorldHandler.sendCommand(this.builderPotion.getClearCommand());
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
this.builderPotionItem.setAmbient(potion, !this.builderPotionItem.getAmbient(potion));
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
this.builderPotion.setHideParticles(!this.builderPotion.getHideParticles());
|
||||
this.builderPotionItem.setShowParticles(potion, !this.builderPotionItem.getShowParticles(potion));
|
||||
container.initGui();
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderPotion);
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.POTIONITEM));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 12:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.LINGERING_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 13:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.SPLASH_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 14:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.TIPPED_ARROW));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.potions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderPotion.setPlayer(username);
|
||||
this.builderPotionItem.setPlayer(username);
|
||||
}
|
||||
}
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentPotions extends ContentChild
|
||||
{
|
||||
private int potionPage;
|
||||
|
||||
private final BuilderPotionEffect builderPotion = new BuilderPotionEffect();
|
||||
private final BuilderPotionItem builderPotionItem = new BuilderPotionItem();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
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)
|
||||
{
|
||||
ElementPageList<ResourceLocation, Potion> potions = new ElementPageList<ResourceLocation, Potion>(x, y, new ArrayList(Potion.REGISTRY.getKeys()), null, 114, 20, 3, this, new int[] {15, 16, 17}, new ILogicPageList<ResourceLocation, Potion>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
{
|
||||
return I18n.format(Potion.REGISTRY.getObject(key).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
{
|
||||
builderPotion.setEffect(clicked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
{
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, ResourceLocation value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(Potion object)
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return object.getRegistryName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "potions";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(potions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonWorldHandler button10;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
|
||||
if(this.potionPage == 0)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(5, x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.potions.effect.give")));
|
||||
container.add(new GuiButtonWorldHandler(6, x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove")));
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove_all")));
|
||||
}
|
||||
else if(this.potionPage == 1)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
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.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());
|
||||
})));
|
||||
}
|
||||
else if(this.potionPage == 2)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
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.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.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());
|
||||
})));
|
||||
}
|
||||
else if(this.potionPage == 3)
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(10, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect")));
|
||||
container.add(button7 = new GuiButtonWorldHandler(14, x + 118, y + 24, 56, 20, I18n.format("gui.worldhandler.potions.effect.tipped_arrow")));
|
||||
container.add(button8 = new GuiButtonWorldHandler(11, x + 178, y + 24, 55, 20, I18n.format("gui.worldhandler.potions.effect.bottle"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button9 = new GuiButtonWorldHandler(13, x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.potions.effect.splash"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button10 = new GuiButtonWorldHandler(12, x + 178, y + 48, 55, 20, I18n.format("gui.worldhandler.potions.effect.lingering"), I18n.format("gui.worldhandler.actions.place_command_block"), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
boolean enabled = this.builderPotion.getAmplifier() >= 0;
|
||||
|
||||
button6.enabled = enabled;
|
||||
button7.enabled = enabled;
|
||||
button8.enabled = enabled;
|
||||
button9.enabled = enabled;
|
||||
button10.enabled = enabled;
|
||||
}
|
||||
|
||||
if(this.potionPage > 0)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button6 = new GuiButtonWorldHandler(5, x + 118 + 60, y + 72, 55, 20, ">"));
|
||||
|
||||
button6.enabled = this.potionPage < 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
switch(button.id)
|
||||
{
|
||||
case 4:
|
||||
this.potionPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.potionPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
WorldHandler.sendCommand(this.builderPotion.getRemoveCommand());
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
WorldHandler.sendCommand(this.builderPotion.getClearCommand());
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
this.builderPotionItem.setAmbient(potion, !this.builderPotionItem.getAmbient(potion));
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
this.builderPotion.setHideParticles(!this.builderPotion.getHideParticles());
|
||||
this.builderPotionItem.setShowParticles(potion, !this.builderPotionItem.getShowParticles(potion));
|
||||
container.initGui();
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderPotion);
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.POTIONITEM));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 12:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.LINGERING_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 13:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.SPLASH_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 14:
|
||||
WorldHandler.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.TIPPED_ARROW));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.potions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderPotion.setPlayer(username);
|
||||
this.builderPotionItem.setPlayer(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ContentRecipes extends Content
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe convert(String object)
|
||||
public IRecipe getObject(String object)
|
||||
{
|
||||
return CraftingManager.REGISTRY.getObject(Type.parseResourceLocation(object));
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user