2.0
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumIcon
|
||||
{
|
||||
WEATHER_SUN(0, 0),
|
||||
WEATHER_RAIN(0, 1),
|
||||
WEATHER_STORM(0, 2),
|
||||
DIFFICULTY_PEACEFUL(1, 0),
|
||||
DIFFICULTY_EASY(1, 1),
|
||||
DIFFICULTY_NORMAL(1, 2),
|
||||
DIFFICULTY_HARD(1, 3),
|
||||
TIME_DAWN(2, 0),
|
||||
TIME_NOON(2, 1),
|
||||
TIME_SUNSET(2, 2),
|
||||
TIME_MIDNIGHT(2, 3),
|
||||
GAMEMODE_SURVIVAL(3, 0),
|
||||
GAMEMODE_CREATIVE(3, 1),
|
||||
GAMEMODE_ADVENTURE(3, 2),
|
||||
GAMEMODE_SPECTATOR(3, 3),
|
||||
BUTCHER(4, 0),
|
||||
POTION(4, 1),
|
||||
ACHIEVEMNTS(4, 2),
|
||||
HOME(5, 0),
|
||||
SETTINGS(5, 1),
|
||||
RELOAD(5, 2);
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
private EnumIcon(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumTooltip
|
||||
{
|
||||
TOP_RIGHT,
|
||||
TOP_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM_LEFT,
|
||||
RIGHT,
|
||||
LEFT
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonItem extends GuiButtonWorldHandler
|
||||
{
|
||||
private final ItemStack item;
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, Item item)
|
||||
{
|
||||
this(id, x, y, width, height, new ItemStack(item));
|
||||
}
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack item)
|
||||
{
|
||||
super(id, x, y, width, height, null);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
|
||||
GlStateManager.enableRescaleNormal();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(this.item, this.x + this.width / 2 - 8, this.y + 2);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonKeyboard extends GuiButtonWorldHandler
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private final Orientation orientation;
|
||||
private final float pitch;
|
||||
|
||||
private boolean lastMousePressed;
|
||||
|
||||
private final BlockPos pos;
|
||||
private final SoundEvent sound;
|
||||
private final Content content;
|
||||
private final Container container;
|
||||
|
||||
public GuiButtonKeyboard(int id, int x, int y, int width, int height, String displayString, Orientation orientation, float pitch, Container container, Content content, BlockPos pos, SoundEvent sound)
|
||||
{
|
||||
super(id, x, y, width, height, displayString);
|
||||
this.orientation = orientation;
|
||||
this.pitch = pitch;
|
||||
this.pos = pos;
|
||||
this.sound = sound;
|
||||
this.content = content;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
FontRenderer fontRenderer = minecraft.fontRenderer;
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
minecraft.renderEngine.bindTexture(NOTE);
|
||||
|
||||
switch(this.orientation)
|
||||
{
|
||||
case LEFT:
|
||||
this.hovered = this.isHoveringLeft(mouseX, mouseY);
|
||||
break;
|
||||
case NORMAL:
|
||||
this.hovered = this.isHoveringNormal(mouseX, mouseY);
|
||||
break;
|
||||
case RIGHT:
|
||||
this.hovered = this.isHoveringRight(mouseX, mouseY);
|
||||
break;
|
||||
case BLACK:
|
||||
this.hovered = this.isHoveringBlack(mouseX, mouseY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int hoverstate = this.getHoverState(this.hovered);
|
||||
|
||||
switch(this.orientation)
|
||||
{
|
||||
case BLACK:
|
||||
this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
|
||||
break;
|
||||
case LEFT:
|
||||
case NORMAL:
|
||||
case RIGHT:
|
||||
default:
|
||||
int textColor = 0x000000;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0x8B8B8B;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
|
||||
fontRenderer.drawString(this.displayString, this.x + this.width / 2 - fontRenderer.getStringWidth(this.displayString) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private boolean isHoveringBlack(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
private boolean isHoveringNormal(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
private boolean isHoveringRight(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 14 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
switch(this.orientation)
|
||||
{
|
||||
case LEFT:
|
||||
return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
|
||||
case NORMAL:
|
||||
return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
|
||||
case RIGHT:
|
||||
return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
|
||||
case BLACK:
|
||||
return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
if(this.lastMousePressed != mousePressed(minecraft, mouseX, mouseY))
|
||||
{
|
||||
if(mousePressed(minecraft, mouseX, mouseY) && Mouse.isButtonDown(0))
|
||||
{
|
||||
this.playPressSound(minecraft.getSoundHandler());
|
||||
this.content.actionPerformed(this.container, this);
|
||||
}
|
||||
|
||||
this.lastMousePressed = mousePressed(minecraft, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPressSound(SoundHandler soundHandlerIn)
|
||||
{
|
||||
soundHandlerIn.playSound(PositionedSoundRecord.getMasterRecord(this.sound, this.pitch));
|
||||
}
|
||||
|
||||
public static enum Orientation
|
||||
{
|
||||
LEFT,
|
||||
NORMAL,
|
||||
RIGHT,
|
||||
BLACK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
{
|
||||
private final IListButtonLogic<T> logic;
|
||||
private final ButtonStorage<T> storage;
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, Content container, IListButtonLogic<T> logic)
|
||||
{
|
||||
this(id, x, y, width, height, null, container, logic);
|
||||
}
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content container, IListButtonLogic<T> logic)
|
||||
{
|
||||
super(id, x, y, width, height, null, null, tooltipType);
|
||||
this.logic = logic;
|
||||
this.storage = container.getStorage(this.logic.getId());
|
||||
this.updateStorageObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
|
||||
if(this.visible)
|
||||
{
|
||||
FontRenderer fontRenderer = minecraft.fontRenderer;
|
||||
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
|
||||
this.displayString = this.logic.getDisplayString(this.storage);
|
||||
|
||||
if(this.displayString != null && !this.displayString.isEmpty())
|
||||
{
|
||||
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? ChatFormatting.BOLD + "<" + ChatFormatting.RESET : "<";
|
||||
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? ChatFormatting.BOLD + ">" + ChatFormatting.RESET : ">";
|
||||
|
||||
int leftArrowWidth = fontRenderer.getStringWidth(leftArrow);
|
||||
int rightArrowWidth = fontRenderer.getStringWidth(rightArrow);
|
||||
|
||||
int maxWidth = Math.max(0, this.width - (fontRenderer.getStringWidth("< >")));
|
||||
int spaceWidth = fontRenderer.getCharWidth(' ');
|
||||
|
||||
String display = TextFormatting.shortenString(this.displayString, maxWidth, fontRenderer);
|
||||
int displayWidth = fontRenderer.getStringWidth(display);
|
||||
int yPos = this.y + (this.height - 8) / 2;
|
||||
|
||||
this.drawCenteredString(fontRenderer, display, this.x + this.width / 2, yPos, this.getTextColor());
|
||||
this.drawCenteredString(fontRenderer, leftArrow, this.x + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getTextColor());
|
||||
this.drawCenteredString(fontRenderer, rightArrow, this.x + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getTextColor());
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(int mouseX, int mouseY, int width, int height)
|
||||
{
|
||||
if(this.tooltipType != null)
|
||||
{
|
||||
this.displayTooltip = this.logic.getTooltipString(this.storage);
|
||||
}
|
||||
|
||||
super.drawTooltip(mouseX, mouseY, width, height);
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(int mouseX, int mouseY)
|
||||
{
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
|
||||
}
|
||||
|
||||
private boolean isHoveringRight(int mouseX, int mouseY)
|
||||
{
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
|
||||
}
|
||||
|
||||
private boolean isHoveringVertical(int mouseY)
|
||||
{
|
||||
return mouseY >= this.y && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(this.isHoveringLeft(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.storage.getIndex() > 0)
|
||||
{
|
||||
this.storage.decrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.storage.setIndex(this.logic.getMax() - 1);
|
||||
}
|
||||
}
|
||||
else if(this.isHoveringRight(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.storage.getIndex() < this.logic.getMax() - 1)
|
||||
{
|
||||
this.storage.incrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.storage.setIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateStorageObject();
|
||||
this.logic.actionPerformed(container, button, this.storage);
|
||||
}
|
||||
|
||||
private void updateStorageObject()
|
||||
{
|
||||
this.storage.setObject(this.logic.getObject(this.storage.getIndex()));
|
||||
}
|
||||
|
||||
public IListButtonLogic<T> getLogic()
|
||||
{
|
||||
return this.logic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonTab extends GuiButton
|
||||
{
|
||||
private final int index;
|
||||
|
||||
public GuiButtonTab(int buttonId, int x, int y, int widthIn, int heightIn, int index)
|
||||
{
|
||||
super(buttonId, x, y, widthIn, heightIn, null);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPressSound(SoundHandler soundHandlerIn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonWorldHandler extends GuiButton
|
||||
{
|
||||
protected String displayTooltip;
|
||||
protected EnumTooltip tooltipType;
|
||||
protected EnumIcon icon;
|
||||
protected boolean isActive;
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, null, null);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, tooltip, tooltipType, null);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, EnumIcon icon)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, null, null, icon);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType, EnumIcon icon)
|
||||
{
|
||||
super(id, x, y, width, height, displayString);
|
||||
this.displayTooltip = tooltip;
|
||||
this.tooltipType = tooltipType;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
this.drawBackground(minecraft, mouseX, mouseY);
|
||||
this.drawCenteredString(minecraft.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
|
||||
|
||||
if(this.icon != null)
|
||||
{
|
||||
this.drawIcons();
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTextColor()
|
||||
{
|
||||
int textColor = 0xE0E0E0;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0xFFFFA0;
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
|
||||
protected void drawBackground(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
int hovered = this.getHoverState(this.hovered);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
|
||||
|
||||
if(ConfigSkin.getTextureType().equals("resourcepack"))
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + hovered * 20, this.width / 2, this.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void drawTooltip(int mouseX, int mouseY, int width, int height)
|
||||
{
|
||||
if(this.hovered && this.displayTooltip != null)
|
||||
{
|
||||
int tooltipWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayTooltip) + 9;
|
||||
int xOffset = 12;
|
||||
int yOffset = 12;
|
||||
boolean right = mouseX + xOffset + tooltipWidth > width;
|
||||
boolean left = mouseX > tooltipWidth + xOffset;
|
||||
|
||||
switch(this.tooltipType)
|
||||
{
|
||||
case TOP_RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, right);
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, left);
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, yOffset, right);
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, yOffset, left);
|
||||
break;
|
||||
case RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, 0, right);
|
||||
break;
|
||||
case LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, 0, left);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderTooltip(int mouseX, int mouseY, int xOffset, int yOffset, boolean left)
|
||||
{
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
GlStateManager.disableDepth();
|
||||
|
||||
String[] text = this.displayTooltip.split("\n");
|
||||
|
||||
int tooltipTextWidth = 0;
|
||||
int tooltipX = mouseX + xOffset;
|
||||
int tooltipY = mouseY + yOffset;
|
||||
|
||||
for(String line : text)
|
||||
{
|
||||
int length = fontRenderer.getStringWidth(line) + 1;
|
||||
|
||||
if(length > tooltipTextWidth)
|
||||
{
|
||||
tooltipTextWidth = length;
|
||||
}
|
||||
}
|
||||
|
||||
if(left)
|
||||
{
|
||||
tooltipX = mouseX - xOffset - tooltipTextWidth;
|
||||
}
|
||||
|
||||
int tooltipHeight = fontRenderer.FONT_HEIGHT * text.length;
|
||||
int backgroundColor = 0xF0100010;
|
||||
int borderColorStart = 0x505000FF;
|
||||
int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
|
||||
|
||||
int zLevel = 300;
|
||||
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||
|
||||
for(int x = 0; x < text.length; x++)
|
||||
{
|
||||
fontRenderer.drawStringWithShadow(text[x], tooltipX + 1, tooltipY + 1 + fontRenderer.FONT_HEIGHT * x, -1);
|
||||
}
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
protected void drawIcons()
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getIconTexture());
|
||||
|
||||
if(this.enabled == true)
|
||||
{
|
||||
if(this.hovered)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 0.6F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color(0.95F, 0.95F, 0.95F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color(0.8F, 0.8F, 0.8F, 1.0F);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
return super.mousePressed(mc, mouseX, mouseY) && this.isActive;
|
||||
}
|
||||
}
|
||||
189
src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
Normal file
189
src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.button.storage.SliderStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiSlider<T> extends GuiButton
|
||||
{
|
||||
private boolean isMouseDown;
|
||||
private boolean isActive;
|
||||
|
||||
private final Object key;
|
||||
private final String name;
|
||||
private final ISliderResponder responder;
|
||||
private final Container frame;
|
||||
private final ButtonStorage<SliderStorage> storage;
|
||||
|
||||
public GuiSlider(Content container, Container frame, Object key, int x, int y, int width, int height, String name, float min, float max, float start, ISliderResponder responder)
|
||||
{
|
||||
super(Integer.MAX_VALUE, x, y, width, height, null);
|
||||
this.frame = frame;
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.responder = responder;
|
||||
this.storage = container.getStorage(key);
|
||||
|
||||
if(this.storage.getObject() == null || this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max)
|
||||
{
|
||||
this.storage.setObject(new SliderStorage(min, max, min == max ? 0 : ((start - min) / (max - min))));
|
||||
}
|
||||
|
||||
this.displayString = this.getDisplayString();
|
||||
}
|
||||
|
||||
private void setFloat(float value)
|
||||
{
|
||||
this.storage.getObject().setFloat(value);
|
||||
}
|
||||
|
||||
private float getFloat()
|
||||
{
|
||||
return this.storage.getObject().getFloat();
|
||||
}
|
||||
|
||||
private void setValue(int value)
|
||||
{
|
||||
SliderStorage slider = this.storage.getObject();
|
||||
this.storage.getObject().setFloat((value - slider.getMin()) / (slider.getMax() - slider.getMin()));
|
||||
}
|
||||
|
||||
private int getValue()
|
||||
{
|
||||
SliderStorage slider = this.storage.getObject();
|
||||
return (int) (slider.getMin() + (slider.getMax() - slider.getMin()) * this.getFloat());
|
||||
}
|
||||
|
||||
private String getDisplayString()
|
||||
{
|
||||
return this.responder.getText(this.key, I18n.format(this.name), this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHoverState(boolean mouseOver)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
|
||||
|
||||
if(ConfigSkin.getTextureType().equals("resourcepack"))
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 46, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46, this.width / 2, this.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 0, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 0, this.width / 2, this.height);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void update(int mouseX, int mouseY)
|
||||
{
|
||||
float sliderValue = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
|
||||
|
||||
if(sliderValue < 0.0F)
|
||||
{
|
||||
sliderValue = 0.0F;
|
||||
}
|
||||
|
||||
if(sliderValue > 1.0F)
|
||||
{
|
||||
sliderValue = 1.0F;
|
||||
}
|
||||
|
||||
this.setFloat(sliderValue);
|
||||
this.displayString = this.getDisplayString();
|
||||
this.responder.setValue(this.key, this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
if(this.isMouseDown)
|
||||
{
|
||||
this.update(mouseX, mouseY);
|
||||
}
|
||||
|
||||
int textureXOffset = ConfigSkin.getTextureType().equals("resourcepack") ? 0 : -46;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
|
||||
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
int color = 0xE0E0E0;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
color = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
color = 0xFFFFA0;
|
||||
}
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, color);
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if(super.mousePressed(mc, mouseX, mouseY) && this.isActive)
|
||||
{
|
||||
this.update(mouseX, mouseY);
|
||||
this.isMouseDown = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY)
|
||||
{
|
||||
this.isMouseDown = false;
|
||||
|
||||
if(this.frame != null)
|
||||
{
|
||||
this.frame.initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiPageButtonList;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiTextFieldTooltip
|
||||
{
|
||||
private GuiTextField textfield;
|
||||
private String display;
|
||||
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height, String display)
|
||||
{
|
||||
this.textfield = new GuiTextField(0, Minecraft.getMinecraft().fontRenderer, x, y, width, height);
|
||||
this.textfield.setMaxStringLength(Integer.MAX_VALUE);
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height)
|
||||
{
|
||||
this(x, y, width, height, null);
|
||||
}
|
||||
|
||||
public void setGuiResponder(GuiPageButtonList.GuiResponder responder)
|
||||
{
|
||||
this.textfield.setGuiResponder(responder);
|
||||
}
|
||||
|
||||
public void updateCursorCounter()
|
||||
{
|
||||
this.textfield.updateCursorCounter();
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.textfield.setText(text);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return this.textfield.getText();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if(this.textfield.getText() != null)
|
||||
{
|
||||
return this.textfield.getText().matches("(\u00A7[a-f0-9k-or])+");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canType(char charTyped)
|
||||
{
|
||||
return (!this.isEmpty() || charTyped != '\b') && this.textfield.isFocused();
|
||||
}
|
||||
|
||||
public String getSelectedText()
|
||||
{
|
||||
return this.textfield.getSelectedText();
|
||||
}
|
||||
|
||||
public void setValidator(Predicate<String> validator)
|
||||
{
|
||||
this.textfield.setValidator(validator);;
|
||||
}
|
||||
|
||||
public void writeText(String text)
|
||||
{
|
||||
this.textfield.writeText(text);
|
||||
}
|
||||
|
||||
public void deleteWords(int num)
|
||||
{
|
||||
this.textfield.deleteWords(num);
|
||||
}
|
||||
|
||||
public void deleteFromCursor(int num)
|
||||
{
|
||||
this.textfield.deleteFromCursor(num);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.textfield.getId();
|
||||
}
|
||||
|
||||
public int getNthWordFromCursor(int numWords)
|
||||
{
|
||||
return this.textfield.getNthWordFromCursor(numWords);
|
||||
}
|
||||
|
||||
public int getNthWordFromPos(int n, int pos)
|
||||
{
|
||||
return this.textfield.getNthWordFromPos(n, pos);
|
||||
}
|
||||
|
||||
public int getNthWordFromPosWS(int n, int pos, boolean skipWs)
|
||||
{
|
||||
return this.textfield.getNthWordFromPosWS(n, pos, skipWs);
|
||||
}
|
||||
|
||||
public void moveCursorBy(int num)
|
||||
{
|
||||
this.textfield.moveCursorBy(num);
|
||||
}
|
||||
|
||||
public void setCursorPosition(int pos)
|
||||
{
|
||||
this.textfield.setCursorPosition(pos);
|
||||
}
|
||||
|
||||
public void setCursorPositionZero()
|
||||
{
|
||||
this.textfield.setCursorPositionZero();
|
||||
}
|
||||
|
||||
public void setCursorPositionEnd()
|
||||
{
|
||||
this.textfield.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
public boolean textboxKeyTyped(char typedChar, int keyCode)
|
||||
{
|
||||
return this.textfield.textboxKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.textfield.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
public void drawTextBox()
|
||||
{
|
||||
this.textfield.drawTextBox();
|
||||
|
||||
if(this.textfield.getVisible())
|
||||
{
|
||||
int x = this.textfield.getEnableBackgroundDrawing() ? this.textfield.x + 4 : this.textfield.x;
|
||||
int y = this.textfield.getEnableBackgroundDrawing() ? this.textfield.y + (this.textfield.height - 8) / 2 : this.textfield.y;
|
||||
|
||||
if(ChatFormatting.stripFormatting(this.textfield.getText()).isEmpty() && !this.textfield.isFocused() && this.display != null)
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(this.display, (float) x, (float) y, 0x7F7F7F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxStringLength(int length)
|
||||
{
|
||||
this.textfield.setMaxStringLength(length);
|
||||
}
|
||||
|
||||
public int getMaxStringLength()
|
||||
{
|
||||
return this.textfield.getMaxStringLength();
|
||||
}
|
||||
|
||||
public int getCursorPosition()
|
||||
{
|
||||
return this.textfield.getCursorPosition();
|
||||
}
|
||||
|
||||
public boolean getEnableBackgroundDrawing()
|
||||
{
|
||||
return this.textfield.getEnableBackgroundDrawing();
|
||||
}
|
||||
|
||||
public void setEnableBackgroundDrawing(boolean enableBackgroundDrawing)
|
||||
{
|
||||
this.textfield.setEnableBackgroundDrawing(enableBackgroundDrawing);
|
||||
}
|
||||
|
||||
public void setTextColor(int color)
|
||||
{
|
||||
this.textfield.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setDisabledTextColour(int color)
|
||||
{
|
||||
this.textfield.setDisabledTextColour(color);
|
||||
}
|
||||
|
||||
public void setFocused(boolean focused)
|
||||
{
|
||||
this.textfield.setFocused(focused);
|
||||
}
|
||||
|
||||
public boolean isFocused()
|
||||
{
|
||||
return this.textfield.isFocused();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.textfield.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public int getSelectionEnd()
|
||||
{
|
||||
return this.textfield.getSelectionEnd();
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.textfield.getWidth();
|
||||
}
|
||||
|
||||
public void setSelectionPos(int position)
|
||||
{
|
||||
this.textfield.setSelectionPos(position);
|
||||
}
|
||||
|
||||
public void setCanLoseFocus(boolean canLoseFocus)
|
||||
{
|
||||
this.textfield.setCanLoseFocus(canLoseFocus);
|
||||
}
|
||||
|
||||
public boolean getVisible()
|
||||
{
|
||||
return this.textfield.getVisible();
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
this.textfield.setVisible(visible);
|
||||
}
|
||||
|
||||
public void setDisplay(String display)
|
||||
{
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y)
|
||||
{
|
||||
this.textfield.x = x;
|
||||
this.textfield.y = y;
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
this.textfield.width = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height)
|
||||
{
|
||||
this.textfield.height = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ColorListButtonLogic implements IListButtonLogic<Integer>
|
||||
{
|
||||
@Override
|
||||
public final int getMax()
|
||||
{
|
||||
return (int) Arrays.stream(ChatFormatting.values()).filter(ChatFormatting::isColor).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getObject(int index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipString(ButtonStorage<Integer> storage)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage storage)
|
||||
{
|
||||
EnumColor color = EnumColor.getColorFromId(storage.getIndex());
|
||||
return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "color";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IListButtonLogic<T>
|
||||
{
|
||||
void actionPerformed(Container container, GuiButton button, ButtonStorage<T> storage);
|
||||
|
||||
int getMax();
|
||||
|
||||
T getObject(int index);
|
||||
|
||||
String getDisplayString(ButtonStorage<T> storage);
|
||||
|
||||
default String getTooltipString(ButtonStorage<T> storage)
|
||||
{
|
||||
if(storage != null && storage.getObject() != null)
|
||||
{
|
||||
return storage.getObject().toString() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ISliderResponder
|
||||
{
|
||||
void setValue(Object id, int value);
|
||||
String getText(Object id, String format, int value);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.gui.button.responder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class AttributeResponder extends SimpleResponder
|
||||
{
|
||||
public AttributeResponder(Consumer<Integer> valueConsumer)
|
||||
{
|
||||
super(valueConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object id, String format, int value)
|
||||
{
|
||||
String suffix = ": " + value + " " + ((EnumAttributes) id).getOperation().getDeclaration();
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package exopandora.worldhandler.gui.button.responder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SimpleResponder<T> implements ISliderResponder
|
||||
{
|
||||
private final Consumer<Integer> valueConsumer;
|
||||
|
||||
public SimpleResponder(Consumer<Integer> valueConsumer)
|
||||
{
|
||||
this.valueConsumer = valueConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object id, int value)
|
||||
{
|
||||
this.valueConsumer.accept(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object id, String format, int value)
|
||||
{
|
||||
String suffix = ": " + value;
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package exopandora.worldhandler.gui.button.storage;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ButtonStorage<T>
|
||||
{
|
||||
private int index;
|
||||
private T object;
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void incrementIndex()
|
||||
{
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public void decrementIndex()
|
||||
{
|
||||
this.index--;
|
||||
}
|
||||
|
||||
public T getObject()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
|
||||
public void setObject(T object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package exopandora.worldhandler.gui.button.storage;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SliderStorage
|
||||
{
|
||||
private final float min;
|
||||
private final float max;
|
||||
private float value;
|
||||
|
||||
public SliderStorage(float min, float max, float value)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public float getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public float getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setFloat(float value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package exopandora.worldhandler.gui.category;
|
||||
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Categories
|
||||
{
|
||||
public static final Category MAIN;
|
||||
public static final Category ENTITIES;
|
||||
public static final Category ITEMS;
|
||||
public static final Category BLOCKS;
|
||||
public static final Category WORLD;
|
||||
public static final Category PLAYER;
|
||||
public static final Category SCOREBOARD;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Categories.getRegisteredCategory("main");
|
||||
ENTITIES = Categories.getRegisteredCategory("entities");
|
||||
ITEMS = Categories.getRegisteredCategory("items");
|
||||
BLOCKS = Categories.getRegisteredCategory("blocks");
|
||||
WORLD = Categories.getRegisteredCategory("world");
|
||||
PLAYER = Categories.getRegisteredCategory("player");
|
||||
SCOREBOARD = Categories.getRegisteredCategory("scoreboard");
|
||||
}
|
||||
|
||||
private static Category getRegisteredCategory(String name)
|
||||
{
|
||||
Category category = Category.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(category == null)
|
||||
{
|
||||
throw new IllegalStateException("Invalid Category requested: " + name);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.gui.category;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Category
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Category> REGISTRY = new RegistryNamespaced<ResourceLocation, Category>();
|
||||
|
||||
private final List<Content> contents;
|
||||
|
||||
public Category()
|
||||
{
|
||||
this.contents = new ArrayList<Content>();
|
||||
}
|
||||
|
||||
public Category(List<Content> contents)
|
||||
{
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public Category(Content... contents)
|
||||
{
|
||||
this.contents = Arrays.asList(contents);
|
||||
}
|
||||
|
||||
public Category add(Content content)
|
||||
{
|
||||
this.contents.add(content);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Content> getContents()
|
||||
{
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return this.contents.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Content getContent(int index)
|
||||
{
|
||||
return this.contents.get(index);
|
||||
}
|
||||
|
||||
public static void registerCategories()
|
||||
{
|
||||
registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER));
|
||||
registerCategory(1, "entities", new Category(Contents.SUMMON));
|
||||
registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT));
|
||||
registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR));
|
||||
registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES));
|
||||
registerCategory(5, "player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS));
|
||||
registerCategory(6, "scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS));
|
||||
}
|
||||
|
||||
private static void registerCategory(int id, String textualID, Category category)
|
||||
{
|
||||
registerCategory(id, new ResourceLocation(Main.MODID, textualID), category);
|
||||
}
|
||||
|
||||
private static void registerCategory(int id, ResourceLocation textualID, Category category)
|
||||
{
|
||||
REGISTRY.register(id, textualID, category);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package exopandora.worldhandler.gui.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigButcher;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.fml.client.config.DummyConfigElement;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiConfigWorldHandler extends GuiConfig
|
||||
{
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, List<IConfigElement> configElements)
|
||||
{
|
||||
super(parentScreen, configElements, Main.MODID, false, false, Main.NAME);
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, ConfigCategory category)
|
||||
{
|
||||
this(parentScreen, new ConfigElement(category).getChildElements());
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, String category)
|
||||
{
|
||||
this(parentScreen, WorldHandler.CONFIG.getCategory(category));
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen)
|
||||
{
|
||||
this(parentScreen, getConfigElements());
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
List<IConfigElement> list = new ArrayList();
|
||||
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package exopandora.worldhandler.gui.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFactoryWorldHandler implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
public void initialize(Minecraft minecraft)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConfigGui()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiScreen createConfigGui(GuiScreen parentScreen)
|
||||
{
|
||||
return new GuiConfigWorldHandler(parentScreen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.IElement;
|
||||
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 abstract class Container extends GuiScreen implements IContainer
|
||||
{
|
||||
protected final List<IElement> elements = new ArrayList<IElement>();
|
||||
|
||||
@Override
|
||||
public void add(GuiButton button)
|
||||
{
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Element element)
|
||||
{
|
||||
this.elements.add(element);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IContainer
|
||||
{
|
||||
void add(GuiButton button);
|
||||
void initButtons();
|
||||
void add(Element element);
|
||||
|
||||
String getPlayer();
|
||||
}
|
||||
@@ -0,0 +1,718 @@
|
||||
package exopandora.worldhandler.gui.container.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderDifficulty;
|
||||
import exopandora.worldhandler.builder.impl.BuilderDifficulty.EnumDifficulty;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamemode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamemode.EnumGamemode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTime;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTime.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWeather;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWeather.EnumWeather;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTab;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.IContent;
|
||||
import exopandora.worldhandler.gui.content.element.IElement;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import exopandora.worldhandler.util.UtilRender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiWorldHandlerContainer extends Container
|
||||
{
|
||||
private final Content content;
|
||||
private final int tabSize;
|
||||
private final int bgTextureWidth = 248;
|
||||
private final int bgTextureHeight = 166;
|
||||
private final int tabDistance = 2;
|
||||
private final int tabDistanceTotal;
|
||||
private final double tabWidth;
|
||||
private final double tabHalf;
|
||||
private final double tabEpsilon;
|
||||
private final String splash = this.getSplash();
|
||||
private final List<GuiButton> finalButtons = new ArrayList<GuiButton>();
|
||||
|
||||
private GuiTextFieldTooltip syntaxField;
|
||||
private GuiTextFieldTooltip nameField;
|
||||
|
||||
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
|
||||
|
||||
public GuiWorldHandlerContainer(Content content)
|
||||
{
|
||||
this.content = content;
|
||||
this.tabSize = this.content.getCategory().getSize();
|
||||
this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
|
||||
this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
|
||||
this.tabHalf = this.tabWidth / 2D;
|
||||
this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
this.finalButtons.clear();
|
||||
this.elements.clear();
|
||||
|
||||
//INIT
|
||||
this.content.onPlayerNameChanged(this.getPlayer());
|
||||
this.content.initGui(this, this.getContentX(), this.getContentY());
|
||||
|
||||
//ELEMENTS
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.initGui(this);
|
||||
}
|
||||
|
||||
//SHORTCUTS
|
||||
|
||||
final int x = this.width / 2 - 10;
|
||||
final int delta = 21;
|
||||
|
||||
if(ConfigSettings.areShortcutsEnabled())
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-1, x - delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.RIGHT, EnumIcon.TIME_DAWN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-2, x - delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.RIGHT, EnumIcon.TIME_NOON));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-3, x - delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.RIGHT, EnumIcon.TIME_SUNSET));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-4, x - delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.RIGHT, EnumIcon.TIME_MIDNIGHT));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-5, x - delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.RIGHT, EnumIcon.WEATHER_SUN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-6, x - delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.RIGHT, EnumIcon.WEATHER_RAIN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-7, x - delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.RIGHT, EnumIcon.WEATHER_STORM));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-8, x - delta * 0, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-9, x + delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_EASY));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-10, x + delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_NORMAL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-11, x + delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_HARD));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-12, x + delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-13, x + delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_CREATIVE));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-14, x + delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-15, x + delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled())
|
||||
{
|
||||
this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
//NAME
|
||||
|
||||
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
|
||||
this.nameField.setMaxStringLength(16);
|
||||
this.nameField.setText(this.getPlayer());
|
||||
this.updateNameField();
|
||||
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
this.forEachTab((index, xOffset) ->
|
||||
{
|
||||
IContent tab = this.content.getCategory().getContent(index);
|
||||
|
||||
if(!this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonTab(-16, (int)(backgroundX + xOffset), backgroundY - 20, (int)this.tabWidth + (int)Math.ceil(this.tabEpsilon / this.tabSize), 21, index));
|
||||
}
|
||||
});
|
||||
|
||||
//BUTTONS
|
||||
|
||||
this.initButtons();
|
||||
}
|
||||
|
||||
public void initButtons()
|
||||
{
|
||||
this.buttonList.clear();
|
||||
|
||||
this.content.initButtons(this, this.getContentX(), this.getContentY());
|
||||
|
||||
if(this.finalButtons != null && !this.finalButtons.isEmpty())
|
||||
{
|
||||
this.buttonList.addAll(this.finalButtons);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.initButtons(this);
|
||||
}
|
||||
}
|
||||
|
||||
private int getContentX()
|
||||
{
|
||||
return (this.width - this.bgTextureWidth) / 2 + 8 + this.getXOffset();
|
||||
}
|
||||
|
||||
private int getContentY()
|
||||
{
|
||||
return this.height / 2 - 50 + this.getYOffset();
|
||||
}
|
||||
|
||||
private int getXOffset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getYOffset()
|
||||
{
|
||||
return ConfigSettings.areShortcutsEnabled() ? 11 : 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
this.content.updateScreen(this);
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
private int getBackgroundX()
|
||||
{
|
||||
return (this.width - this.bgTextureWidth) / 2 + this.getXOffset();
|
||||
}
|
||||
|
||||
private int getBackgroundY()
|
||||
{
|
||||
return (this.height - this.bgTextureHeight) / 2 + this.getYOffset();
|
||||
}
|
||||
|
||||
private int getWatchOffset()
|
||||
{
|
||||
return ConfigSettings.isWatchEnabled() ? 9 : 0;
|
||||
}
|
||||
|
||||
private void forEachTab(BiConsumer<Integer, Double> consumer)
|
||||
{
|
||||
double xOffset = 0D;
|
||||
|
||||
for(int index = 0; index < this.tabSize; index++)
|
||||
{
|
||||
consumer.accept(index, xOffset);
|
||||
xOffset += this.tabWidth + this.tabDistance + this.tabEpsilon / this.tabSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSyntax()
|
||||
{
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
if(!this.syntaxField.isFocused())
|
||||
{
|
||||
this.syntaxField.setValidator(Predicates.alwaysTrue());
|
||||
|
||||
if(this.content.getCommandBuilder() != null)
|
||||
{
|
||||
this.syntaxField.setText(this.content.getCommandBuilder().toCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
|
||||
}
|
||||
|
||||
this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
|
||||
this.syntaxField.setCursorPositionZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNameField()
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
if(WorldHandler.USERNAME.isEmpty())
|
||||
{
|
||||
int width = this.fontRenderer.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
|
||||
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.fontRenderer.getStringWidth(this.content.getTitle()) + 2), backgroundY + 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = this.fontRenderer.getStringWidth(WorldHandler.USERNAME) + 2;
|
||||
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
|
||||
this.content.onPlayerNameChanged(WorldHandler.USERNAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 1:
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 0:
|
||||
if(this.content.getBackContent() != null)
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getBackContent()));
|
||||
}
|
||||
break;
|
||||
case -1:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getDawn()));
|
||||
break;
|
||||
case -2:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getNoon()));
|
||||
break;
|
||||
case -3:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getSunset()));
|
||||
break;
|
||||
case -4:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getMidnight()));
|
||||
break;
|
||||
case -5:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.CLEAR));
|
||||
break;
|
||||
case -6:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.RAIN));
|
||||
break;
|
||||
case -7:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.THUNDER));
|
||||
break;
|
||||
case -8:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.PEACEFUL));
|
||||
break;
|
||||
case -9:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.EASY));
|
||||
break;
|
||||
case -10:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.NORMAL));
|
||||
break;
|
||||
case -11:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.HARD));
|
||||
break;
|
||||
case -12:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SURVIVAL));
|
||||
break;
|
||||
case -13:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.CREATIVE));
|
||||
break;
|
||||
case -14:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.ADVENTURE));
|
||||
break;
|
||||
case -15:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SPECTATOR));
|
||||
break;
|
||||
case -16:
|
||||
if(button instanceof GuiButtonTab)
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getCategory().getContent(((GuiButtonTab)button).getIndex())));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elements:
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
if(element.actionPerformed(this, button))
|
||||
{
|
||||
break elements;
|
||||
}
|
||||
}
|
||||
|
||||
this.content.actionPerformed(this, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void defaultColor()
|
||||
{
|
||||
this.defaultColor(1);
|
||||
}
|
||||
|
||||
private void defaultColor(float alpha)
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255, (float) ConfigSkin.getBackgroundGreen() / 255, (float) ConfigSkin.getBackgroundBlue() / 255, alpha * (float) ConfigSkin.getBackgroundAlpha() / 255);
|
||||
}
|
||||
|
||||
private void darkColor()
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255 - 0.3F, (float) ConfigSkin.getBackgroundGreen() / 255 - 0.3F, (float) ConfigSkin.getBackgroundBlue() / 255 - 0.3F, (float) ConfigSkin.getBackgroundAlpha() / 255);
|
||||
}
|
||||
|
||||
private void bindBackground()
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getBackgroundTexture());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getSplash()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
|
||||
if(day == 12 && month == 24)
|
||||
{
|
||||
return "Merry X-mas!";
|
||||
}
|
||||
else if(day == 1 && month == 1)
|
||||
{
|
||||
return "Happy new year!";
|
||||
}
|
||||
else if(day == 10 && month == 31)
|
||||
{
|
||||
return "OOoooOOOoooo! Spooky!";
|
||||
}
|
||||
else if(day == 3 && month == 28)
|
||||
{
|
||||
return (calendar.get(Calendar.YEAR) - 2013) + " Years of World Handler!";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
//DEFAULT BACKGROUND
|
||||
|
||||
if(ConfigSkin.isBackgroundDrawingEnabled())
|
||||
{
|
||||
super.drawDefaultBackground();
|
||||
}
|
||||
|
||||
//COLOR
|
||||
|
||||
this.defaultColor();
|
||||
|
||||
//BACKGROUND
|
||||
|
||||
this.bindBackground();
|
||||
this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
|
||||
|
||||
//TABS
|
||||
|
||||
this.forEachTab((index, xOffset) ->
|
||||
{
|
||||
IContent tab = this.content.getCategory().getContent(index);
|
||||
int yOffset;
|
||||
int fHeight;
|
||||
int color;
|
||||
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
yOffset = -22;
|
||||
fHeight = 25;
|
||||
color = 0xFFFFFF;
|
||||
this.defaultColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
yOffset = -20;
|
||||
fHeight = 20;
|
||||
color = 0xE0E0E0;
|
||||
this.darkColor();
|
||||
}
|
||||
|
||||
this.bindBackground();
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
|
||||
this.drawTexturedModalRect((int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
|
||||
|
||||
if(!ConfigSkin.areSharpEdgesEnabled())
|
||||
{
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
//RIGHT TAB CURVATURE
|
||||
|
||||
if(index < this.tabSize - 1 || this.tabSize == 1)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect((int)(backgroundX + this.tabWidth + xOffset - x - 1), (int)(backgroundY + x + 1), (int)(this.tabWidth - x - 1), x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//LEFT TAB CURVATURE
|
||||
|
||||
if(index > 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int width = (int)(this.tabWidth - 3);
|
||||
int interval = 5;
|
||||
|
||||
//LEFT GRADIENT
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT GRADIENT
|
||||
|
||||
if(index == this.tabSize - 1 && this.tabSize > 1)
|
||||
{
|
||||
int offset = 3;
|
||||
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.drawTexturedModalRect((int)(backgroundX + Math.ceil(xOffset) + x + offset), (int)(backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//LEFT CORNER FILLER
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT CORNER FILLER
|
||||
|
||||
if(index == this.tabSize - 1)
|
||||
{
|
||||
int factor = 3;
|
||||
|
||||
for(int x = 0; x < factor + 1; x++)
|
||||
{
|
||||
this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY - 13), color);
|
||||
});
|
||||
|
||||
this.defaultColor();
|
||||
|
||||
//VERSION LABEL
|
||||
|
||||
final int hexAlpha = (int) (0xFF * 0.2) << 24;
|
||||
final int color = ConfigSkin.getLabelColor() + hexAlpha;
|
||||
|
||||
this.fontRenderer.drawString(Main.MC_VERSION + "-" + Main.VERSION, this.width - this.fontRenderer.getStringWidth(Main.MC_VERSION + "-" + Main.VERSION) - 2, this.height - 10, color);
|
||||
|
||||
//TITLE
|
||||
|
||||
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
|
||||
this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, ConfigSkin.getLabelColor());
|
||||
|
||||
//HEADLINE
|
||||
|
||||
if(this.content.getHeadline() != null)
|
||||
{
|
||||
if(this.content.getHeadline().length > 0)
|
||||
{
|
||||
this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
|
||||
if(this.content.getHeadline().length > 1)
|
||||
{
|
||||
this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
}
|
||||
|
||||
//NAME FIELD
|
||||
|
||||
final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
|
||||
this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, ConfigSkin.getLabelColor());
|
||||
|
||||
//WATCH
|
||||
|
||||
if(ConfigSettings.isWatchEnabled())
|
||||
{
|
||||
final int watchX = backgroundX + 233;
|
||||
final int watchY = backgroundY + 5;
|
||||
|
||||
UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getMinecraft().world.getWorldInfo().getWorldTime(), ConfigSettings.isSmoothWatchEnabled());
|
||||
|
||||
if(ConfigSettings.areTooltipsEnabled())
|
||||
{
|
||||
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
|
||||
{
|
||||
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BUTTONS
|
||||
|
||||
for(int x = 0; x < this.buttonList.size(); x++)
|
||||
{
|
||||
this.buttonList.get(x).drawButton(this.mc, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
for(int x = 0; x < this.labelList.size(); x++)
|
||||
{
|
||||
this.labelList.get(x).drawLabel(this.mc, mouseX, mouseY);
|
||||
}
|
||||
|
||||
//CONTAINER
|
||||
|
||||
this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
|
||||
|
||||
//CONTAINER ELEMENTS
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.draw();
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.drawTextBox();
|
||||
}
|
||||
|
||||
//SPLASHTEXT
|
||||
|
||||
if(this.splash != null)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
|
||||
GlStateManager.rotate(17.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
|
||||
scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
|
||||
this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
//TOOLTIPS
|
||||
|
||||
if(ConfigSettings.areTooltipsEnabled())
|
||||
{
|
||||
for(int x = 0; x < this.buttonList.size(); x++)
|
||||
{
|
||||
if(this.buttonList.get(x) instanceof GuiButtonWorldHandler)
|
||||
{
|
||||
((GuiButtonWorldHandler) this.buttonList.get(x)).drawTooltip(mouseX, mouseY, this.width, this.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char charTyped, int keyCode) throws IOException
|
||||
{
|
||||
super.keyTyped(charTyped, keyCode);
|
||||
|
||||
this.content.keyTyped(this, charTyped, keyCode);
|
||||
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.textboxKeyTyped(charTyped, keyCode);
|
||||
WorldHandler.USERNAME = this.nameField.getText();
|
||||
this.updateNameField();
|
||||
}
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.textboxKeyTyped(charTyped, keyCode);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.keyTyped(this, charTyped, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
this.content.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
this.content.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
return ConfigSettings.isPauseEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer()
|
||||
{
|
||||
return WorldHandler.USERNAME;
|
||||
}
|
||||
}
|
||||
111
src/main/java/exopandora/worldhandler/gui/content/Content.java
Normal file
111
src/main/java/exopandora/worldhandler/gui/content/Content.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcher;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContainers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentCustomItem;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentEditBlocks;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentEnchantment;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentExperience;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentGamerules;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentMain;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentMultiplayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentNoteEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPotions;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSummon;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Content implements IContent
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Content> REGISTRY = new RegistryNamespaced<ResourceLocation, Content>();
|
||||
|
||||
public static void registerContents()
|
||||
{
|
||||
//MAIN
|
||||
registerContent(0, "main", new ContentMain());
|
||||
registerContent(1, "containers", new ContentContainers());
|
||||
registerContent(2, "multiplayer", new ContentMultiplayer());
|
||||
|
||||
//ENTITIES
|
||||
registerContent(3, "summon", new ContentSummon());
|
||||
|
||||
//ITEMS
|
||||
registerContent(5, "custom_item", new ContentCustomItem());
|
||||
registerContent(4, "enchantment", new ContentEnchantment());
|
||||
|
||||
//BLOCKS
|
||||
registerContent(6, "edit_blocks", new ContentEditBlocks());
|
||||
registerContent(7, "sign_editor", new ContentSignEditor());
|
||||
registerContent(8, "note_editor", new ContentNoteEditor());
|
||||
|
||||
//WORLD
|
||||
registerContent(9, "world", new ContentWorldInfo());
|
||||
registerContent(10, "gamerules", new ContentGamerules());
|
||||
|
||||
//PLAYER
|
||||
registerContent(11, "player", new ContentPlayer());
|
||||
registerContent(12, "experience", new ContentExperience());
|
||||
registerContent(13, "advancements", new ContentAdvancements());
|
||||
|
||||
//SCOREBOARD
|
||||
registerContent(14, "scoreboard_objectives", new ContentScoreboardObjectives());
|
||||
registerContent(15, "scoreboard_teams", new ContentScoreboardTeams());
|
||||
registerContent(16, "scoreboard_players", new ContentScoreboardPlayers());
|
||||
|
||||
//MISC
|
||||
registerContent(17, "change_world", new ContentChangeWorld());
|
||||
registerContent(18, "continue", new ContentContinue());
|
||||
|
||||
//NO CATEGORY
|
||||
registerContent(19, "potions", new ContentPotions());
|
||||
registerContent(20, "butcher", new ContentButcher());
|
||||
}
|
||||
|
||||
private static void registerContent(int id, String textualID, Content content)
|
||||
{
|
||||
registerContent(id, new ResourceLocation(Main.MODID, textualID), content);
|
||||
}
|
||||
|
||||
private static void registerContent(int id, ResourceLocation textualID, Content content)
|
||||
{
|
||||
REGISTRY.register(id, textualID, content);
|
||||
}
|
||||
|
||||
private Map<Object, ButtonStorage> storage;
|
||||
|
||||
public <T> ButtonStorage<T> getStorage(Object id)
|
||||
{
|
||||
if(this.storage == null)
|
||||
{
|
||||
this.storage = new HashMap<Object, ButtonStorage>();
|
||||
}
|
||||
|
||||
if(this.storage.containsKey(id))
|
||||
{
|
||||
return this.storage.get(id);
|
||||
}
|
||||
|
||||
ButtonStorage<T> storage = new ButtonStorage<T>();
|
||||
|
||||
this.storage.put(id, storage);
|
||||
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Contents
|
||||
{
|
||||
public static final Content MAIN;
|
||||
public static final Content CONTAINERS;
|
||||
public static final Content MULTIPLAYER;
|
||||
|
||||
public static final Content SUMMON;
|
||||
|
||||
public static final Content CUSTOM_ITEM;
|
||||
public static final Content ENCHANTMENT;
|
||||
|
||||
public static final Content EDIT_BLOCKS;
|
||||
public static final Content SIGN_EDITOR;
|
||||
public static final Content NOTE_EDITOR;
|
||||
|
||||
public static final Content WORLD_INFO;
|
||||
public static final Content GAMERULES;
|
||||
|
||||
public static final Content PLAYER;
|
||||
public static final Content EXPERIENCE;
|
||||
public static final Content ADVANCEMENTS;
|
||||
|
||||
public static final Content SCOREBOARD_OBJECTIVES;
|
||||
public static final Content SCOREBOARD_TEAMS;
|
||||
public static final Content SCOREBOARD_PLAYERS;
|
||||
|
||||
public static final ContentChild CHANGE_WORLD;
|
||||
public static final ContentContinue CONTINUE;
|
||||
|
||||
public static final ContentChild POTIONS;
|
||||
public static final ContentChild BUTCHER;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Contents.getRegisteredContainer("main");
|
||||
CONTAINERS = Contents.getRegisteredContainer("containers");
|
||||
MULTIPLAYER = Contents.getRegisteredContainer("multiplayer");
|
||||
|
||||
SUMMON = Contents.getRegisteredContainer("summon");
|
||||
|
||||
CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item");
|
||||
ENCHANTMENT = Contents.getRegisteredContainer("enchantment");
|
||||
|
||||
EDIT_BLOCKS = Contents.getRegisteredContainer("edit_blocks");
|
||||
SIGN_EDITOR = Contents.getRegisteredContainer("sign_editor");
|
||||
NOTE_EDITOR = Contents.getRegisteredContainer("note_editor");
|
||||
|
||||
WORLD_INFO = Contents.getRegisteredContainer("world");
|
||||
GAMERULES = Contents.getRegisteredContainer("gamerules");
|
||||
|
||||
PLAYER = Contents.getRegisteredContainer("player");
|
||||
EXPERIENCE = Contents.getRegisteredContainer("experience");
|
||||
ADVANCEMENTS = Contents.getRegisteredContainer("advancements");
|
||||
|
||||
SCOREBOARD_OBJECTIVES = Contents.getRegisteredContainer("scoreboard_objectives");
|
||||
SCOREBOARD_TEAMS = Contents.getRegisteredContainer("scoreboard_teams");
|
||||
SCOREBOARD_PLAYERS = Contents.getRegisteredContainer("scoreboard_players");
|
||||
|
||||
CHANGE_WORLD = Contents.getRegisteredContainer("change_world");
|
||||
CONTINUE = Contents.getRegisteredContainer("continue");
|
||||
|
||||
POTIONS = Contents.getRegisteredContainer("potions");
|
||||
BUTCHER = Contents.getRegisteredContainer("butcher");
|
||||
}
|
||||
|
||||
private static <T extends Content> T getRegisteredContainer(String name)
|
||||
{
|
||||
Content container = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(container == null)
|
||||
{
|
||||
throw new IllegalStateException("Invalid Container requested: " + name);
|
||||
}
|
||||
|
||||
return (T) container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IContent
|
||||
{
|
||||
default void initGui(Container container, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void initButtons(Container container, int x, int y);
|
||||
|
||||
default void updateScreen(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void onPlayerNameChanged(String username)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Category getCategory();
|
||||
|
||||
String getTitle();
|
||||
String getTabTitle();
|
||||
|
||||
Content getActiveContent();
|
||||
|
||||
@Nullable
|
||||
default Content getBackContent()
|
||||
{
|
||||
return Contents.MAIN;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String[] getHeadline()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
default void onGuiClosed()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package exopandora.worldhandler.gui.content.element;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Element implements IElement
|
||||
{
|
||||
protected int x;
|
||||
protected int y;
|
||||
|
||||
public Element(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package exopandora.worldhandler.gui.content.element;
|
||||
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IElement
|
||||
{
|
||||
void initGui(Container container);
|
||||
void initButtons(Container container);
|
||||
void draw();
|
||||
boolean actionPerformed(Container container, GuiButton button);
|
||||
|
||||
default void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.helper.Node;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ElementClickList extends Element
|
||||
{
|
||||
private final int buttonId1;
|
||||
private final int buttonId2;
|
||||
private final List<Node> list;
|
||||
private final ILogicClickList logic;
|
||||
private GuiButtonList button1;
|
||||
private GuiButtonList button2;
|
||||
private final Content master;
|
||||
|
||||
public ElementClickList(int x, int y, List<Node> list, int buttonId1, int buttonId2, Content container, ILogicClickList logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.buttonId1 = buttonId1;
|
||||
this.buttonId2 = buttonId2;
|
||||
this.logic = logic;
|
||||
this.master = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
container.add(this.button1 = new GuiButtonList(this.buttonId1, this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.master, new IListButtonLogic<Node>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonStorage<Node> storage)
|
||||
{
|
||||
master.getStorage(listButtonLogic2.getId()).setIndex(0);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getObject(int index)
|
||||
{
|
||||
return list.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage<Node> storage)
|
||||
{
|
||||
return logic.translate1(storage.getObject().getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipString(ButtonStorage<Node> storage)
|
||||
{
|
||||
if(storage != null && storage.getObject() != null)
|
||||
{
|
||||
return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return logic.getId() + 1;
|
||||
}
|
||||
}));
|
||||
|
||||
final Node node = this.getStorage1().getObject();
|
||||
this.logic.consumeKey1(node.getKey());
|
||||
|
||||
if(node.getEntries() != null)
|
||||
{
|
||||
container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2));
|
||||
this.logic.consumeKey2(node.getKey(), node.getEntries().get(this.getStorage2().getIndex()).getKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(this.button2 = new GuiButtonList(this.buttonId2, this.x, this.y + 24, 114, 20, EnumTooltip.TOP_RIGHT, this.master, this.listButtonLogic2));
|
||||
this.button2.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private final IListButtonLogic<Node> listButtonLogic2 = new IListButtonLogic<Node>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonStorage<Node> storage)
|
||||
{
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
if(getStorage1().getObject() != null)
|
||||
{
|
||||
return getStorage1().getObject().getEntries().size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getObject(int index)
|
||||
{
|
||||
if(getStorage1().getObject().getEntries() != null)
|
||||
{
|
||||
return getStorage1().getObject().getEntries().get(index);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage<Node> storage)
|
||||
{
|
||||
if(storage.getObject() != null)
|
||||
{
|
||||
return logic.translate2(getStorage1().getObject().getKey(), storage.getObject().getKey());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipString(ButtonStorage<Node> storage)
|
||||
{
|
||||
if(getStorage1().getObject().getEntries() != null)
|
||||
{
|
||||
return storage.getObject().getKey() + " (" + (storage.getIndex() + 1) + "/" + getStorage1().getObject().getEntries().size() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return logic.getId() + 2;
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
private ButtonStorage<Node> getStorage1()
|
||||
{
|
||||
if(this.button1 != null)
|
||||
{
|
||||
return this.master.<Node>getStorage(this.button1.getLogic().getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ButtonStorage<Node> getStorage2()
|
||||
{
|
||||
if(this.button2 != null)
|
||||
{
|
||||
return this.master.<Node>getStorage(this.button2.getLogic().getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.buttonId1)
|
||||
{
|
||||
this.button1.actionPerformed(container, button);
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.buttonId2)
|
||||
{
|
||||
this.button2.actionPerformed(container, button);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.logic.ColorListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicColorMenu;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
public class ElementColorMenu extends Element
|
||||
{
|
||||
private GuiTextFieldTooltip textField;
|
||||
private GuiButtonList colorList;
|
||||
private final Content content;
|
||||
private final ColoredString string;
|
||||
private final int[] ids;
|
||||
private final ILogicColorMenu logic;
|
||||
private final String translationKey;
|
||||
|
||||
public ElementColorMenu(Content content, int x, int y, String translationKey, ColoredString string, int[] ids)
|
||||
{
|
||||
this(content, x, y, translationKey, string, ids, new ILogicColorMenu(){});
|
||||
}
|
||||
|
||||
public ElementColorMenu(Content content, int x, int y, String translationKey, ColoredString string, int[] ids, ILogicColorMenu logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.content = content;
|
||||
this.translationKey = translationKey;
|
||||
this.string = string;
|
||||
this.ids = ids;
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
if(this.logic.drawTextfield())
|
||||
{
|
||||
this.textField = new GuiTextFieldTooltip(this.x + 118, this.y, 114, 20, I18n.format(this.translationKey));
|
||||
this.textField.setValidator(this.logic.getValidator());
|
||||
this.textField.setText(this.string.getTextFieldString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
if(this.logic.drawButtons())
|
||||
{
|
||||
container.add(this.colorList = new GuiButtonList(this.ids[0], this.x + 118, this.y + 24, 114, 20, this.content, new ColorListButtonLogic()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonStorage<Integer> storage)
|
||||
{
|
||||
string.setColor(storage.getIndex());
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(this.ids[1], this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? ChatFormatting.ITALIC : ChatFormatting.RESET) + "I"));
|
||||
container.add(new GuiButtonWorldHandler(this.ids[2], this.x + 118 + 24 - 1, this.y + 48, 20, 20, (this.string.isBold() ? ChatFormatting.BOLD : ChatFormatting.RESET) + "B"));
|
||||
container.add(new GuiButtonWorldHandler(this.ids[3], this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, (this.string.isUnderlined() ? ChatFormatting.UNDERLINE : ChatFormatting.RESET) + "U"));
|
||||
container.add(new GuiButtonWorldHandler(this.ids[4], this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, (this.string.isStriked() ? ChatFormatting.STRIKETHROUGH : ChatFormatting.RESET) + "S"));
|
||||
container.add(new GuiButtonWorldHandler(this.ids[5], this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, (this.string.isObfuscated() ? ChatFormatting.OBFUSCATED : ChatFormatting.RESET) + "O"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.ids[0])
|
||||
{
|
||||
this.colorList.actionPerformed(container, button);
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
this.string.setItalic(!this.string.isItalic());
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[2])
|
||||
{
|
||||
this.string.setBold(!this.string.isBold());
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[3])
|
||||
{
|
||||
this.string.setUnderlined(!this.string.isUnderlined());
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[4])
|
||||
{
|
||||
this.string.setStriked(!this.string.isStriked());
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[5])
|
||||
{
|
||||
this.string.setObfuscated(!this.string.isObfuscated());
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
if(this.logic.drawTextfield())
|
||||
{
|
||||
this.textField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
if(this.logic.drawTextfield())
|
||||
{
|
||||
if(this.textField.canType(charTyped))
|
||||
{
|
||||
if(this.textField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.string.setText(this.textField.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.logic.drawTextfield())
|
||||
{
|
||||
this.textField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
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.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 ButtonStorage<Integer> storage;
|
||||
|
||||
public ElementPageList(int x, int y, List<T> list, K initial, int width, int height, int length, Content container, 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.storage = container.getStorage(logic.getId());
|
||||
this.ids = ids;
|
||||
|
||||
this.list.sort((a, b) -> this.logic.translate(a).compareTo(this.logic.translate(b)));
|
||||
|
||||
if(this.storage.getObject() == null)
|
||||
{
|
||||
this.storage.setObject(0);
|
||||
this.storage.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.storage.getObject() > 0;
|
||||
right.enabled = this.storage.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.storage.getObject() * length + x;
|
||||
|
||||
if(index < this.list.size())
|
||||
{
|
||||
T entry = this.list.get(index);
|
||||
this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.storage.getIndex() != index, entry, container);
|
||||
}
|
||||
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])
|
||||
{
|
||||
this.storage.setObject(this.storage.getObject() - 1);
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
this.storage.setObject(this.storage.getObject() + 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.storage.setIndex(x);
|
||||
this.logic.onClick(entry);
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawString((this.storage.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, 0x4F4F4F);
|
||||
}
|
||||
|
||||
private int getTotalPages()
|
||||
{
|
||||
return (int) Math.ceil((float) this.list.size() / this.length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogicClickList
|
||||
{
|
||||
void consumeKey1(String key);
|
||||
|
||||
default void consumeKey2(String key1, String key2)
|
||||
{
|
||||
this.consumeKey1(key1 + "." + key2);
|
||||
}
|
||||
|
||||
String translate1(String key);
|
||||
|
||||
default String translate2(String key1, String key2)
|
||||
{
|
||||
return this.translate1(key2);
|
||||
}
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
public interface ILogicColorMenu
|
||||
{
|
||||
default Predicate<String> getValidator()
|
||||
{
|
||||
return Predicates.notNull();
|
||||
}
|
||||
|
||||
default boolean drawTextfield()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean drawButtons()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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>
|
||||
{
|
||||
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);
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
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.storage.ButtonStorage;
|
||||
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 exopandora.worldhandler.main.WorldHandler;
|
||||
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 = StreamSupport.stream(new AdvancementManager(null).getAdvancements().spliterator(), true).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, ButtonStorage<EnumMode> storage)
|
||||
{
|
||||
builderAdvancement.setMode(storage.getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
return this.values.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMode getObject(int index)
|
||||
{
|
||||
return this.values[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage<EnumMode> storage)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.advancements." + storage.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 String[] getHeadline()
|
||||
{
|
||||
return new String[] {null, I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.ADVANCEMENTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderAdvancement.setPlayer(username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.config.ConfigButcher;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.config.GuiConfigWorldHandler;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentButcher extends ContentChild
|
||||
{
|
||||
private GuiTextFieldTooltip radiusField;
|
||||
private String radius;
|
||||
private final BuilderButcher builderButcher = new BuilderButcher();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderButcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.radiusField = new GuiTextFieldTooltip(x + 116 / 2, y + 12, 116, 20, I18n.format("gui.worldhandler.butcher.radius"));
|
||||
this.radiusField.setValidator(string -> string != null && string.matches("[0-9]*"));
|
||||
this.radiusField.setText(this.radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler slaughter;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(3, x + 116 / 2, y + 36, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.configure")));
|
||||
container.add(slaughter = new GuiButtonWorldHandler(2, x + 116 / 2, y + 60, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.slaughter")));
|
||||
|
||||
slaughter.enabled = this.radius != null && this.radius.matches("[0-9]+");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
for(ResourceLocation entity : EntityList.ENTITY_EGGS.keySet())
|
||||
{
|
||||
if(ConfigButcher.getEntitiyMap().get(EntityHelper.getEntityName(entity)))
|
||||
{
|
||||
WorldHandler.sendCommand(new BuilderButcher(entity, Integer.valueOf(this.radius)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiConfigWorldHandler(container, ConfigButcher.CATEGORY));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.radiusField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.butcher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.radiusField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.radius = this.radiusField.getText();
|
||||
|
||||
if(this.radius.length() > 0)
|
||||
{
|
||||
this.builderButcher.setRadius(Integer.valueOf(this.radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderButcher.setRadius(0);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.radiusField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiWorldSelection;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentChangeWorld extends ContentChild
|
||||
{
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x + 116 / 2, y + 24, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.singleplayer")));
|
||||
container.add(new GuiButtonWorldHandler(3, x + 116 / 2, y + 48, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.multiplayer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldSelection(container));
|
||||
break;
|
||||
case 3:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(container));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.change_world");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderGive;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetblock;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentContainers extends Content
|
||||
{
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(1, x, y + 96, 232, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(3, x + 24, y, 208, 20, Blocks.CRAFTING_TABLE.getLocalizedName()));
|
||||
container.add(new GuiButtonWorldHandler(4, x + 24, y + 24, 208, 20, Blocks.ENDER_CHEST.getLocalizedName()));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 24, y + 48, 208, 20, Blocks.ANVIL.getLocalizedName()));
|
||||
container.add(new GuiButtonWorldHandler(6, x + 24, y + 72, 208, 20, Blocks.ENCHANTING_TABLE.getLocalizedName()));
|
||||
|
||||
container.add(new GuiButtonItem(7, x, y, 20, 20, new ItemStack(Blocks.CRAFTING_TABLE)));
|
||||
container.add(new GuiButtonItem(8, x, y + 24, 20, 20, new ItemStack(Blocks.ENDER_CHEST)));
|
||||
container.add(new GuiButtonItem(9, x, y + 48, 20, 20, new ItemStack(Blocks.ANVIL)));
|
||||
container.add(new GuiButtonItem(10, x, y + 72, 20, 20, new ItemStack(Blocks.ENCHANTING_TABLE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
BlockHelper.setBlockNearPlayer(Blocks.CRAFTING_TABLE, (byte) 0, (byte) 0, (byte) 0, (byte) 0);
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 4:
|
||||
BlockHelper.setBlockNearPlayer(Blocks.ENDER_CHEST, (byte) 2, (byte) 5, (byte) 3, (byte) 4);
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 5:
|
||||
BlockHelper.setBlockNearPlayer(Blocks.ANVIL, (byte) 1, (byte) 0, (byte) 1, (byte) 0);
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 6:
|
||||
BlockHelper.setBlockNearPlayer(Blocks.ENCHANTING_TABLE, (byte) 0, (byte) 0, (byte) 0, (byte) 0);
|
||||
|
||||
int direction = MathHelper.floor((double) (Minecraft.getMinecraft().player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
double angle = direction * Math.PI / 2;
|
||||
double sin = Math.sin(angle);
|
||||
double cos = Math.cos(angle);
|
||||
|
||||
for(int x = -2; x <= 2; x++)
|
||||
{
|
||||
for(int y = 0; y <= 1; y++)
|
||||
{
|
||||
for(int z = 1; z <= 4; z++)
|
||||
{
|
||||
if(!(x >= -1 && x <= 1 && z < 4))
|
||||
{
|
||||
WorldHandler.sendCommand(new BuilderSetblock(new Coordinate(x * cos - z * sin, true), new Coordinate(y, true), new Coordinate(x * sin + z * cos, true), Blocks.BOOKSHELF.getRegistryName(), ConfigSettings.getMode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 7:
|
||||
WorldHandler.sendCommand(new BuilderGive(container.getPlayer(), Blocks.CRAFTING_TABLE.getRegistryName()));
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ENDER_CHEST.getRegistryName()));
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ANVIL.getRegistryName()));
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ENCHANTING_TABLE.getRegistryName()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.MAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.containers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.containers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.CONTAINERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getBackContent()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
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 ContentContinue extends ContentChild
|
||||
{
|
||||
private ICommandBuilder builder;
|
||||
private GuiTextFieldTooltip commandField;
|
||||
private boolean special;
|
||||
|
||||
public ContentContinue withBuilder(ICommandBuilder builder)
|
||||
{
|
||||
return this.withBuilder(builder, false);
|
||||
}
|
||||
|
||||
public ContentContinue withBuilder(ICommandBuilder builder, boolean special)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.special = special;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.commandField = new GuiTextFieldTooltip(x + 116 / 2, y + 12, 116, 20);
|
||||
this.commandField.setFocused(false);
|
||||
|
||||
if(this.builder instanceof ICommandBuilderSyntax)
|
||||
{
|
||||
this.commandField.setText(((ICommandBuilderSyntax) this.builder).toActualCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.commandField.setText(this.builder.toCommand());
|
||||
}
|
||||
|
||||
this.commandField.setCursorPositionZero();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x + 116 / 2, y + 36, 116, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.generic.yes")));
|
||||
container.add(new GuiButtonWorldHandler(0, x + 116 / 2, y + 60, 116, 20, I18n.format("gui.worldhandler.generic.no")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builder, this.special);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.parent));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.commandField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[]{I18n.format("gui.worldhandler.continue.question")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(keyCode == Keyboard.KEY_RIGHT || keyCode == Keyboard.KEY_LEFT)
|
||||
{
|
||||
this.commandField.textboxKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.commandField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.parent.getTitle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
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.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 exopandora.worldhandler.main.WorldHandler;
|
||||
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;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderCutomItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.item_id"));
|
||||
this.itemField.setValidator(Predicates.<String>notNull());
|
||||
this.itemField.setText(this.item);
|
||||
|
||||
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.lore_1"));
|
||||
this.itemLore1Field.setValidator(Predicates.<String>notNull());
|
||||
this.itemLore1Field.setText(this.builderCutomItem.getLore1());
|
||||
|
||||
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.start.lore_2"));
|
||||
this.itemLore2Field.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.give_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, 100, 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, Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.PLAYER).stream()).collect(Collectors.toList()), null, 114, 20, 3, this, new int[] {13, 14, 15}, new ILogicPageList<EnumAttributes, Object>()
|
||||
{
|
||||
@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, value.getMin(), value.getMax(), value.getStart(), 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.give_custom_item.start")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.enchantment")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.give_custom_item.attributes")));
|
||||
|
||||
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.give_custom_item.give_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.give_custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.items.give_custom_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
String[] headline = new String[2];
|
||||
|
||||
headline[0] = I18n.format("gui.worldhandler.generic.browse");
|
||||
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
headline[1] = I18n.format("gui.worldhandler.generic.options");
|
||||
}
|
||||
|
||||
return headline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.CUSTOM_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderCutomItem.setPlayer(username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWH;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.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.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
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 ContentEditBlocks extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip x1Field;
|
||||
private GuiTextFieldTooltip y1Field;
|
||||
private GuiTextFieldTooltip z1Field;
|
||||
|
||||
private GuiTextFieldTooltip x2Field;
|
||||
private GuiTextFieldTooltip y2Field;
|
||||
private GuiTextFieldTooltip z2Field;
|
||||
|
||||
private GuiTextFieldTooltip block1Field;
|
||||
private GuiTextFieldTooltip block2Field;
|
||||
|
||||
private final BuilderFill builderFill = new BuilderFill().addPositionObservers();
|
||||
private final BuilderClone builderClone = new BuilderClone().addPositionObservers();
|
||||
private final BuilderWH builderWH = new BuilderWH();
|
||||
|
||||
private String block1;
|
||||
private String block2;
|
||||
|
||||
private GuiButtonList cloneButton;
|
||||
|
||||
private String selectedPage = "coordinates";
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
return this.builderWH;
|
||||
}
|
||||
else if(this.selectedPage.equals("fill") || this.selectedPage.equals("replace"))
|
||||
{
|
||||
return this.builderFill;
|
||||
}
|
||||
else if(this.selectedPage.equals("clone"))
|
||||
{
|
||||
return this.builderClone;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.x1Field = new GuiTextFieldTooltip(x + 118, y, 55, 20);
|
||||
this.x1Field.setValidator(this.getCoordinatePredicate("X1"));
|
||||
this.x1Field.setText("X1: " + BlockHelper.getPos1().getX());
|
||||
|
||||
this.y1Field = new GuiTextFieldTooltip(x + 118, y + 24, 55, 20);
|
||||
this.y1Field.setValidator(this.getCoordinatePredicate("Y1"));
|
||||
this.y1Field.setText("Y1: " + BlockHelper.getPos1().getY());
|
||||
|
||||
this.z1Field = new GuiTextFieldTooltip(x + 118, y + 48, 55, 20);
|
||||
this.z1Field.setValidator(this.getCoordinatePredicate("Z1"));
|
||||
this.z1Field.setText("Z1: " + BlockHelper.getPos1().getZ());
|
||||
|
||||
this.x2Field = new GuiTextFieldTooltip(x + 118 + 59, y, 55, 20);
|
||||
this.x2Field.setValidator(this.getCoordinatePredicate("X2"));
|
||||
this.x2Field.setText("X2: " + BlockHelper.getPos2().getX());
|
||||
|
||||
this.y2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 24, 55, 20);
|
||||
this.y2Field.setValidator(this.getCoordinatePredicate("Y2"));
|
||||
this.y2Field.setText("Y2: " + BlockHelper.getPos2().getY());
|
||||
|
||||
this.z2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 48, 55, 20);
|
||||
this.z2Field.setValidator(this.getCoordinatePredicate("Z2"));
|
||||
this.z2Field.setText("Z2: " + BlockHelper.getPos2().getZ());
|
||||
|
||||
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, this.selectedPage.equals("fill") ? I18n.format("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : I18n.format("gui.worldhandler.edit_blocks.replace.block_id_replace"));
|
||||
this.block1Field.setValidator(Predicates.notNull());
|
||||
this.block1Field.setText(this.block1);
|
||||
|
||||
this.block2Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace.block_id_place"));
|
||||
this.block2Field.setValidator(Predicates.notNull());
|
||||
this.block2Field.setText(this.block2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
|
||||
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(2, x, y, 114, 20, I18n.format("gui.worldhandler.edit_blocks.coordinates")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(3, x, y + 24, 114, 20, I18n.format("gui.worldhandler.edit_blocks.fill")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(4, x, y + 48, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(5, x, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone")));
|
||||
|
||||
int yOffset1 = 0;
|
||||
int yOffset2 = 0;
|
||||
int xOffset2 = 0;
|
||||
int width1 = 0;
|
||||
int width2 = 0;
|
||||
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
|
||||
yOffset1 = 72;
|
||||
yOffset2 = 72;
|
||||
width1 = 56;
|
||||
width2 = 56;
|
||||
xOffset2 = 58;
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
|
||||
yOffset1 = 24;
|
||||
yOffset2 = 48;
|
||||
width1 = 114;
|
||||
width2 = 114;
|
||||
xOffset2 = 0;
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(10, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.fill")));
|
||||
button3.enabled = ResourceHelper.isRegisteredBlock(this.builderFill.getBlock1String());
|
||||
}
|
||||
else if(this.selectedPage.equals("replace"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
|
||||
yOffset1 = 48;
|
||||
yOffset2 = 48;
|
||||
width1 = 56;
|
||||
width2 = 56;
|
||||
xOffset2 = 58;
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(8, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace")));
|
||||
button3.enabled = ResourceHelper.isRegisteredBlock(this.builderFill.getBlock1String()) && ResourceHelper.isRegisteredBlock(this.builderFill.getBlock2String());
|
||||
}
|
||||
else if(this.selectedPage.equals("clone"))
|
||||
{
|
||||
button6.enabled = false;
|
||||
|
||||
yOffset1 = 24;
|
||||
yOffset2 = 48;
|
||||
width1 = 114;
|
||||
width2 = 114;
|
||||
xOffset2 = 0;
|
||||
|
||||
container.add(this.cloneButton = new GuiButtonList(9, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic<EnumMask>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonStorage<EnumMask> storage)
|
||||
{
|
||||
builderClone.setMask(storage.getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
{
|
||||
return EnumMask.values().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMask getObject(int index)
|
||||
{
|
||||
return EnumMask.values()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage<EnumMask> storage)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + storage.getObject().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "mask";
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(11, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone")));
|
||||
}
|
||||
|
||||
container.add(new GuiButtonWorldHandler(6, x + 118, y + yOffset1, width1, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_1")));
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118 + xOffset2, y + yOffset2, width2, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_2")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.selectedPage = "coordinates";
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
this.selectedPage = "fill";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedPage = "replace";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedPage = "clone";
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(this.builderFill.getBuilderForReplace());
|
||||
break;
|
||||
case 9:
|
||||
this.cloneButton.actionPerformed(container, button);
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderFill.getBuilderForFill());
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderClone);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
this.x1Field.drawTextBox();
|
||||
this.y1Field.drawTextBox();
|
||||
this.z1Field.drawTextBox();
|
||||
|
||||
this.x2Field.drawTextBox();
|
||||
this.y2Field.drawTextBox();
|
||||
this.z2Field.drawTextBox();
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
this.block1Field.drawTextBox();
|
||||
}
|
||||
else if(this.selectedPage.equals("replace"))
|
||||
{
|
||||
this.block1Field.drawTextBox();
|
||||
this.block2Field.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.x1Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), this.filterCoordinateText(this.x1Field.getText())));
|
||||
}
|
||||
|
||||
if(this.y1Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), this.filterCoordinateText(this.y1Field.getText())));
|
||||
}
|
||||
|
||||
if(this.z1Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), this.filterCoordinateText(this.z1Field.getText())));
|
||||
}
|
||||
|
||||
if(this.x2Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), this.filterCoordinateText(this.x2Field.getText())));
|
||||
}
|
||||
|
||||
if(this.y2Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), this.filterCoordinateText(this.y2Field.getText())));
|
||||
}
|
||||
|
||||
if(this.z2Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), this.filterCoordinateText(this.z2Field.getText())));
|
||||
}
|
||||
|
||||
if(this.block1Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.block1 = this.block1Field.getText();
|
||||
this.builderFill.setBlock1(this.block1);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.block2Field.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.block2 = this.block2Field.getText();
|
||||
this.builderFill.setBlock2(this.block2);
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
this.x1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.y1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.z1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.x2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.y2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.z2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
this.block1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
else if(this.selectedPage.equals("replace"))
|
||||
{
|
||||
this.block1Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.block2Field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate<String> getCoordinatePredicate(String coordinate)
|
||||
{
|
||||
return string -> string.matches(coordinate + ": [-]?[0-9]*");
|
||||
}
|
||||
|
||||
private int filterCoordinateText(String input)
|
||||
{
|
||||
if(input != null)
|
||||
{
|
||||
String[] split = input.split(": ", 2);
|
||||
|
||||
if(split[1].matches("[-]?[0-9]+"))
|
||||
{
|
||||
return Integer.parseInt(split[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.BLOCKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.blocks.edit_blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.blocks.edit_blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.EDIT_BLOCKS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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 exopandora.worldhandler.main.WorldHandler;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderExperience;
|
||||
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.main.WorldHandler;
|
||||
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 ContentExperience extends Content
|
||||
{
|
||||
private final BuilderExperience builderExperience = new BuilderExperience();
|
||||
private GuiButtonWorldHandler addButton;
|
||||
private GuiButtonWorldHandler removeButton;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderExperience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
container.add(new GuiSlider<String>(this, container, "experience", x + 116 / 2, y, 114, 20, I18n.format("gui.worldhandler.title.player.experience"), 0, 100, 0, new SimpleResponder<String>(value ->
|
||||
{
|
||||
this.builderExperience.setLevel(value);
|
||||
})));
|
||||
|
||||
container.add(addButton = new GuiButtonWorldHandler(3, x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add")));
|
||||
container.add(removeButton = new GuiButtonWorldHandler(4, x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove")));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 116 / 2, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderExperience);
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
if(Minecraft.getMinecraft().player.experienceLevel >= this.builderExperience.getLevel())
|
||||
{
|
||||
WorldHandler.sendCommand(new BuilderExperience(-this.builderExperience.getLevel(), this.builderExperience.getPlayer()));
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
WorldHandler.sendCommand(new BuilderExperience(-Minecraft.getMinecraft().player.experienceLevel, this.builderExperience.getPlayer()));
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.player.experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.player.experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.EXPERIENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderExperience.setPlayer(username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
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 exopandora.worldhandler.main.WorldHandler;
|
||||
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)
|
||||
{
|
||||
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 String[] getHeadline()
|
||||
{
|
||||
return new String[] {null, I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.GAMERULES;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.config.GuiConfigWorldHandler;
|
||||
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.main.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreenResourcePacks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentMain extends Content
|
||||
{
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(-1, x, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.TOP_RIGHT, EnumIcon.TIME_DAWN));
|
||||
container.add(new GuiButtonWorldHandler(-2, x + 26, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.TOP_RIGHT, EnumIcon.TIME_NOON));
|
||||
container.add(new GuiButtonWorldHandler(-3, x + 26 * 2, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.TOP_RIGHT, EnumIcon.TIME_SUNSET));
|
||||
container.add(new GuiButtonWorldHandler(-4, x + 26 * 3, y, 23, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.TOP_RIGHT, EnumIcon.TIME_MIDNIGHT));
|
||||
container.add(new GuiButtonWorldHandler(-8, x + 26 * 4, y, 24, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.TOP_RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
|
||||
container.add(new GuiButtonWorldHandler(-9, x + 26 * 5 + 2, y, 23, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.TOP_RIGHT, EnumIcon.DIFFICULTY_EASY));
|
||||
container.add(new GuiButtonWorldHandler(-10, x + 26 * 6 + 2, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.TOP_RIGHT, EnumIcon.DIFFICULTY_NORMAL));
|
||||
container.add(new GuiButtonWorldHandler(-11, x + 26 * 7 + 2, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.TOP_RIGHT, EnumIcon.DIFFICULTY_HARD));
|
||||
container.add(new GuiButtonWorldHandler(10, x + 26 * 8 + 2, y, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.settings"), EnumTooltip.TOP_RIGHT, EnumIcon.SETTINGS));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(-5, x, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.TOP_RIGHT, EnumIcon.WEATHER_SUN));
|
||||
container.add(new GuiButtonWorldHandler(-6, x + 26, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.TOP_RIGHT, EnumIcon.WEATHER_RAIN));
|
||||
container.add(new GuiButtonWorldHandler(-7, x + 26 * 2, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.TOP_RIGHT, EnumIcon.WEATHER_STORM));
|
||||
container.add(new GuiButtonWorldHandler(11, x + 26 * 3, y + 24, 23, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.butcher"), EnumTooltip.TOP_RIGHT, EnumIcon.BUTCHER));
|
||||
container.add(new GuiButtonWorldHandler(12, x + 26 * 4, y + 24, 24, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.potions"), EnumTooltip.TOP_RIGHT, EnumIcon.POTION));
|
||||
container.add(new GuiButtonWorldHandler(-12, x + 26 * 5 + 2, y + 24, 23, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.TOP_RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
|
||||
container.add(new GuiButtonWorldHandler(-13, x + 26 * 6 + 2, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.TOP_RIGHT, EnumIcon.GAMEMODE_CREATIVE));
|
||||
container.add(new GuiButtonWorldHandler(-14, x + 26 * 7 + 2, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.TOP_RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
|
||||
container.add(new GuiButtonWorldHandler(-15, x + 26 * 8 + 2, y + 24, 22, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.TOP_RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x, y + 48, 74, 20, I18n.format("gui.worldhandler.items")));
|
||||
container.add(new GuiButtonWorldHandler(3, x + 78, y + 48, 76, 20, I18n.format("gui.worldhandler.blocks")));
|
||||
container.add(new GuiButtonWorldHandler(9, x + 158, y + 48, 74, 20, I18n.format("gui.worldhandler.entities")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(7, x, y + 72, 74, 20, I18n.format("gui.worldhandler.world")));
|
||||
container.add(new GuiButtonWorldHandler(8, x + 78, y + 72, 76, 20, I18n.format("gui.worldhandler.player")));
|
||||
container.add(new GuiButtonWorldHandler(4, x + 158, y + 72, 74, 20, I18n.format("gui.worldhandler.scoreboard")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(6, x, y + 96, 74, 20, I18n.format("gui.worldhandler.change_world")));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 78, y + 96, 76, 20, I18n.format("gui.worldhandler.resourcepack")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 158, y + 96, 74, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CUSTOM_ITEM));
|
||||
break;
|
||||
case 3:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.EDIT_BLOCKS));
|
||||
break;
|
||||
case 4:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SCOREBOARD_OBJECTIVES));
|
||||
break;
|
||||
case 5:
|
||||
Minecraft.getMinecraft().gameSettings.saveOptions();
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiScreenResourcePacks(container));
|
||||
break;
|
||||
case 6:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CHANGE_WORLD.withParent(Contents.MAIN)));
|
||||
break;
|
||||
case 7:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.WORLD_INFO));
|
||||
break;
|
||||
case 8:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.PLAYER));
|
||||
break;
|
||||
case 9:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SUMMON));
|
||||
break;
|
||||
case 10:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiConfigWorldHandler(container, ConfigSettings.CATEGORY));
|
||||
break;
|
||||
case 11:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.BUTCHER.withParent(Contents.MAIN)));
|
||||
break;
|
||||
case 12:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.POTIONS.withParent(Contents.MAIN)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.MAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return Main.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return Main.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.MAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getBackContent()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayer;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayerReason;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
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.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentMultiplayer extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip playerField;
|
||||
private GuiTextFieldTooltip reasonField;
|
||||
|
||||
private int shiftDown = 0;
|
||||
|
||||
private String selected = "kickBan";
|
||||
|
||||
private final BuilderPlayerReason builderKick = new BuilderPlayerReason("kick");
|
||||
private final BuilderPlayerReason builderBan = new BuilderPlayerReason("ban");
|
||||
private final BuilderPlayer builderPardon = new BuilderPlayer("pardon");
|
||||
private final BuilderPlayer builderOp = new BuilderPlayer("op");
|
||||
private final BuilderPlayer builderDeop = new BuilderPlayer("deop");
|
||||
private final BuilderGeneric builderSaveAll = new BuilderGeneric("save-all");
|
||||
private final BuilderGeneric builderSaveOn = new BuilderGeneric("save-on");
|
||||
private final BuilderGeneric builderSaveOff = new BuilderGeneric("save-off");
|
||||
private final BuilderGeneric builderStop = new BuilderGeneric("stop");
|
||||
private final BuilderWhitelist builderWhitelist = new BuilderWhitelist();
|
||||
|
||||
private final BuilderMultiCommand builderKickBan = new BuilderMultiCommand(this.builderKick, this.builderBan);
|
||||
private final BuilderMultiCommand builderPermissions = new BuilderMultiCommand(this.builderOp, this.builderDeop);
|
||||
private final BuilderMultiCommand builderRuntime = new BuilderMultiCommand(this.builderSaveAll, this.builderSaveOn, this.builderSaveOff, this.builderStop);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
if(this.selected.equals("kickBan"))
|
||||
{
|
||||
return this.builderKickBan;
|
||||
}
|
||||
else if(this.selected.equals("pardon"))
|
||||
{
|
||||
return this.builderPardon;
|
||||
}
|
||||
else if(this.selected.equals("permissions"))
|
||||
{
|
||||
return this.builderPermissions;
|
||||
}
|
||||
else if(this.selected.equals("runtime"))
|
||||
{
|
||||
return this.builderRuntime;
|
||||
}
|
||||
else if(this.selected.equals("whitelist"))
|
||||
{
|
||||
return this.builderWhitelist;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.shiftDown, 114, 20, I18n.format("gui.worldhandler.multiplayer.username"));
|
||||
this.playerField.setValidator(Predicates.notNull());
|
||||
this.playerField.setFocused(false);
|
||||
this.playerField.setText(this.builderKick.getPlayer());
|
||||
this.playerField.setMaxStringLength(16);
|
||||
|
||||
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.shiftDown, 114, 20, I18n.format("gui.worldhandler.multiplayer.kick_ban.reason"));
|
||||
this.reasonField.setValidator(Predicates.notNull());
|
||||
this.reasonField.setFocused(false);
|
||||
this.reasonField.setText(this.builderKick.getReason());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
|
||||
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.multiplayer.kick") + " / " + I18n.format("gui.worldhandler.multiplayer.ban")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.multiplayer.pardon")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(6, x, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime")));
|
||||
container.add(button7 = new GuiButtonWorldHandler(7, x, y + 96, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist")));
|
||||
|
||||
if(this.selected.equals("kickBan"))
|
||||
{
|
||||
container.add(button8 = new GuiButtonWorldHandler(8, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.kick"), this.builderKick.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button9 = new GuiButtonWorldHandler(9, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.ban"), this.builderBan.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
button9.enabled = false;
|
||||
}
|
||||
|
||||
button3.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("pardon"))
|
||||
{
|
||||
container.add(button8 = new GuiButtonWorldHandler(10, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.pardon"), this.builderPardon.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
}
|
||||
|
||||
button4.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("permissions"))
|
||||
{
|
||||
container.add(button8 = new GuiButtonWorldHandler(11, x + 118, y + 24 + 12, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions.give"), this.builderOp.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
container.add(button9 = new GuiButtonWorldHandler(12, x + 118, y + 48 + 12, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions.take"), this.builderDeop.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
button9.enabled = false;
|
||||
}
|
||||
|
||||
button5.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("runtime"))
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(13, x + 118, y, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime.save_world"), this.builderSaveAll.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
container.add(new GuiButtonWorldHandler(14, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime.autosave", I18n.format("gui.worldhandler.generic.on"), this.builderSaveOn.toActualCommand(), EnumTooltip.TOP_RIGHT)));
|
||||
container.add(new GuiButtonWorldHandler(15, x + 118, y + 48, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.multiplayer.runtime.autosave", I18n.format("gui.worldhandler.generic.off"), this.builderSaveOff.toActualCommand(), EnumTooltip.TOP_RIGHT)));
|
||||
container.add(new GuiButtonWorldHandler(16, x + 118, y + 72, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.multiplayer.runtime.stop_server"), this.builderStop.toActualCommand(), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
button6.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("whitelist"))
|
||||
{
|
||||
container.add(button8 = new GuiButtonWorldHandler(17, x + 118, y + 24, 44, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.add")));
|
||||
container.add(button9 = new GuiButtonWorldHandler(18, x + 118 + 47, y + 24, 44, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.remove")));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(19, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.whitelist", I18n.format("gui.worldhandler.generic.on"))));
|
||||
container.add(new GuiButtonWorldHandler(20, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.whitelist", I18n.format("gui.worldhandler.generic.off"))));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(21, x + 232 - 20, y + 24, 20, 20, null, I18n.format("gui.worldhandler.multiplayer.whitelist.reload"), EnumTooltip.TOP_RIGHT, EnumIcon.RELOAD));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
button9.enabled = false;
|
||||
}
|
||||
|
||||
button7.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
this.selected = "kickBan";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selected = "pardon";
|
||||
this.shiftDown = 24;
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selected = "permissions";
|
||||
this.shiftDown = 12;
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
this.selected = "runtime";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
this.selected = "whitelist";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(this.builderKick);
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderBan);
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderPardon);
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderOp);
|
||||
break;
|
||||
case 12:
|
||||
WorldHandler.sendCommand(this.builderDeop);
|
||||
break;
|
||||
case 13:
|
||||
WorldHandler.sendCommand(this.builderSaveAll);
|
||||
break;
|
||||
case 14:
|
||||
WorldHandler.sendCommand(this.builderSaveOn);
|
||||
break;
|
||||
case 15:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderSaveOff).withParent(Contents.MULTIPLAYER)));
|
||||
break;
|
||||
case 16:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderStop).withParent(Contents.MULTIPLAYER)));
|
||||
break;
|
||||
case 17:
|
||||
WorldHandler.sendCommand(this.builderWhitelist.getBuilder(EnumMode.ADD));
|
||||
break;
|
||||
case 18:
|
||||
WorldHandler.sendCommand(this.builderWhitelist.getBuilder(EnumMode.REMOVE));
|
||||
break;
|
||||
case 19:
|
||||
WorldHandler.sendCommand(this.builderWhitelist.getBuilder(EnumMode.ON));
|
||||
break;
|
||||
case 20:
|
||||
WorldHandler.sendCommand(this.builderWhitelist.getBuilder(EnumMode.OFF));
|
||||
break;
|
||||
case 21:
|
||||
WorldHandler.sendCommand(this.builderWhitelist.getBuilder(EnumMode.RELOAD));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selected.equals("kickBan"))
|
||||
{
|
||||
this.reasonField.drawTextBox();
|
||||
}
|
||||
|
||||
if(!this.selected.equals("runtime"))
|
||||
{
|
||||
this.playerField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
private void setPlayer(String player)
|
||||
{
|
||||
this.builderBan.setPlayer(player);
|
||||
this.builderKick.setPlayer(player);
|
||||
|
||||
this.builderPardon.setPlayer(player);
|
||||
this.builderOp.setPlayer(player);
|
||||
this.builderDeop.setPlayer(player);
|
||||
|
||||
this.builderWhitelist.setPlayer(player);
|
||||
}
|
||||
|
||||
private void setReason(String reason)
|
||||
{
|
||||
this.builderBan.setReason(reason);
|
||||
this.builderKick.setReason(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.MAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.multiplayer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.multiplayer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[]{I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.MULTIPLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.playerField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.setPlayer(this.playerField.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.reasonField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.setReason(this.reasonField.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.playerField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.reasonField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getBackContent()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderNoteEditor;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonKeyboard;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonKeyboard.Orientation;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentNoteEditor extends Content
|
||||
{
|
||||
private final BuilderNoteEditor builderNoteEditor = new BuilderNoteEditor();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.isActive() ? this.builderNoteEditor : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.builderNoteEditor.setPosition(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
|
||||
@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.isActive())
|
||||
{
|
||||
BlockPos pos = BlockHelper.getFocusedBlockPos();
|
||||
SoundEvent sound = this.getSoundEvent(pos.down());
|
||||
|
||||
container.add(new GuiButtonKeyboard(4, x - 3 + 15, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), Orientation.NORMAL, 0.53F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(5, x - 3 + 15 * 2, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.a"), Orientation.NORMAL, 0.6F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(6, x - 3 + 15 * 3, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.b"), Orientation.RIGHT, 0.67F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(7, x - 3 + 15 * 4, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.c"), Orientation.LEFT, 0.7F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(8, x - 3 + 15 * 5, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.d"), Orientation.NORMAL, 0.8F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(9, x - 3 + 15 * 6, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.e"), Orientation.RIGHT, 0.9F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(10, x - 3 + 15 * 7, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.f"), Orientation.LEFT, 0.95F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(11, x - 3 + 15 * 8, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), Orientation.NORMAL, 1.05F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(12, x - 3 + 15 * 9, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.a"), Orientation.NORMAL, 1.2F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(13, x - 3 + 15 * 10, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.b"), Orientation.RIGHT, 1.32F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(14, x - 3 + 15 * 11, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.c"), Orientation.LEFT, 1.4F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(15, x - 3 + 15 * 12, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.d"), Orientation.NORMAL, 1.6F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(16, x - 3 + 15 * 13, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.e"), Orientation.RIGHT, 1.8F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(17, x - 3 + 15 * 14, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.f"), Orientation.LEFT, 1.9F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(18, x - 3 - 5 + 15, y, 9, 58, "F#", Orientation.BLACK, 0.5F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(19, x - 3 - 5 + 15 * 2, y, 9, 58, "G#", Orientation.BLACK, 0.56F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(20, x - 3 - 5 + 15 * 3, y, 9, 58, "A#", Orientation.BLACK, 0.63F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(21, x - 3 - 5 + 15 * 5, y, 9, 58, "C#", Orientation.BLACK, 0.75F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(22, x - 3 - 5 + 15 * 6, y, 9, 58, "D#", Orientation.BLACK, 0.85F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(23, x - 3 - 5 + 15 * 8, y, 9, 58, "F#", Orientation.BLACK, 1.0F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(24, x - 3 - 5 + 15 * 9, y, 9, 58, "G#", Orientation.BLACK, 1.1F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(25, x - 3 - 5 + 15 * 10, y, 9, 58, "A#", Orientation.BLACK, 1.25F, container, this, pos, sound));
|
||||
|
||||
container.add(new GuiButtonKeyboard(26, x - 3 - 5 + 15 * 12, y, 9, 58, "C#", Orientation.BLACK, 1.5F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(27, x - 3 - 5 + 15 * 13, y, 9, 58, "D#", Orientation.BLACK, 1.7F, container, this, pos, sound));
|
||||
container.add(new GuiButtonKeyboard(28, x - 3 - 5 + 15 * 15, y, 9, 58, "F#", Orientation.BLACK, 2.0F, container, this, pos, sound));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
if(!this.isActive())
|
||||
{
|
||||
container.initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 4:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 1));
|
||||
break;
|
||||
case 5:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 3));
|
||||
break;
|
||||
case 6:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 5));
|
||||
break;
|
||||
case 7:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 6));
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 8));
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 10));
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 11));
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 13));
|
||||
break;
|
||||
case 12:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 15));
|
||||
break;
|
||||
case 13:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 17));
|
||||
break;
|
||||
case 14:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 18));
|
||||
break;
|
||||
case 15:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 20));
|
||||
break;
|
||||
case 16:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 22));
|
||||
break;
|
||||
case 17:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 23));
|
||||
break;
|
||||
case 18:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 0));
|
||||
break;
|
||||
case 19:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 2));
|
||||
break;
|
||||
case 20:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 4));
|
||||
break;
|
||||
case 21:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 7));
|
||||
break;
|
||||
case 22:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 9));
|
||||
break;
|
||||
case 23:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 12));
|
||||
break;
|
||||
case 24:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 14));
|
||||
break;
|
||||
case 25:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 16));
|
||||
break;
|
||||
case 26:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 19));
|
||||
break;
|
||||
case 27:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 21));
|
||||
break;
|
||||
case 28:
|
||||
WorldHandler.sendCommand(this.builderNoteEditor.getBuilderForNote((byte) 24));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.isActive())
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("worldhandler:textures/misc/note.png"));
|
||||
|
||||
container.drawTexturedModalRect(x - 1, y - 1, 0, 0, 8, 59);
|
||||
container.drawTexturedModalRect(x - 1, y - 1 + 59, 0, 59, 13, 35);
|
||||
|
||||
container.drawTexturedModalRect(x - 1 + 232 - 5, y - 1, 18, 0, 7, 59);
|
||||
container.drawTexturedModalRect(x - 1 + 232 - 10, y - 1 + 59, 13, 59, 12, 35);
|
||||
|
||||
container.drawTexturedModalRect(x - 1 + 8, y - 1, 0, 94, 219, 1);
|
||||
container.drawTexturedModalRect(x - 1 + 13, y - 1 + 93, 0, 94, 209, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
float scale = 4;
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.pushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GlStateManager.translate(container.width / 2 - 8 * scale, container.height / 2 - 15 - 8 * scale, 0);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(new ItemStack(Blocks.NOTEBLOCK), 0, 0);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", Keyboard.getKeyName(WorldHandler.KEY_WORLD_HANDLER.getKeyCode()));
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, ConfigSkin.getLabelColor());
|
||||
}
|
||||
}
|
||||
|
||||
private SoundEvent getSoundEvent(BlockPos blockPos)
|
||||
{
|
||||
IBlockState blockstate = Minecraft.getMinecraft().world.getBlockState(blockPos);
|
||||
Material material = blockstate.getMaterial();
|
||||
Block block = blockstate.getBlock();
|
||||
|
||||
if(block.equals(Blocks.CLAY))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_FLUTE;
|
||||
}
|
||||
else if(block.equals(Blocks.GOLD_BLOCK))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_BELL;
|
||||
}
|
||||
else if(block.equals(Blocks.WOOL))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_GUITAR;
|
||||
}
|
||||
else if(block.equals(Blocks.PACKED_ICE))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_CHIME;
|
||||
}
|
||||
else if(block.equals(Blocks.BONE_BLOCK))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_XYLOPHONE;
|
||||
}
|
||||
|
||||
if(material.equals(Material.WOOD))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_BASS;
|
||||
}
|
||||
else if(material.equals(Material.SAND))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_SNARE;
|
||||
}
|
||||
else if(material.equals(Material.GLASS))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_HAT;
|
||||
}
|
||||
else if(material.equals(Material.ROCK))
|
||||
{
|
||||
return SoundEvents.BLOCK_NOTE_BASEDRUM;
|
||||
}
|
||||
|
||||
return SoundEvents.BLOCK_NOTE_HARP;
|
||||
}
|
||||
|
||||
private boolean isActive()
|
||||
{
|
||||
return BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.BLOCKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.blocks.note_block_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.blocks.note_block_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.NOTE_EDITOR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSpawnpoint;
|
||||
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.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentPlayer extends Content
|
||||
{
|
||||
private String selectedMain = "start";
|
||||
|
||||
private GuiTextFieldTooltip posXField;
|
||||
private GuiTextFieldTooltip posYField;
|
||||
private GuiTextFieldTooltip posZField;
|
||||
|
||||
private GuiTextFieldTooltip scoreField;
|
||||
private GuiTextFieldTooltip coinsField;
|
||||
private GuiTextFieldTooltip xpField;
|
||||
|
||||
private final BuilderGeneric builderSetworldspawn = new BuilderGeneric("setworldspawn");
|
||||
private final BuilderSpawnpoint builderSpawnpoint = new BuilderSpawnpoint(WorldHandler.USERNAME);
|
||||
private final BuilderGeneric builderKill = new BuilderGeneric("kill");
|
||||
private final BuilderGeneric builderClear = new BuilderGeneric("clear");
|
||||
|
||||
private final BuilderMultiCommand builderMiscellaneous = new BuilderMultiCommand(this.builderSetworldspawn, this.builderSpawnpoint, this.builderKill, this.builderClear);
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
if(this.selectedMain.equals("miscellaneous"))
|
||||
{
|
||||
return this.builderMiscellaneous;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.posXField = new GuiTextFieldTooltip(x + 118, y, 114, 20);
|
||||
this.posYField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20);
|
||||
this.posZField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
|
||||
this.scoreField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
|
||||
this.coinsField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
|
||||
this.xpField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
|
||||
|
||||
this.updateScreen(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
|
||||
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(4, x, y, 114, 20, I18n.format("gui.worldhandler.entities.player.start")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(5, x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.player.score")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(6, x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.player.position")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(7, x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.miscellaneous")));
|
||||
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("score"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("position"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(8, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.position.copy_position")));
|
||||
}
|
||||
else if(this.selectedMain.equals("miscellaneous"))
|
||||
{
|
||||
button6.enabled = false;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(9, x + 118, y, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_spawn")));
|
||||
container.add(new GuiButtonWorldHandler(10, x + 118, y + 24, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_global_spawn")));
|
||||
container.add(new GuiButtonWorldHandler(11, x + 118, y + 48, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.kill")));
|
||||
container.add(new GuiButtonWorldHandler(12, x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.clear_inventory")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
this.posXField.setText("X: " + MathHelper.floor(Minecraft.getMinecraft().player.posX));
|
||||
this.posYField.setText("Y: " + MathHelper.floor(Minecraft.getMinecraft().player.posY));
|
||||
this.posZField.setText("Z: " + MathHelper.floor(Minecraft.getMinecraft().player.posZ));
|
||||
this.scoreField.setText(I18n.format("gui.worldhandler.entities.player.score") + ": " + Minecraft.getMinecraft().player.getScore());
|
||||
this.coinsField.setText(I18n.format("gui.worldhandler.entities.player.score.experience") + ": " + Minecraft.getMinecraft().player.experienceLevel + "L");
|
||||
this.xpField.setText(I18n.format("gui.worldhandler.entities.player.score.experience_coins") + ": " + Minecraft.getMinecraft().player.experienceTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 4:
|
||||
this.selectedMain = "start";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedMain = "score";
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
this.selectedMain = "position";
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
this.selectedMain = "miscellaneous";
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
int posX = MathHelper.floor(Minecraft.getMinecraft().player.posX);
|
||||
int posY = MathHelper.floor(Minecraft.getMinecraft().player.posY);
|
||||
int posZ = MathHelper.floor(Minecraft.getMinecraft().player.posZ);
|
||||
|
||||
container.setClipboardString(posX + " " + posY + " " + posZ);
|
||||
break;
|
||||
case 9:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderSpawnpoint).withParent(Contents.PLAYER)));
|
||||
break;
|
||||
case 10:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderSetworldspawn).withParent(Contents.PLAYER)));
|
||||
break;
|
||||
case 11:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderKill).withParent(Contents.PLAYER)));
|
||||
break;
|
||||
case 12:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.CONTINUE.withBuilder(this.builderClear).withParent(Contents.PLAYER)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
int xPos = x + 175;
|
||||
int yPos = y + 82;
|
||||
int playerNameWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(Minecraft.getMinecraft().player.getName()) / 2;
|
||||
|
||||
container.drawRect(container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(Minecraft.getMinecraft().player.getName(), container.width / 2 - playerNameWidth + 59, yPos - 73, 0xE0E0E0);
|
||||
|
||||
GuiInventory.drawEntityOnScreen(xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, Minecraft.getMinecraft().player);
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
}
|
||||
else if(this.selectedMain.equals("score"))
|
||||
{
|
||||
this.scoreField.drawTextBox();
|
||||
this.xpField.drawTextBox();
|
||||
this.coinsField.drawTextBox();
|
||||
}
|
||||
else if(this.selectedMain.equals("position"))
|
||||
{
|
||||
this.posXField.drawTextBox();
|
||||
this.posYField.drawTextBox();
|
||||
this.posZField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderSpawnpoint.setPlayer(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.player.player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.player.player");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[]{I18n.format("gui.worldhandler.generic.browse")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.PLAYER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.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 exopandora.worldhandler.main.WorldHandler;
|
||||
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 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, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect.amplifier"), 0, 100, 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, x + 118, y, 114, 20, I18n.format("gui.worldhandler.potion.time.seconds"), 0, 59, 0, new SimpleResponder<Potion>(value ->
|
||||
{
|
||||
this.builderPotion.setSeconds(value.intValue());
|
||||
this.builderPotionItem.setSeconds(potion, value.intValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "minutes" + potion, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 59, 0, new SimpleResponder<Potion>(value ->
|
||||
{
|
||||
this.builderPotion.setMinutes(value.intValue());
|
||||
this.builderPotionItem.setMinutes(potion, value.intValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "hours" + potion, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potion.time.hours"), 0, 99, 0, new SimpleResponder<Potion>(value ->
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives;
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
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.ElementClickList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
private GuiTextFieldTooltip objectField;
|
||||
private String selectedObjective = "create";
|
||||
|
||||
private final BuilderScoreboardObjectives builderObjectives = new BuilderScoreboardObjectives();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderObjectives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y + (this.selectedObjective.equals("remove") ? 24 : 0), 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField.setValidator(Predicates.notNull());
|
||||
this.objectField.setText(this.objective);
|
||||
|
||||
if(this.selectedObjective.equals("create"))
|
||||
{
|
||||
ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), 7, 8, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public void consumeKey1(String key)
|
||||
{
|
||||
builderObjectives.setCriteria(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translate1(String key)
|
||||
{
|
||||
String format = "gui.worldhandler.scoreboard.objectives.criteria." + key;
|
||||
String result = I18n.format(format);
|
||||
|
||||
if(result.equals(format))
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation(key);
|
||||
|
||||
if(Item.REGISTRY.containsKey(location))
|
||||
{
|
||||
result = I18n.format(Item.REGISTRY.getObject(location).getUnlocalizedName() + ".name");
|
||||
}
|
||||
else if(Block.REGISTRY.containsKey(location))
|
||||
{
|
||||
result = Block.REGISTRY.getObject(location).getLocalizedName();
|
||||
}
|
||||
else if(EntityHelper.doesExist(key))
|
||||
{
|
||||
result = I18n.format("entity." + key + ".name");
|
||||
}
|
||||
else if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key)))
|
||||
{
|
||||
result = I18n.format("gui.worldhandler.color." + key);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = I18n.format(key);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "objectives";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(objectives);
|
||||
}
|
||||
else if(this.selectedObjective.equals("display") || this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
ElementClickList slots = new ElementClickList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), 9, 10, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate1(String key)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.slot." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translate2(String key1, String key2)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.color." + key2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeKey1(String key)
|
||||
{
|
||||
builderObjectives.setSlot(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "slots";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(slots);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
|
||||
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(2, x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.create")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(3, x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.display")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(4, x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.undisplay")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(5, x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.remove")));
|
||||
|
||||
button3.enabled = !this.selectedObjective.equals("create");
|
||||
button4.enabled = !this.selectedObjective.equals("display");
|
||||
button5.enabled = !this.selectedObjective.equals("undisplay");
|
||||
button6.enabled = !this.selectedObjective.equals("remove");
|
||||
|
||||
boolean enabled = this.builderObjectives.getObjective() != null && this.builderObjectives.getObjective().length() > 0;
|
||||
int yOffset = this.selectedObjective.equals("undisplay") ? -12 : (this.selectedObjective.equals("remove") ? -24 : 0);
|
||||
|
||||
if(this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
this.builderObjectives.setObjective(null);
|
||||
enabled = true;
|
||||
}
|
||||
else if(this.selectedObjective.equals("remove"))
|
||||
{
|
||||
this.builderObjectives.setMode("remove");
|
||||
}
|
||||
|
||||
if(!this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
this.builderObjectives.setObjective(this.objective);
|
||||
}
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(6, x + 118, y + 72 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
button3.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.selectedObjective = "create";
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
this.selectedObjective = "display";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedObjective = "undisplay";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedObjective = "remove";
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
WorldHandler.sendCommand(this.builderObjectives);
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(!this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
this.objectField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.objectField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.objective = this.objectField.getText();
|
||||
this.builderObjectives.setObjective(this.objective);
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(!this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
this.objectField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.scoreboard.objectives");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.SCOREBOARD_OBJECTIVES;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumPoints;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumTag;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
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 ContentScoreboardPlayers extends ContentScoreboard
|
||||
{
|
||||
private GuiTextFieldTooltip objectField;
|
||||
private GuiTextFieldTooltip tagField;
|
||||
|
||||
private final BuilderScoreboardPlayers builderPlayers = new BuilderScoreboardPlayers();
|
||||
private final Predicate<String> nonNullNoSpace = string -> string != null && !string.matches("(.* .*)+");
|
||||
|
||||
private String selectedPlayer = "add|set|remove";
|
||||
private String tag;
|
||||
|
||||
private GuiButtonWorldHandler addButton;
|
||||
private GuiButtonWorldHandler removeButton;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.objectField = new GuiTextFieldTooltip(x + 118, y + (this.selectedPlayer.equals("enable") ? 24 : 0), 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField.setValidator(this.nonNullNoSpace);
|
||||
this.objectField.setText(this.objective);
|
||||
|
||||
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag"));
|
||||
this.tagField.setValidator(this.nonNullNoSpace);
|
||||
this.tagField.setText(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
|
||||
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(2, x, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(3, x, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(4, x, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.trigger")));
|
||||
|
||||
button3.enabled = !this.selectedPlayer.equals("add|set|remove");
|
||||
button4.enabled = !this.selectedPlayer.equals("tag");
|
||||
button5.enabled = !this.selectedPlayer.equals("enable");
|
||||
|
||||
this.builderPlayers.setMode(this.selectedPlayer);
|
||||
|
||||
boolean objective = this.builderPlayers.getObjective() != null && !this.builderPlayers.getObjective().isEmpty();
|
||||
|
||||
if(this.selectedPlayer.equals("add|set|remove"))
|
||||
{
|
||||
container.add(new GuiSlider<String>(this, container, "points", x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points"), 0, 100, 0, new SimpleResponder<String>(value ->
|
||||
{
|
||||
this.builderPlayers.setPoints(value);
|
||||
})));
|
||||
|
||||
container.add(this.addButton = new GuiButtonWorldHandler(5, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.add")));
|
||||
container.add(this.removeButton = new GuiButtonWorldHandler(6, x + 118, y + 72, 56, 20, I18n.format("gui.worldhandler.actions.remove")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(7, x + 118 + 114 / 2 + 1, y + 72, 56, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
boolean enabled = objective && this.builderPlayers.getPoints() > 0;
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
button5.enabled = objective;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(8, x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.actions.add")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(9, x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.actions.remove")));
|
||||
|
||||
boolean enabled = this.tag != null && !this.tag.isEmpty();
|
||||
|
||||
button3.enabled = enabled;
|
||||
button4.enabled = enabled;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("enable"))
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(10, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.enable")));
|
||||
|
||||
button3.enabled = objective;
|
||||
}
|
||||
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
this.builderPlayers.setTag(this.tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderPlayers.setObjective(this.objective);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
if(this.selectedPlayer.equals("add|set|remove"))
|
||||
{
|
||||
boolean objective = this.builderPlayers.getObjective() != null && !this.builderPlayers.getObjective().isEmpty();
|
||||
boolean enabled = objective && this.builderPlayers.getPoints() > 0;
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.selectedPlayer = "add|set|remove";
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
this.selectedPlayer = "tag";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedPlayer = "enable";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
WorldHandler.sendCommand(this.builderPlayers.getBuilderForPoints(EnumPoints.ADD));
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
WorldHandler.sendCommand(this.builderPlayers.getBuilderForPoints(EnumPoints.REMOVE));
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
WorldHandler.sendCommand(this.builderPlayers.getBuilderForPoints(EnumPoints.SET, 0));
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(this.builderPlayers.getBuilderForTag(EnumTag.ADD));
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderPlayers.getBuilderForTag(EnumTag.REMOVE));
|
||||
container.initGui();
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderPlayers);
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
this.tagField.drawTextBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.objectField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.objectField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.objective = this.objectField.getText();
|
||||
this.builderPlayers.setObjective(this.objective);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.tagField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.tag = this.tagField.getText();
|
||||
this.builderPlayers.setTag(this.tag);
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
this.tagField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.objectField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.scoreboard.players");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.SCOREBOARD_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderPlayers.setPlayer(username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams.EnumMode;
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
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.ElementClickList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
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 ContentScoreboardTeams extends ContentScoreboard
|
||||
{
|
||||
private GuiTextFieldTooltip teamField;
|
||||
|
||||
private String team;
|
||||
private String selectedTeam = "add";
|
||||
|
||||
private final BuilderScoreboardTeams builderTeams = new BuilderScoreboardTeams();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderTeams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.teamField = new GuiTextFieldTooltip(x + 118, y + (this.selectedTeam.equals("option") ? 0 : (this.selectedTeam.equals("add") ? 24 : 12)), 114, 20, I18n.format("gui.worldhandler.scoreboard.team.team"));
|
||||
this.teamField.setValidator(Predicates.notNull());
|
||||
this.teamField.setText(this.team);
|
||||
|
||||
if(this.selectedTeam.equals("option"))
|
||||
{
|
||||
ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), 6, 7, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate1(String key)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.options." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translate2(String key1, String key2)
|
||||
{
|
||||
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key2)))
|
||||
{
|
||||
return I18n.format("gui.worldhandler.color." + key2);
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.suboption." + key2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeKey1(String key)
|
||||
{
|
||||
builderTeams.setRule(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeKey2(String key1, String key2)
|
||||
{
|
||||
builderTeams.setValue(key2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "options";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(options);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
|
||||
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(2, x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.create")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(3, x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.join") + " / " + I18n.format("gui.worldhandler.scoreboard.team.leave")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(4, x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.remove") + " / " + I18n.format("gui.worldhandler.scoreboard.team.empty")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(5, x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.options")));
|
||||
|
||||
button3.enabled = !this.selectedTeam.equals("add");
|
||||
button4.enabled = !this.selectedTeam.equals("join|leave");
|
||||
button5.enabled = !this.selectedTeam.equals("remove|empty");
|
||||
button6.enabled = !this.selectedTeam.equals("option");
|
||||
|
||||
this.builderTeams.setMode(this.selectedTeam);
|
||||
|
||||
boolean enabled = this.team != null && this.team.length() > 0;
|
||||
|
||||
if(this.selectedTeam.equals("add"))
|
||||
{
|
||||
this.builderTeams.setTeam(this.team);
|
||||
}
|
||||
else if(this.selectedTeam.equals("join|leave"))
|
||||
{
|
||||
this.builderTeams.setPlayer(container.getPlayer());
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(9, x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.join")));
|
||||
container.add(new GuiButtonWorldHandler(10, x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.leave")));
|
||||
|
||||
button3.enabled = enabled;
|
||||
}
|
||||
else if(this.selectedTeam.equals("remove|empty"))
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(11, x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.remove")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(12, x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.empty")));
|
||||
|
||||
button3.enabled = enabled;
|
||||
button4.enabled = enabled;
|
||||
}
|
||||
|
||||
if(!this.selectedTeam.equals("join|leave") && !this.selectedTeam.equals("remove|empty"))
|
||||
{
|
||||
int yOffset = this.selectedTeam.equals("option") ? 24 : 0;
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(8, x + 118, y + 48 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
button3.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.selectedTeam = "add";
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
this.selectedTeam = "join|leave";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedTeam = "remove|empty";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedTeam = "option";
|
||||
container.initGui();
|
||||
break;
|
||||
case 8:
|
||||
WorldHandler.sendCommand(this.builderTeams);
|
||||
container.initButtons();
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.JOIN));
|
||||
container.initButtons();
|
||||
break;
|
||||
case 10:
|
||||
WorldHandler.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.LEAVE));
|
||||
container.initButtons();
|
||||
break;
|
||||
case 11:
|
||||
WorldHandler.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.REMOVE));
|
||||
container.initButtons();
|
||||
break;
|
||||
case 12:
|
||||
WorldHandler.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.EMPTY));
|
||||
container.initButtons();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.teamField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.teamField.textboxKeyTyped(typedChar, keyCode))
|
||||
{
|
||||
this.team = this.teamField.getText();
|
||||
this.builderTeams.setTeam(this.team);
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.teamField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.scoreboard.teams");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.SCOREBOARD_TEAMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
if(this.selectedTeam.equals("join|leave"))
|
||||
{
|
||||
this.builderTeams.setPlayer(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSignEditor;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
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.ElementColorMenu;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicColorMenu;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentSignEditor extends Content
|
||||
{
|
||||
private static final ResourceLocation LOGO = new ResourceLocation("worldhandler:textures/logo.png");
|
||||
|
||||
private int selectedLine = 0;
|
||||
private boolean editColor;
|
||||
|
||||
private GuiTextFieldTooltip commandField;
|
||||
private GuiTextFieldTooltip textlineField;
|
||||
|
||||
private final BuilderSignEditor builderSignEditor = new BuilderSignEditor();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.isActive() ? this.builderSignEditor : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
if(this.isActive())
|
||||
{
|
||||
this.builderSignEditor.setPosition(BlockHelper.getFocusedBlockPos());
|
||||
|
||||
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.commmand"));
|
||||
this.commandField.setValidator(Predicates.notNull());
|
||||
this.commandField.setText(this.builderSignEditor.getCommand(this.selectedLine));
|
||||
this.commandField.setCursorPositionEnd();
|
||||
|
||||
ElementColorMenu colors = new ElementColorMenu(this, x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.builderSignEditor.getColoredString(this.selectedLine), new int[] {8, 9, 10, 11, 12, 13}, new ILogicColorMenu()
|
||||
{
|
||||
@Override
|
||||
public Predicate<String> getValidator()
|
||||
{
|
||||
return string -> Minecraft.getMinecraft().fontRenderer.getStringWidth(string) <= 90;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawButtons()
|
||||
{
|
||||
return editColor;
|
||||
}
|
||||
});
|
||||
|
||||
container.add(colors);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
|
||||
if(this.isActive())
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(3, x, y, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_1")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_2")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_3")));
|
||||
container.add(button6 = new GuiButtonWorldHandler(6, x, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_4")));
|
||||
|
||||
if(this.editColor)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.done")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.format_text_line")));
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
}
|
||||
|
||||
button3.enabled = this.selectedLine != 0;
|
||||
button4.enabled = this.selectedLine != 1;
|
||||
button5.enabled = this.selectedLine != 2;
|
||||
button6.enabled = this.selectedLine != 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
if(!this.isActive())
|
||||
{
|
||||
container.initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderSignEditor, this.builderSignEditor.isSpecial());
|
||||
break;
|
||||
case 3:
|
||||
this.selectedLine = 0;
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedLine = 1;
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.selectedLine = 2;
|
||||
container.initGui();
|
||||
break;
|
||||
case 6:
|
||||
this.selectedLine = 3;
|
||||
container.initGui();
|
||||
break;
|
||||
case 7:
|
||||
this.editColor = !this.editColor;
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.isActive())
|
||||
{
|
||||
if(!this.editColor)
|
||||
{
|
||||
this.commandField.drawTextBox();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float scale = 4;
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.pushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GlStateManager.translate(container.width / 2 - 8.5F * scale, container.height / 2 - 15 - 8.5F * scale, 0);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(new ItemStack(Items.SIGN), 0, 0);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", Keyboard.getKeyName(WorldHandler.KEY_WORLD_HANDLER.getKeyCode()));
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, ConfigSkin.getLabelColor());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isActive()
|
||||
{
|
||||
return BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
if(this.isActive())
|
||||
{
|
||||
if(this.commandField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.builderSignEditor.setCommand(this.selectedLine, this.commandField.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.isActive())
|
||||
{
|
||||
this.commandField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.BLOCKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.blocks.sign_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.blocks.sign_editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
|
||||
{
|
||||
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.SIGN_EDITOR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,653 @@
|
||||
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 org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSummon;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonItem;
|
||||
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.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import exopandora.worldhandler.util.UtilPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.MobEffects;
|
||||
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 ContentSummon extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip mobField;
|
||||
private GuiTextFieldTooltip customNameField;
|
||||
private GuiTextFieldTooltip passengerField;
|
||||
|
||||
private int potionPage = 0;
|
||||
private int equipmentPage = 0;
|
||||
|
||||
private String page = "main";
|
||||
private String mob;
|
||||
private String name;
|
||||
private String passenger;
|
||||
|
||||
private final BuilderSummon builderSummon = new BuilderSummon();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderSummon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.builderSummon.setDirection(UtilPlayer.getPlayerDirection());
|
||||
|
||||
this.mobField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.mob_id") + " (" + I18n.format("gui.worldhandler.generic.name") + ")");
|
||||
this.mobField.setValidator(Predicates.notNull());
|
||||
this.mobField.setText(this.mob);
|
||||
|
||||
this.customNameField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.custom_name"));
|
||||
this.customNameField.setValidator(Predicates.notNull());
|
||||
this.customNameField.setText(this.name);
|
||||
|
||||
this.passengerField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.passenger_mob_id"));
|
||||
this.passengerField.setValidator(Predicates.notNull());
|
||||
this.passengerField.setText(this.passenger);
|
||||
|
||||
if(this.page.equals("attributes"))
|
||||
{
|
||||
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.MOB).stream()).collect(Collectors.toList()), null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<EnumAttributes, Object>()
|
||||
{
|
||||
@Override
|
||||
public String translate(EnumAttributes key)
|
||||
{
|
||||
return key.getTranslation();
|
||||
}
|
||||
|
||||
@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.SUMMON, container, value, x, y, width, height, display, value.getMin(), value.getMax(), value.getStart(), new AttributeResponder(response ->
|
||||
{
|
||||
builderSummon.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;
|
||||
GuiButtonItem button11;
|
||||
GuiButtonItem button12;
|
||||
GuiButtonItem button13;
|
||||
GuiButtonItem button14;
|
||||
GuiButtonItem button15;
|
||||
GuiButtonWorldHandler button16;
|
||||
GuiButtonItem button17;
|
||||
GuiButtonItem button18;
|
||||
GuiButtonItem button19;
|
||||
GuiButtonItem button20;
|
||||
GuiButtonItem button21;
|
||||
GuiButtonWorldHandler button22;
|
||||
GuiButtonItem button23;
|
||||
GuiButtonItem button24;
|
||||
GuiButtonItem button25;
|
||||
GuiButtonItem button26;
|
||||
GuiButtonItem button27;
|
||||
GuiButtonWorldHandler button28;
|
||||
|
||||
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(button7 = new GuiButtonWorldHandler(12, x, y, 114, 20, I18n.format("gui.worldhandler.entities.summon.start")));
|
||||
container.add(button8 = new GuiButtonWorldHandler(3, x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.summon.potion_effects")));
|
||||
container.add(button9 = new GuiButtonWorldHandler(4, x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.summon.attributes")));
|
||||
container.add(button10 = new GuiButtonWorldHandler(5, x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.summon.equipment")));
|
||||
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
button7.enabled = false;
|
||||
|
||||
if(!this.builderSummon.needsCommandBlock() && !this.builderSummon.getCustomName().isSpecial())
|
||||
{
|
||||
container.add(button5 = new GuiButtonWorldHandler(9, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.title.entities.summon")));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button5 = new GuiButtonWorldHandler(9, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
}
|
||||
|
||||
button5.enabled = EntityList.isRegistered(this.builderSummon.getEntity());
|
||||
}
|
||||
else if(this.page.equals("potionEffects"))
|
||||
{
|
||||
button8.enabled = false;
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(14, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button4 = new GuiButtonWorldHandler(15, x + 118 + 60, y + 72, 55, 20, ">"));
|
||||
|
||||
int count = 0;
|
||||
|
||||
for(ResourceLocation location : this.getSortedPotionList())
|
||||
{
|
||||
Potion potion = Potion.REGISTRY.getObject(location);
|
||||
|
||||
if(!potion.equals(MobEffects.INSTANT_DAMAGE) && !potion.equals(MobEffects.INSTANT_HEALTH))
|
||||
{
|
||||
if(this.potionPage == 0)
|
||||
{
|
||||
button3.enabled = false;
|
||||
}
|
||||
|
||||
if(this.potionPage == Potion.REGISTRY.getKeys().size() - 3)
|
||||
{
|
||||
button4.enabled = false;
|
||||
}
|
||||
|
||||
if(count == this.potionPage)
|
||||
{
|
||||
container.add(new GuiSlider<Potion>(this, container, "amplifier" + potion, x + 118, y, 114, 20, I18n.format(potion.getName()), 0, 100, 0, new SimpleResponder<Potion>(value ->
|
||||
{
|
||||
this.builderSummon.setAmplifier(potion, value.byteValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "duration" + potion, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 100, 0, new SimpleResponder<Potion>(value ->
|
||||
{
|
||||
this.builderSummon.setMinutes(potion, value);
|
||||
})));
|
||||
container.add(new GuiButtonWorldHandler(54, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potions.effect.particles", this.builderSummon.getShowParticles(potion) ? I18n.format("gui.worldhandler.generic.on") : I18n.format("gui.worldhandler.generic.off"))));
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.page.equals("attributes"))
|
||||
{
|
||||
button9.enabled = false;
|
||||
}
|
||||
else if(this.page.equals("equipment"))
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(16, x + 118, y + 72, 56, 20, "<"));
|
||||
container.add(button4 = new GuiButtonWorldHandler(17, x + 118 + 60, y + 72, 54, 20, ">"));
|
||||
|
||||
if(this.equipmentPage == 0)
|
||||
{
|
||||
button3.enabled = false;
|
||||
|
||||
container.add(button11 = new GuiButtonItem(18, x + 118, y, 18, 20, Items.LEATHER_HELMET));
|
||||
container.add(button12 = new GuiButtonItem(19, x + 118 + 20 - 1, y, 18, 20, Items.IRON_HELMET));
|
||||
container.add(button13 = new GuiButtonItem(20, x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_HELMET));
|
||||
container.add(button14 = new GuiButtonItem(21, x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_HELMET));
|
||||
container.add(button15 = new GuiButtonItem(22, x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_HELMET));
|
||||
container.add(button16 = new GuiButtonWorldHandler(23, x + 118 + 20 * 5 - 5, y, 20, 20, null));
|
||||
|
||||
container.add(button17 = new GuiButtonItem(24, x + 118, y + 24, 18, 20, Items.LEATHER_CHESTPLATE));
|
||||
container.add(button18 = new GuiButtonItem(25, x + 118 + 20 - 1, y + 24, 18, 20, Items.IRON_CHESTPLATE));
|
||||
container.add(button19 = new GuiButtonItem(26, x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.CHAINMAIL_CHESTPLATE));
|
||||
container.add(button20 = new GuiButtonItem(27, x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_CHESTPLATE));
|
||||
container.add(button21 = new GuiButtonItem(28, x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_CHESTPLATE));
|
||||
container.add(button22 = new GuiButtonWorldHandler(29, x + 118 + 20 * 5 - 5, y + 24, 20, 20, null));
|
||||
|
||||
container.add(button23 = new GuiButtonItem(30, x + 118, y + 48, 18, 20, Items.LEATHER_LEGGINGS));
|
||||
container.add(button24 = new GuiButtonItem(31, x + 118 + 20 - 1, y + 48, 18, 20, Items.IRON_LEGGINGS));
|
||||
container.add(button25 = new GuiButtonItem(32, x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.CHAINMAIL_LEGGINGS));
|
||||
container.add(button26 = new GuiButtonItem(33, x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_LEGGINGS));
|
||||
container.add(button27 = new GuiButtonItem(34, x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_LEGGINGS));
|
||||
container.add(button28 = new GuiButtonWorldHandler(35, x + 118 + 20 * 5 - 5, y + 48, 20, 20, null));
|
||||
|
||||
button11.enabled = !this.builderSummon.getArmorItem(3).equals(Items.LEATHER_HELMET.getRegistryName());
|
||||
button12.enabled = !this.builderSummon.getArmorItem(3).equals(Items.IRON_HELMET.getRegistryName());
|
||||
button13.enabled = !this.builderSummon.getArmorItem(3).equals(Items.CHAINMAIL_HELMET.getRegistryName());
|
||||
button14.enabled = !this.builderSummon.getArmorItem(3).equals(Items.GOLDEN_HELMET.getRegistryName());
|
||||
button15.enabled = !this.builderSummon.getArmorItem(3).equals(Items.DIAMOND_HELMET.getRegistryName());
|
||||
button16.enabled = !this.builderSummon.getArmorItem(3).equals(Blocks.AIR.getRegistryName());
|
||||
|
||||
button17.enabled = !this.builderSummon.getArmorItem(2).equals(Items.LEATHER_CHESTPLATE.getRegistryName());
|
||||
button18.enabled = !this.builderSummon.getArmorItem(2).equals(Items.IRON_CHESTPLATE.getRegistryName());
|
||||
button19.enabled = !this.builderSummon.getArmorItem(2).equals(Items.CHAINMAIL_CHESTPLATE.getRegistryName());
|
||||
button20.enabled = !this.builderSummon.getArmorItem(2).equals(Items.GOLDEN_CHESTPLATE.getRegistryName());
|
||||
button21.enabled = !this.builderSummon.getArmorItem(2).equals(Items.DIAMOND_CHESTPLATE.getRegistryName());
|
||||
button22.enabled = !this.builderSummon.getArmorItem(2).equals(Blocks.AIR.getRegistryName());
|
||||
|
||||
button23.enabled = !this.builderSummon.getArmorItem(1).equals(Items.LEATHER_LEGGINGS.getRegistryName());
|
||||
button24.enabled = !this.builderSummon.getArmorItem(1).equals(Items.IRON_LEGGINGS.getRegistryName());
|
||||
button25.enabled = !this.builderSummon.getArmorItem(1).equals(Items.CHAINMAIL_LEGGINGS.getRegistryName());
|
||||
button26.enabled = !this.builderSummon.getArmorItem(1).equals(Items.GOLDEN_LEGGINGS.getRegistryName());
|
||||
button27.enabled = !this.builderSummon.getArmorItem(1).equals(Items.DIAMOND_LEGGINGS.getRegistryName());
|
||||
button28.enabled = !this.builderSummon.getArmorItem(1).equals(Blocks.AIR.getRegistryName());
|
||||
}
|
||||
else if(this.equipmentPage == 1)
|
||||
{
|
||||
button4.enabled = false;
|
||||
|
||||
container.add(button11 = new GuiButtonItem(36, x + 118, y, 18, 20, Items.LEATHER_BOOTS));
|
||||
container.add(button12 = new GuiButtonItem(37, x + 118 + 20 - 1, y, 18, 20, Items.IRON_BOOTS));
|
||||
container.add(button13 = new GuiButtonItem(38, x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_BOOTS));
|
||||
container.add(button14 = new GuiButtonItem(39, x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_BOOTS));
|
||||
container.add(button15 = new GuiButtonItem(40, x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_BOOTS));
|
||||
container.add(button16 = new GuiButtonWorldHandler(41, x + 118 + 20 * 5 - 5, y, 20, 20, null));
|
||||
|
||||
container.add(button17 = new GuiButtonItem(42, x + 118, y + 24, 18, 20, Items.WOODEN_SWORD));
|
||||
container.add(button18 = new GuiButtonItem(43, x + 118 + 20 - 1, y + 24, 18, 20, Items.STONE_SWORD));
|
||||
container.add(button19 = new GuiButtonItem(44, x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.IRON_SWORD));
|
||||
container.add(button20 = new GuiButtonItem(45, x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_SWORD));
|
||||
container.add(button21 = new GuiButtonItem(46, x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_SWORD));
|
||||
container.add(button22 = new GuiButtonWorldHandler(47, x + 118 + 20 * 5 - 5, y + 24, 20, 20, null));
|
||||
|
||||
container.add(button23 = new GuiButtonItem(48, x + 118, y + 48, 18, 20, Items.WOODEN_SWORD));
|
||||
container.add(button24 = new GuiButtonItem(49, x + 118 + 20 - 1, y + 48, 18, 20, Items.STONE_SWORD));
|
||||
container.add(button25 = new GuiButtonItem(50, x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.IRON_SWORD));
|
||||
container.add(button26 = new GuiButtonItem(51, x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_SWORD));
|
||||
container.add(button27 = new GuiButtonItem(52, x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_SWORD));
|
||||
container.add(button28 = new GuiButtonWorldHandler(53, x + 118 + 20 * 5 - 5, y + 48, 20, 20, null));
|
||||
|
||||
button11.enabled = !this.builderSummon.getArmorItem(0).equals(Items.LEATHER_BOOTS.getRegistryName());
|
||||
button12.enabled = !this.builderSummon.getArmorItem(0).equals(Items.IRON_BOOTS.getRegistryName());
|
||||
button13.enabled = !this.builderSummon.getArmorItem(0).equals(Items.CHAINMAIL_BOOTS.getRegistryName());
|
||||
button14.enabled = !this.builderSummon.getArmorItem(0).equals(Items.GOLDEN_BOOTS.getRegistryName());
|
||||
button15.enabled = !this.builderSummon.getArmorItem(0).equals(Items.DIAMOND_BOOTS.getRegistryName());
|
||||
button16.enabled = !this.builderSummon.getArmorItem(0).equals(Blocks.AIR.getRegistryName());
|
||||
|
||||
button17.enabled = !this.builderSummon.getHandItem(0).equals(Items.WOODEN_SWORD.getRegistryName());
|
||||
button18.enabled = !this.builderSummon.getHandItem(0).equals(Items.STONE_SWORD.getRegistryName());
|
||||
button19.enabled = !this.builderSummon.getHandItem(0).equals(Items.IRON_SWORD.getRegistryName());
|
||||
button20.enabled = !this.builderSummon.getHandItem(0).equals(Items.GOLDEN_SWORD.getRegistryName());
|
||||
button21.enabled = !this.builderSummon.getHandItem(0).equals(Items.DIAMOND_SWORD.getRegistryName());
|
||||
button22.enabled = !this.builderSummon.getHandItem(0).equals(Blocks.AIR.getRegistryName());
|
||||
|
||||
button23.enabled = !this.builderSummon.getHandItem(1).equals(Items.WOODEN_SWORD.getRegistryName());
|
||||
button24.enabled = !this.builderSummon.getHandItem(1).equals(Items.STONE_SWORD.getRegistryName());
|
||||
button25.enabled = !this.builderSummon.getHandItem(1).equals(Items.IRON_SWORD.getRegistryName());
|
||||
button26.enabled = !this.builderSummon.getHandItem(1).equals(Items.GOLDEN_SWORD.getRegistryName());
|
||||
button27.enabled = !this.builderSummon.getHandItem(1).equals(Items.DIAMOND_SWORD.getRegistryName());
|
||||
button28.enabled = !this.builderSummon.getHandItem(1).equals(Blocks.AIR.getRegistryName());
|
||||
}
|
||||
|
||||
button10.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 3:
|
||||
this.page = "potionEffects";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.page = "attributes";
|
||||
container.initGui();
|
||||
break;
|
||||
case 5:
|
||||
this.page = "equipment";
|
||||
container.initGui();
|
||||
break;
|
||||
case 9:
|
||||
WorldHandler.sendCommand(this.builderSummon, this.builderSummon.getCustomName().isSpecial());
|
||||
break;
|
||||
case 12:
|
||||
this.page = "main";
|
||||
container.initGui();
|
||||
break;
|
||||
case 14:
|
||||
this.potionPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 15:
|
||||
this.potionPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 16:
|
||||
this.equipmentPage--;
|
||||
container.initGui();
|
||||
break;
|
||||
case 17:
|
||||
this.equipmentPage++;
|
||||
container.initGui();
|
||||
break;
|
||||
case 18:
|
||||
this.builderSummon.setArmorItem(3, Items.LEATHER_HELMET);
|
||||
container.initGui();
|
||||
break;
|
||||
case 19:
|
||||
this.builderSummon.setArmorItem(3, Items.IRON_HELMET);
|
||||
container.initGui();
|
||||
break;
|
||||
case 20:
|
||||
this.builderSummon.setArmorItem(3, Items.CHAINMAIL_HELMET);
|
||||
container.initGui();
|
||||
break;
|
||||
case 21:
|
||||
this.builderSummon.setArmorItem(3, Items.GOLDEN_HELMET);
|
||||
container.initGui();
|
||||
break;
|
||||
case 22:
|
||||
this.builderSummon.setArmorItem(3, Items.DIAMOND_HELMET);
|
||||
container.initGui();
|
||||
break;
|
||||
case 23:
|
||||
this.builderSummon.setArmorItem(3, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 24:
|
||||
this.builderSummon.setArmorItem(2, Items.LEATHER_CHESTPLATE);
|
||||
container.initGui();
|
||||
break;
|
||||
case 25:
|
||||
this.builderSummon.setArmorItem(2, Items.IRON_CHESTPLATE);
|
||||
container.initGui();
|
||||
break;
|
||||
case 26:
|
||||
this.builderSummon.setArmorItem(2, Items.CHAINMAIL_CHESTPLATE);
|
||||
container.initGui();
|
||||
break;
|
||||
case 27:
|
||||
this.builderSummon.setArmorItem(2, Items.GOLDEN_CHESTPLATE);
|
||||
container.initGui();
|
||||
break;
|
||||
case 28:
|
||||
this.builderSummon.setArmorItem(2, Items.DIAMOND_CHESTPLATE);
|
||||
container.initGui();
|
||||
break;
|
||||
case 29:
|
||||
this.builderSummon.setArmorItem(2, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 30:
|
||||
this.builderSummon.setArmorItem(1, Items.LEATHER_LEGGINGS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 31:
|
||||
this.builderSummon.setArmorItem(1, Items.IRON_LEGGINGS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 32:
|
||||
this.builderSummon.setArmorItem(1, Items.CHAINMAIL_LEGGINGS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 33:
|
||||
this.builderSummon.setArmorItem(1, Items.GOLDEN_LEGGINGS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 34:
|
||||
this.builderSummon.setArmorItem(1, Items.DIAMOND_LEGGINGS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 35:
|
||||
this.builderSummon.setArmorItem(1, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 36:
|
||||
this.builderSummon.setArmorItem(0, Items.LEATHER_BOOTS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 37:
|
||||
this.builderSummon.setArmorItem(0, Items.IRON_BOOTS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 38:
|
||||
this.builderSummon.setArmorItem(0, Items.CHAINMAIL_BOOTS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 39:
|
||||
this.builderSummon.setArmorItem(0, Items.GOLDEN_BOOTS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 40:
|
||||
this.builderSummon.setArmorItem(0, Items.DIAMOND_BOOTS);
|
||||
container.initGui();
|
||||
break;
|
||||
case 41:
|
||||
this.builderSummon.setArmorItem(0, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 42:
|
||||
this.builderSummon.setHandItem(0, Items.WOODEN_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 43:
|
||||
this.builderSummon.setHandItem(0, Items.STONE_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 44:
|
||||
this.builderSummon.setHandItem(0, Items.IRON_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 45:
|
||||
this.builderSummon.setHandItem(0, Items.GOLDEN_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 46:
|
||||
this.builderSummon.setHandItem(0, Items.DIAMOND_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 47:
|
||||
this.builderSummon.setHandItem(0, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 48:
|
||||
this.builderSummon.setHandItem(1, Items.WOODEN_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 49:
|
||||
this.builderSummon.setHandItem(1, Items.STONE_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 50:
|
||||
this.builderSummon.setHandItem(1, Items.IRON_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 51:
|
||||
this.builderSummon.setHandItem(1, Items.GOLDEN_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 52:
|
||||
this.builderSummon.setHandItem(1, Items.DIAMOND_SWORD);
|
||||
container.initGui();
|
||||
break;
|
||||
case 53:
|
||||
this.builderSummon.setHandItem(1, Blocks.AIR);
|
||||
container.initGui();
|
||||
break;
|
||||
case 54:
|
||||
int count = 0;
|
||||
|
||||
for(ResourceLocation value : this.getSortedPotionList())
|
||||
{
|
||||
Potion potion = Potion.getPotionFromResourceLocation(value.toString());
|
||||
|
||||
if(!potion.equals(MobEffects.INSTANT_DAMAGE) && !potion.equals(MobEffects.INSTANT_HEALTH))
|
||||
{
|
||||
if(count == this.potionPage)
|
||||
{
|
||||
this.builderSummon.setShowParticles(potion, !this.builderSummon.getShowParticles(potion));
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
this.mobField.drawTextBox();
|
||||
this.customNameField.drawTextBox();
|
||||
this.passengerField.drawTextBox();
|
||||
}
|
||||
else if(this.page.equals("equipment"))
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("textures/gui/container/beacon.png"));
|
||||
|
||||
for(int row = 0; row < 3; row++)
|
||||
{
|
||||
container.drawTexturedModalRect(x + 116 + 99, y + 2 + 24 * row, 112, 221, 16, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char charTyped, int keyCode)
|
||||
{
|
||||
if(this.mobField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.mob = this.mobField.getText();
|
||||
this.builderSummon.setEntity(this.mob);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.customNameField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.name = this.customNameField.getText();
|
||||
this.builderSummon.setCustomName(this.name);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
if(this.passengerField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.passenger = this.passengerField.getText();
|
||||
this.builderSummon.setPassenger(this.passenger);
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
this.mobField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.customNameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.passengerField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ResourceLocation> getSortedPotionList()
|
||||
{
|
||||
List<ResourceLocation> potions = new ArrayList<ResourceLocation>(Potion.REGISTRY.getKeys());
|
||||
potions.sort((a, b) -> I18n.format(Potion.REGISTRY.getObject(a).getName()).compareTo(I18n.format(Potion.REGISTRY.getObject(b).getName())));
|
||||
|
||||
return potions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ENTITIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.entities.summon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.entities.summon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
String[] headline = new String[2];
|
||||
|
||||
headline[0] = I18n.format("gui.worldhandler.generic.browse");
|
||||
|
||||
if(this.page.equals("potionEffects"))
|
||||
{
|
||||
headline[1] = (this.potionPage + 1) + "/" + (Potion.REGISTRY.getKeys().size() - 2);
|
||||
}
|
||||
else if(this.page.equals("equipment"))
|
||||
{
|
||||
headline[1] = (this.equipmentPage + 1) + "/2";
|
||||
}
|
||||
else if(this.page.equals("main"))
|
||||
{
|
||||
headline[1] = I18n.format("gui.worldhandler.generic.options");
|
||||
}
|
||||
|
||||
return headline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.SUMMON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ContentWorldInfo extends Content
|
||||
{
|
||||
private String selectedMain = "start";
|
||||
|
||||
private GuiTextFieldTooltip posXField;
|
||||
private GuiTextFieldTooltip posYField;
|
||||
private GuiTextFieldTooltip posZField;
|
||||
|
||||
private GuiTextFieldTooltip worldField;
|
||||
private GuiTextFieldTooltip seedField;
|
||||
private GuiTextFieldTooltip terrainField;
|
||||
|
||||
private GuiTextFieldTooltip totalTimeField;
|
||||
private GuiTextFieldTooltip currentTimeField;
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
|
||||
if(Minecraft.getMinecraft().getIntegratedServer() != null)
|
||||
{
|
||||
world = Minecraft.getMinecraft().getIntegratedServer().getEntityWorld();
|
||||
}
|
||||
|
||||
this.posXField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
|
||||
this.posXField.setText(I18n.format("gui.worldhandler.world_info.start.spawn") + " X: " + this.getWorldInfo(WorldInfo::getSpawnX, world));
|
||||
|
||||
this.posYField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
|
||||
this.posYField.setText(I18n.format("gui.worldhandler.world_info.start.spawn") + " Y: " + this.getWorldInfo(WorldInfo::getSpawnY, world));
|
||||
|
||||
this.posZField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
|
||||
this.posZField.setText(I18n.format("gui.worldhandler.world_info.start.spawn") + " Z: " + this.getWorldInfo(WorldInfo::getSpawnZ, world));
|
||||
|
||||
this.worldField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
|
||||
this.worldField.setText(I18n.format("gui.worldhandler.world_info.world.name") + ": " + this.getWorldInfo(WorldInfo::getWorldName, world));
|
||||
|
||||
this.terrainField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
|
||||
this.terrainField.setText(I18n.format("gui.worldhandler.world_info.world.world_type") + ": " + this.getWorldInfo(info -> I18n.format(info.getTerrainType().getTranslationKey()), world));
|
||||
|
||||
this.seedField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
|
||||
this.seedField.setText(I18n.format("gui.worldhandler.world_info.world.seed") + ": " + (Minecraft.getMinecraft().getIntegratedServer() != null ? world.getWorldInfo().getSeed() : I18n.format("gui.worldhandler.world_info.n_a")));
|
||||
this.seedField.setValidator(string -> string.equals(this.seedField.getText()));
|
||||
this.seedField.setCursorPositionZero();
|
||||
this.updateCursorPosition();
|
||||
|
||||
this.currentTimeField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20);
|
||||
this.updateCurrentTime();
|
||||
|
||||
this.totalTimeField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
|
||||
this.updateTotalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler start;
|
||||
GuiButtonWorldHandler world;
|
||||
GuiButtonWorldHandler stats;
|
||||
|
||||
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(start = new GuiButtonWorldHandler(2, x, y + 12, 114, 20, I18n.format("gui.worldhandler.world_info.start")));
|
||||
container.add(world = new GuiButtonWorldHandler(3, x, y + 36, 114, 20, I18n.format("gui.worldhandler.world_info.world")));
|
||||
container.add(stats = new GuiButtonWorldHandler(4, x, y + 60, 114, 20, I18n.format("gui.worldhandler.world_info.statistics")));
|
||||
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
start.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("world"))
|
||||
{
|
||||
world.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("stats"))
|
||||
{
|
||||
stats.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
{
|
||||
this.updateCurrentTime();
|
||||
this.updateTotalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 2:
|
||||
this.selectedMain = "start";
|
||||
container.initGui();
|
||||
break;
|
||||
case 3:
|
||||
this.selectedMain = "world";
|
||||
container.initGui();
|
||||
break;
|
||||
case 4:
|
||||
this.selectedMain = "stats";
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
this.posXField.drawTextBox();
|
||||
this.posYField.drawTextBox();
|
||||
this.posZField.drawTextBox();
|
||||
}
|
||||
else if(this.selectedMain.equals("world"))
|
||||
{
|
||||
this.worldField.drawTextBox();
|
||||
this.terrainField.drawTextBox();
|
||||
this.seedField.drawTextBox();
|
||||
}
|
||||
else if(this.selectedMain.equals("stats"))
|
||||
{
|
||||
this.totalTimeField.drawTextBox();
|
||||
this.currentTimeField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentTime()
|
||||
{
|
||||
this.currentTimeField.setText(I18n.format("gui.worldhandler.world_info.statistics.world_time") + ": " + TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldInfo().getWorldTime()));
|
||||
}
|
||||
|
||||
private void updateTotalTime()
|
||||
{
|
||||
this.totalTimeField.setText(I18n.format("gui.worldhandler.world_info.statistics.played") + ": " + TextFormatting.getTotalTimePlayed(Minecraft.getMinecraft().world.getWorldInfo().getWorldTotalTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
if(this.selectedMain.equals("world"))
|
||||
{
|
||||
this.seedField.textboxKeyTyped(typedChar, keyCode);
|
||||
this.updateCursorPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if(this.selectedMain.equals("world"))
|
||||
{
|
||||
this.seedField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.updateCursorPosition();
|
||||
}
|
||||
}
|
||||
|
||||
private <T> String getWorldInfo(Function<WorldInfo, T> function, World world)
|
||||
{
|
||||
if(world != null)
|
||||
{
|
||||
return String.valueOf(function.apply(world.getWorldInfo()));
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.world_info.n_a");
|
||||
}
|
||||
|
||||
private void updateCursorPosition()
|
||||
{
|
||||
int length = I18n.format("gui.worldhandler.world_info.start.spawn").length();
|
||||
|
||||
if(this.seedField.getCursorPosition() < length + 2)
|
||||
{
|
||||
this.seedField.setCursorPosition(length + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.WORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.world.world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.world.world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[] {I18n.format("gui.worldhandler.generic.browse")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.WORLD_INFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package exopandora.worldhandler.gui.content.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ContentChild extends Content
|
||||
{
|
||||
protected Content parent;
|
||||
|
||||
public ContentChild withParent(Content parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
if(this.parent.getCategory() != null)
|
||||
{
|
||||
return this.parent.getCategory();
|
||||
}
|
||||
|
||||
return Contents.MAIN.getCategory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
if(this.parent != null)
|
||||
{
|
||||
return this.parent.getTabTitle();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
if(this.parent != null)
|
||||
{
|
||||
return this.parent.getActiveContent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getBackContent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package exopandora.worldhandler.gui.content.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.helper.ScoreboardHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ContentScoreboard extends Content
|
||||
{
|
||||
protected static final ScoreboardHelper HELPER = new ScoreboardHelper();
|
||||
protected static String objective;
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.SCOREBOARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.scoreboard");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeadline()
|
||||
{
|
||||
return new String[] {I18n.format("gui.worldhandler.generic.browse"), I18n.format("gui.worldhandler.generic.options")};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user