Update to 1.13.2
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* XXX To be replaced by a proper registry object
|
||||
*/
|
||||
@Deprecated
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public enum EnumIcon
|
||||
{
|
||||
WEATHER_SUN(0, 0),
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
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,91 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonBase extends GuiButton
|
||||
{
|
||||
protected ActionHandler actionHandler;
|
||||
|
||||
public GuiButtonBase(int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
|
||||
{
|
||||
this(0, x, y, widthIn, heightIn, buttonText, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonBase(int id, int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
|
||||
{
|
||||
super(id, x, y, widthIn, heightIn, buttonText);
|
||||
this.actionHandler = actionHandler;
|
||||
}
|
||||
|
||||
protected void drawBackground(int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
|
||||
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.getInstance().getTextureManager().bindTexture(ResourceHelper.getButtonTexture());
|
||||
|
||||
if(Config.getSkin().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.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
this.drawBackground(mouseX, mouseY);
|
||||
this.renderBg(Minecraft.getInstance(), mouseX, mouseY);
|
||||
this.drawCenteredString(Minecraft.getInstance().fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY)
|
||||
{
|
||||
super.onClick(mouseX, mouseY);
|
||||
|
||||
if(this.actionHandler != null)
|
||||
{
|
||||
ActionHelper.tryRun(this.actionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTextColor()
|
||||
{
|
||||
int textColor = 0xE0E0E0;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0xFFFFA0;
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonIcon extends GuiButtonTooltip
|
||||
{
|
||||
private EnumIcon icon;
|
||||
|
||||
public GuiButtonIcon(int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
|
||||
{
|
||||
this(0, x, y, widthIn, heightIn, icon, tooltip, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonIcon(int id, int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
|
||||
{
|
||||
super(id, x, y, widthIn, heightIn, null, tooltip, actionHandler);
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
if(this.icon != null)
|
||||
{
|
||||
this.renderIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private void renderIcon()
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
|
||||
|
||||
if(this.enabled)
|
||||
{
|
||||
if(this.hovered)
|
||||
{
|
||||
GlStateManager.color4f(1.0F, 1.0F, 0.6F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color4f(0.95F, 0.95F, 0.95F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color4f(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);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,55 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonItem extends GuiButtonWorldHandler
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonItem extends GuiButtonBase
|
||||
{
|
||||
private final ItemStack item;
|
||||
private final ItemStack stack;
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, Item item)
|
||||
public GuiButtonItem(int x, int y, int width, int height, Item item, ActionHandler actionHandler)
|
||||
{
|
||||
this(id, x, y, width, height, new ItemStack(item));
|
||||
this(0, x, y, width, height, item, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack item)
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, Item item, ActionHandler actionHandler)
|
||||
{
|
||||
super(id, x, y, width, height, null);
|
||||
this.item = item;
|
||||
this(id, x, y, width, height, new ItemStack(item), actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonItem(int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
|
||||
{
|
||||
this(0, x, y, width, height, stack, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
|
||||
{
|
||||
super(id, x, y, width, height, null, actionHandler);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
super.drawBackground(mouseX, mouseY);
|
||||
|
||||
GlStateManager.enableRescaleNormal();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(this.item, this.x + this.width / 2 - 8, this.y + 2);
|
||||
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(this.stack, this.x + this.width / 2 - 8, this.y + 2);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
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());
|
||||
|
||||
try
|
||||
{
|
||||
this.content.actionPerformed(this.container, this);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
WorldHandler.throwError(e);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +1,80 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.logic.ILogicMapped;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonList<T> extends GuiButtonTooltip
|
||||
{
|
||||
private final IListButtonLogic<T> logic;
|
||||
private final ButtonValue<T> persistence;
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
private final ILogicMapped<T> logic;
|
||||
private final Persistence persistence;
|
||||
private final List<T> items;
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, Content content, IListButtonLogic<T> logic)
|
||||
public GuiButtonList(int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
|
||||
{
|
||||
this(id, x, y, width, height, null, content, logic);
|
||||
this(0, x, y, items, widthIn, heightIn, container, logic);
|
||||
}
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content content, IListButtonLogic<T> logic)
|
||||
public GuiButtonList(int id, int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
|
||||
{
|
||||
super(id, x, y, width, height, null, null, tooltipType);
|
||||
super(id, x, y, widthIn, heightIn, null, null, null);
|
||||
this.items = items;
|
||||
this.logic = logic;
|
||||
this.persistence = content.getPersistence(this.logic.getId());
|
||||
this.updatePersistenceObject();
|
||||
this.persistence = container.getContent().getPersistence(this.logic.getId(), Persistence::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
|
||||
if(this.visible)
|
||||
{
|
||||
FontRenderer fontRenderer = minecraft.fontRenderer;
|
||||
this.drawBackground(mouseX, mouseY);
|
||||
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
String displayString = this.logic.translate(this.items.get(this.persistence.getIndex()));
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
this.displayString = this.logic.getDisplayString(this.persistence);
|
||||
|
||||
if(this.displayString != null && !this.displayString.isEmpty())
|
||||
if(displayString != null && !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(' ');
|
||||
int maxWidth = Math.max(0, this.width - fontRenderer.getStringWidth("< >"));
|
||||
int spaceWidth = fontRenderer.getStringWidth(" ");
|
||||
|
||||
String display = TextFormatting.shortenString(this.displayString, maxWidth, fontRenderer);
|
||||
int displayWidth = fontRenderer.getStringWidth(display);
|
||||
String display = TextFormatting.shortenString(displayString, maxWidth, fontRenderer);
|
||||
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)
|
||||
public void renderTooltip(int mouseX, int mouseY)
|
||||
{
|
||||
if(this.tooltipType != null)
|
||||
{
|
||||
this.displayTooltip = this.logic.getTooltipString(this.persistence);
|
||||
}
|
||||
|
||||
super.drawTooltip(mouseX, mouseY, width, height);
|
||||
this.tooltip = this.logic.formatTooltip(this.items.get(this.persistence.getIndex()), this.persistence.getIndex() + 1, this.items.size());
|
||||
super.renderTooltip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(int mouseX, int mouseY)
|
||||
@Override
|
||||
public void onClick(double mouseX, double 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)
|
||||
{
|
||||
int max = this.logic.getMax() - 1;
|
||||
int max = this.items.size() - 1;
|
||||
int index = this.persistence.getIndex();
|
||||
|
||||
if(this.isHoveringLeft(this.mouseX, this.mouseY))
|
||||
if(this.isHoveringLeft(mouseX, mouseY))
|
||||
{
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
@@ -129,7 +99,7 @@ public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.isHoveringRight(this.mouseX, this.mouseY))
|
||||
else if(this.isHoveringRight(mouseX, mouseY))
|
||||
{
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
@@ -155,17 +125,67 @@ public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePersistenceObject();
|
||||
this.logic.actionPerformed(container, button, this.persistence);
|
||||
this.logic.onClick(this.items.get(this.persistence.getIndex()));
|
||||
}
|
||||
|
||||
private void updatePersistenceObject()
|
||||
private boolean isHoveringLeft(double mouseX, double mouseY)
|
||||
{
|
||||
this.persistence.setObject(this.logic.getObject(this.persistence.getIndex()));
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
|
||||
}
|
||||
|
||||
public IListButtonLogic<T> getLogic()
|
||||
private boolean isHoveringRight(double mouseX, double mouseY)
|
||||
{
|
||||
return this.logic;
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
|
||||
}
|
||||
|
||||
private boolean isHoveringVertical(double mouseY)
|
||||
{
|
||||
return mouseY >= this.y && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Persistence
|
||||
{
|
||||
private int index;
|
||||
|
||||
public Persistence()
|
||||
{
|
||||
this(0);
|
||||
}
|
||||
|
||||
public Persistence(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void incrementIndex()
|
||||
{
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public void incrementIndex(int amount)
|
||||
{
|
||||
this.index += amount;
|
||||
}
|
||||
|
||||
public void decrementIndex()
|
||||
{
|
||||
this.index--;
|
||||
}
|
||||
|
||||
public void decrementIndex(int amount)
|
||||
{
|
||||
this.index -= amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonPiano extends GuiButtonBase
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private final Type type;
|
||||
private final SoundEvent sound;
|
||||
private final float pitch;
|
||||
|
||||
public GuiButtonPiano(int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
|
||||
{
|
||||
this(0, x, y, widthIn, heightIn, buttonText, sound, pitch, type, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonPiano(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
|
||||
{
|
||||
super(buttonId, x, y, widthIn, heightIn, buttonText, actionHandler);
|
||||
this.sound = sound;
|
||||
this.pitch = pitch;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
switch(this.type)
|
||||
{
|
||||
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);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, Config.getSkin().getButtonAlphaF());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
|
||||
|
||||
switch(this.type)
|
||||
{
|
||||
case LEFT:
|
||||
case NORMAL:
|
||||
case RIGHT:
|
||||
this.drawWhiteKey(hoverstate);
|
||||
break;
|
||||
case BLACK:
|
||||
this.drawBlackKey(hoverstate);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawWhiteKey(int hoverstate)
|
||||
{
|
||||
int textColor = this.getTextColor();
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected void drawBlackKey(int hoverstate)
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
|
||||
}
|
||||
|
||||
protected int getTextColor()
|
||||
{
|
||||
int textColor = 0x000000;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0x8B8B8B;
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPressSound(SoundHandler soundHandler)
|
||||
{
|
||||
soundHandler.play(SimpleSound.getMasterRecord(this.sound, this.pitch));
|
||||
}
|
||||
|
||||
private boolean isHoveringBlack(double mouseX, double mouseY)
|
||||
{
|
||||
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(double mouseX, double 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(double mouseX, double 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(double mouseX, double 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
|
||||
protected boolean isPressable(double mouseX, double mouseY)
|
||||
{
|
||||
switch(this.type)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum Type
|
||||
{
|
||||
LEFT,
|
||||
NORMAL,
|
||||
RIGHT,
|
||||
BLACK;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,20 @@
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonTab extends GuiButton
|
||||
{
|
||||
private final int index;
|
||||
|
||||
public GuiButtonTab(int buttonId, int x, int y, int widthIn, int heightIn, int index)
|
||||
public GuiButtonTab(int x, int y, int widthIn, int heightIn)
|
||||
{
|
||||
super(buttonId, x, y, widthIn, heightIn, null);
|
||||
this.index = index;
|
||||
super(0, x, y, widthIn, heightIn, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,9 +24,4 @@ public class GuiButtonTab extends GuiButton
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiButtonTooltip extends GuiButtonBase
|
||||
{
|
||||
protected String tooltip;
|
||||
|
||||
public GuiButtonTooltip(int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
|
||||
{
|
||||
this(0, x, y, widthIn, heightIn, buttonText, tooltip, actionHandler);
|
||||
}
|
||||
|
||||
public GuiButtonTooltip(int id, int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
|
||||
{
|
||||
super(id, x, y, widthIn, heightIn, buttonText, actionHandler);
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public void renderTooltip(int mouseX, int mouseY)
|
||||
{
|
||||
if(this.hovered && this.tooltip != null)
|
||||
{
|
||||
List<String> list = Arrays.asList(this.tooltip.split("\n"));
|
||||
|
||||
if(!list.isEmpty())
|
||||
{
|
||||
int tooltipWidth = Minecraft.getInstance().fontRenderer.getStringWidth(this.tooltip) + 9;
|
||||
int width = Minecraft.getInstance().currentScreen.width;
|
||||
int height = Minecraft.getInstance().currentScreen.height;
|
||||
|
||||
GuiUtils.drawHoveringText(list, mouseX, mouseY, width, height, tooltipWidth, Minecraft.getInstance().fontRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +1,80 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
import exopandora.worldhandler.gui.button.persistence.SliderValue;
|
||||
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.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.Objects;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiSlider<T> extends GuiButton
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.logic.ILogic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiSlider extends GuiButtonBase
|
||||
{
|
||||
private boolean isMouseDown;
|
||||
private boolean isActive;
|
||||
private final Persistence persistence;
|
||||
private final ILogicSlider logic;
|
||||
private final Container container;
|
||||
|
||||
private final Object key;
|
||||
private final String name;
|
||||
private final ISliderResponder responder;
|
||||
private final Container frame;
|
||||
private final ButtonValue<SliderValue> persistence;
|
||||
private boolean dragging;
|
||||
|
||||
public GuiSlider(Content content, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder)
|
||||
public GuiSlider(int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
|
||||
{
|
||||
super(Integer.MAX_VALUE, x, y, width, height, null);
|
||||
this.frame = frame;
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.responder = responder;
|
||||
this.persistence = content.getPersistence(key);
|
||||
this.initValues(Math.round(min), Math.round(max), Math.round(start));
|
||||
this.displayString = this.getDisplayString();
|
||||
this(0, x, y, widthIn, heightIn, min, max, start, container, logic);
|
||||
}
|
||||
|
||||
private void initValues(double min, double max, double start)
|
||||
public GuiSlider(int id, int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
|
||||
{
|
||||
if(this.persistence.getObject() == null)
|
||||
super(id, x, y, widthIn, heightIn, null, null);
|
||||
this.logic = Objects.requireNonNull(logic);
|
||||
this.container = Objects.requireNonNull(container);
|
||||
this.persistence = this.container.getContent().getPersistence(this.logic.getId(), () -> new Persistence(min, max, min == max ? 0.0 : ((start - min) / (max - min))));
|
||||
this.persistence.validate(min, max);
|
||||
this.logic.onChangeSliderValue(this.persistence.getValueInt());
|
||||
this.updateDisplayString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
if(min == max)
|
||||
if(this.dragging)
|
||||
{
|
||||
this.persistence.setObject(new SliderValue(min, max, 0.0D));
|
||||
this.persistence.setValue((mouseX - (this.x + 4)) / (float) (this.width - 8));
|
||||
this.updateSlider();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setObject(new SliderValue(min, max, (start - min) / (max - min)));
|
||||
}
|
||||
}
|
||||
else if(this.persistence.getObject().getMin() != min || this.persistence.getObject().getMax() != max)
|
||||
{
|
||||
this.persistence.setObject(new SliderValue(min, max, (int) MathHelper.clamp(this.getValue(), min, max)));
|
||||
|
||||
int xOffset = Config.getSkin().getTextureType().equals("resourcepack") ? 0 : -46;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
|
||||
this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.y, 0, 66 + xOffset, 4, 20);
|
||||
this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.y, 196, 66 + xOffset, 4, 20);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void setPosition(double position)
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY)
|
||||
{
|
||||
this.persistence.getObject().setPosition(position);
|
||||
this.persistence.setValue((mouseX - (this.x + 4)) / (this.width - 8));
|
||||
this.updateSlider();
|
||||
this.dragging = true;
|
||||
}
|
||||
|
||||
private double getPosition()
|
||||
@Override
|
||||
public void onRelease(double mouseX, double mouseY)
|
||||
{
|
||||
return this.persistence.getObject().getPosition();
|
||||
}
|
||||
|
||||
private void setValue(int value)
|
||||
{
|
||||
this.persistence.getObject().setValue(value);
|
||||
}
|
||||
|
||||
private int getValue()
|
||||
{
|
||||
return this.persistence.getObject().getValue();
|
||||
}
|
||||
|
||||
private String getDisplayString()
|
||||
{
|
||||
return this.responder.getText(this.key, I18n.format(this.name), this.getValue());
|
||||
super.onRelease(mouseX, mouseY);
|
||||
this.dragging = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,114 +83,107 @@ public class GuiSlider<T> extends GuiButton
|
||||
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)
|
||||
private void updateSlider()
|
||||
{
|
||||
float sliderValue = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
|
||||
|
||||
if(sliderValue < 0.0F)
|
||||
if(this.persistence.getValue() < 0.0F)
|
||||
{
|
||||
sliderValue = 0.0F;
|
||||
this.persistence.setValue(0.0F);
|
||||
}
|
||||
|
||||
if(sliderValue > 1.0F)
|
||||
if(this.persistence.getValue() > 1.0F)
|
||||
{
|
||||
sliderValue = 1.0F;
|
||||
this.persistence.setValue(1.0F);
|
||||
}
|
||||
|
||||
this.setPosition(sliderValue);
|
||||
this.displayString = this.getDisplayString();
|
||||
this.responder.setValue(this.key, this.getValue());
|
||||
this.updateDisplayString();
|
||||
this.logic.onChangeSliderValue(this.persistence.getValueInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(Minecraft mc, int mouseX, int mouseY)
|
||||
private void updateDisplayString()
|
||||
{
|
||||
if(this.visible)
|
||||
int value = this.persistence.getValueInt();
|
||||
String suffix = this.logic.formatValue(value) + this.logic.formatSuffix(value);
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
this.displayString = TextFormatting.shortenString(this.logic.formatPrefix(value), this.width - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static interface ILogicSlider extends ILogic
|
||||
{
|
||||
String formatPrefix(int value);
|
||||
String formatSuffix(int value);
|
||||
String formatValue(int value);
|
||||
|
||||
void onChangeSliderValue(int value);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Persistence
|
||||
{
|
||||
private double min;
|
||||
private double max;
|
||||
private double value;
|
||||
|
||||
private Persistence(double min, double max)
|
||||
{
|
||||
if(this.isMouseDown)
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public Persistence(double min, double max, double value)
|
||||
{
|
||||
this(min, max);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public double getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValueInt()
|
||||
{
|
||||
return (int) Math.round(this.min + (this.max - this.min) * this.value);
|
||||
}
|
||||
|
||||
public void setValueInt(int value)
|
||||
{
|
||||
this.value = this.intToValue(value);
|
||||
}
|
||||
|
||||
public void validate(double min, double max)
|
||||
{
|
||||
if(this.getMin() != min || this.getMax() != max)
|
||||
{
|
||||
this.update(mouseX, mouseY);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
private double intToValue(int value)
|
||||
{
|
||||
if(this.min == this.max)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
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.getPosition() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
|
||||
this.drawTexturedModalRect(this.x + (int) (this.getPosition() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
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);
|
||||
return (value - this.min) / (this.max - this.min);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,261 +1,76 @@
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiTextFieldTooltip
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiTextFieldTooltip extends GuiTextField
|
||||
{
|
||||
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;
|
||||
}
|
||||
private String tooltip;
|
||||
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height)
|
||||
{
|
||||
this(x, y, width, height, null);
|
||||
this(0, x, y, width, height, null);
|
||||
}
|
||||
|
||||
public void setGuiResponder(GuiPageButtonList.GuiResponder responder)
|
||||
public GuiTextFieldTooltip(int id, int x, int y, int width, int height)
|
||||
{
|
||||
this.textfield.setGuiResponder(responder);
|
||||
this(id, x, y, width, height, null);
|
||||
}
|
||||
|
||||
public void updateCursorCounter()
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height, String tooltip)
|
||||
{
|
||||
this.textfield.updateCursorCounter();
|
||||
this(0, x, y, width, height, tooltip);
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
public GuiTextFieldTooltip(int id, int x, int y, int width, int height, String tooltip)
|
||||
{
|
||||
this.textfield.setText(text);
|
||||
super(id, Minecraft.getInstance().fontRenderer, x, y, width, height);
|
||||
this.setMaxStringLength(Integer.MAX_VALUE);
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
@Override
|
||||
public void drawTextField(int x, int y, float partialTicks)
|
||||
{
|
||||
return this.textfield.getText();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if(this.textfield.getText() != null)
|
||||
{
|
||||
return this.textfield.getText().matches("(\u00A7[a-f0-9k-or])+");
|
||||
}
|
||||
super.drawTextField(x, y, partialTicks);
|
||||
|
||||
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())
|
||||
if(this.getVisible() && !this.isFocused() && this.tooltip != null && ChatFormatting.stripFormatting(this.getText()).isEmpty())
|
||||
{
|
||||
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;
|
||||
int tx = this.getEnableBackgroundDrawing() ? this.x + 4 : this.x;
|
||||
int ty = this.getEnableBackgroundDrawing() ? this.y + (this.height - 8) / 2 : this.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);
|
||||
}
|
||||
Minecraft.getInstance().fontRenderer.drawStringWithShadow(this.tooltip, (float) tx, (float) ty, 0x7F7F7F);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxStringLength(int length)
|
||||
public void setTooltip(String tooltip)
|
||||
{
|
||||
this.textfield.setMaxStringLength(length);
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public int getMaxStringLength()
|
||||
public String getTooltip()
|
||||
{
|
||||
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;
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y)
|
||||
{
|
||||
this.textfield.x = x;
|
||||
this.textfield.y = y;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
this.textfield.width = width;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height)
|
||||
{
|
||||
this.textfield.height = height;
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
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.persistence.ButtonValue;
|
||||
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(ButtonValue<Integer> values)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonValue values)
|
||||
{
|
||||
EnumColor color = EnumColor.getColorFromId(values.getIndex());
|
||||
return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "color";
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
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, ButtonValue<T> values);
|
||||
|
||||
int getMax();
|
||||
|
||||
T getObject(int index);
|
||||
|
||||
String getDisplayString(ButtonValue<T> values);
|
||||
|
||||
default String getTooltipString(ButtonValue<T> values)
|
||||
{
|
||||
if(values != null && values.getObject() != null)
|
||||
{
|
||||
return values.getObject().toString() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package exopandora.worldhandler.gui.button.persistence;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ButtonValue<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 incrementIndex(int amount)
|
||||
{
|
||||
this.index += amount;
|
||||
}
|
||||
|
||||
public void decrementIndex()
|
||||
{
|
||||
this.index--;
|
||||
}
|
||||
|
||||
public void decrementIndex(int amount)
|
||||
{
|
||||
this.index -= amount;
|
||||
}
|
||||
|
||||
public T getObject()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
|
||||
public void setObject(T object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package exopandora.worldhandler.gui.button.persistence;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SliderValue
|
||||
{
|
||||
private final double min;
|
||||
private final double max;
|
||||
private double position;
|
||||
|
||||
private SliderValue(double min, double max)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public SliderValue(double min, double max, double position)
|
||||
{
|
||||
this(min, max);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public SliderValue(double min, double max, int value)
|
||||
{
|
||||
this(min, max);
|
||||
this.position = this.valueToPosition(value);
|
||||
}
|
||||
|
||||
public double getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public double getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public double getPosition()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public void setPosition(double position)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return (int) (this.min + (this.max - this.min) * this.position);
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.position = this.valueToPosition(value);
|
||||
}
|
||||
|
||||
private double valueToPosition(int value)
|
||||
{
|
||||
if(this.min == this.max)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (value - this.min) / (this.max - this.min);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package exopandora.worldhandler.gui.category;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Categories
|
||||
{
|
||||
public static final Category MAIN;
|
||||
@@ -29,7 +29,7 @@ public class Categories
|
||||
|
||||
private static Category getRegisteredCategory(String name)
|
||||
{
|
||||
Category category = Category.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
Category category = Category.REGISTRY.get(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(category == null)
|
||||
{
|
||||
|
||||
@@ -10,14 +10,17 @@ import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Category
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Category extends ForgeRegistryEntry<Category>
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Category> REGISTRY = new RegistryNamespaced<ResourceLocation, Category>();
|
||||
public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "category"});
|
||||
public static final IRegistry<Category> REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey<Category>(new ResourceLocation(NAMESPACE, "main")));
|
||||
|
||||
private final List<Content> contents;
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package exopandora.worldhandler.gui.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.config.ConfigButcher;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
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.DummyCategoryElement;
|
||||
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 DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyCategoryElement(I18n.format("gui.worldhandler.config.category.sliders"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSliders.CATEGORY)).getChildElements()));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,31 @@ 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;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class Container extends GuiScreen implements IContainer
|
||||
{
|
||||
protected final List<IElement> elements = new ArrayList<IElement>();
|
||||
|
||||
@Override
|
||||
public void add(GuiButton button)
|
||||
public <T extends GuiButton> T add(T button)
|
||||
{
|
||||
this.buttonList.add(button);
|
||||
return super.addButton(button);
|
||||
}
|
||||
|
||||
public <T extends GuiTextField> T add(T textfield)
|
||||
{
|
||||
this.children.add(textfield);
|
||||
return textfield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IContainer
|
||||
{
|
||||
void add(GuiButton button);
|
||||
<T extends GuiButton> T add(T button);
|
||||
|
||||
void initButtons();
|
||||
void add(Element element);
|
||||
|
||||
String getPlayer();
|
||||
|
||||
Content getContent();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,11 +2,12 @@ package exopandora.worldhandler.gui.content;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcher;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcherSettings;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContainers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
@@ -18,24 +19,28 @@ 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.ContentScoreboardObjectives;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPotions;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentRecipes;
|
||||
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.ContentSettings;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSummon;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Content implements IContent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class Content extends ForgeRegistryEntry<Content> implements IContent
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Content> REGISTRY = new RegistryNamespaced<ResourceLocation, Content>();
|
||||
public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "content"});
|
||||
public static final IRegistry<Content> REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey<Content>(new ResourceLocation(NAMESPACE, "main")));
|
||||
|
||||
public static void registerContents()
|
||||
{
|
||||
@@ -78,36 +83,38 @@ public abstract class Content implements IContent
|
||||
//NO CATEGORY
|
||||
registerContent(20, "potions", new ContentPotions());
|
||||
registerContent(21, "butcher", new ContentButcher());
|
||||
registerContent(22, "butcher_settings", new ContentButcherSettings());
|
||||
registerContent(23, "settings", new ContentSettings());
|
||||
}
|
||||
|
||||
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, ButtonValue> persistence;
|
||||
|
||||
public <T> ButtonValue<T> getPersistence(Object id)
|
||||
{
|
||||
if(this.persistence == null)
|
||||
{
|
||||
this.persistence = new HashMap<Object, ButtonValue>();
|
||||
}
|
||||
|
||||
if(this.persistence.containsKey(id))
|
||||
{
|
||||
return this.persistence.get(id);
|
||||
}
|
||||
|
||||
ButtonValue<T> values = new ButtonValue<T>();
|
||||
|
||||
this.persistence.put(id, values);
|
||||
|
||||
return values;
|
||||
}
|
||||
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<String, Object> persistence;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getPersistence(String id, Supplier<T> supplier)
|
||||
{
|
||||
if(this.persistence == null)
|
||||
{
|
||||
this.persistence = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
if(this.persistence.containsKey(id))
|
||||
{
|
||||
return (T) this.persistence.get(id);
|
||||
}
|
||||
|
||||
T object = supplier.get();
|
||||
this.persistence.put(id, object);
|
||||
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Contents
|
||||
{
|
||||
public static final Content MAIN;
|
||||
@@ -40,50 +40,54 @@ public class Contents
|
||||
|
||||
public static final ContentChild POTIONS;
|
||||
public static final ContentChild BUTCHER;
|
||||
public static final ContentChild BUTCHER_SETTINGS;
|
||||
public static final ContentChild SETTINGS;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Contents.getRegisteredContainer("main");
|
||||
CONTAINERS = Contents.getRegisteredContainer("containers");
|
||||
MULTIPLAYER = Contents.getRegisteredContainer("multiplayer");
|
||||
MAIN = Contents.getRegisteredContent("main");
|
||||
CONTAINERS = Contents.getRegisteredContent("containers");
|
||||
MULTIPLAYER = Contents.getRegisteredContent("multiplayer");
|
||||
|
||||
SUMMON = Contents.getRegisteredContainer("summon");
|
||||
SUMMON = Contents.getRegisteredContent("summon");
|
||||
|
||||
CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item");
|
||||
ENCHANTMENT = Contents.getRegisteredContainer("enchantment");
|
||||
CUSTOM_ITEM = Contents.getRegisteredContent("custom_item");
|
||||
ENCHANTMENT = Contents.getRegisteredContent("enchantment");
|
||||
|
||||
EDIT_BLOCKS = Contents.getRegisteredContainer("edit_blocks");
|
||||
SIGN_EDITOR = Contents.getRegisteredContainer("sign_editor");
|
||||
NOTE_EDITOR = Contents.getRegisteredContainer("note_editor");
|
||||
EDIT_BLOCKS = Contents.getRegisteredContent("edit_blocks");
|
||||
SIGN_EDITOR = Contents.getRegisteredContent("sign_editor");
|
||||
NOTE_EDITOR = Contents.getRegisteredContent("note_editor");
|
||||
|
||||
WORLD_INFO = Contents.getRegisteredContainer("world");
|
||||
GAMERULES = Contents.getRegisteredContainer("gamerules");
|
||||
RECIPES = Contents.getRegisteredContainer("recipes");
|
||||
WORLD_INFO = Contents.getRegisteredContent("world");
|
||||
GAMERULES = Contents.getRegisteredContent("gamerules");
|
||||
RECIPES = Contents.getRegisteredContent("recipes");
|
||||
|
||||
PLAYER = Contents.getRegisteredContainer("player");
|
||||
EXPERIENCE = Contents.getRegisteredContainer("experience");
|
||||
ADVANCEMENTS = Contents.getRegisteredContainer("advancements");
|
||||
PLAYER = Contents.getRegisteredContent("player");
|
||||
EXPERIENCE = Contents.getRegisteredContent("experience");
|
||||
ADVANCEMENTS = Contents.getRegisteredContent("advancements");
|
||||
|
||||
SCOREBOARD_OBJECTIVES = Contents.getRegisteredContainer("scoreboard_objectives");
|
||||
SCOREBOARD_TEAMS = Contents.getRegisteredContainer("scoreboard_teams");
|
||||
SCOREBOARD_PLAYERS = Contents.getRegisteredContainer("scoreboard_players");
|
||||
SCOREBOARD_OBJECTIVES = Contents.getRegisteredContent("scoreboard_objectives");
|
||||
SCOREBOARD_TEAMS = Contents.getRegisteredContent("scoreboard_teams");
|
||||
SCOREBOARD_PLAYERS = Contents.getRegisteredContent("scoreboard_players");
|
||||
|
||||
CHANGE_WORLD = Contents.getRegisteredContainer("change_world");
|
||||
CONTINUE = Contents.getRegisteredContainer("continue");
|
||||
CHANGE_WORLD = (ContentChild) Contents.getRegisteredContent("change_world");
|
||||
CONTINUE = (ContentContinue) Contents.getRegisteredContent("continue");
|
||||
|
||||
POTIONS = Contents.getRegisteredContainer("potions");
|
||||
BUTCHER = Contents.getRegisteredContainer("butcher");
|
||||
POTIONS = (ContentChild) Contents.getRegisteredContent("potions");
|
||||
BUTCHER = (ContentChild) Contents.getRegisteredContent("butcher");
|
||||
BUTCHER_SETTINGS = (ContentChild) Contents.getRegisteredContent("butcher_settings");
|
||||
SETTINGS = (ContentChild) Contents.getRegisteredContent("settings");
|
||||
}
|
||||
|
||||
private static <T extends Content> T getRegisteredContainer(String name)
|
||||
private static Content getRegisteredContent(String name)
|
||||
{
|
||||
Content content = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
Content content = Content.REGISTRY.get(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(content == null)
|
||||
{
|
||||
throw new IllegalStateException("Invalid Container requested: " + name);
|
||||
throw new IllegalStateException("Invalid Content requested: " + name);
|
||||
}
|
||||
|
||||
return (T) content;
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,10 @@ 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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IContent
|
||||
{
|
||||
default void init(Container container)
|
||||
@@ -24,12 +23,7 @@ public interface IContent
|
||||
|
||||
void initButtons(Container container, int x, int y);
|
||||
|
||||
default void updateScreen(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
default void tick(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -39,16 +33,6 @@ public interface IContent
|
||||
|
||||
}
|
||||
|
||||
default void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void onPlayerNameChanged(String username)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package exopandora.worldhandler.gui.content.element;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class Element implements IElement
|
||||
{
|
||||
protected int x;
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.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)
|
||||
{
|
||||
|
||||
}
|
||||
void tick();
|
||||
void draw(int mouseX, int mouseY, float partialTicks);
|
||||
}
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
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.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
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[] buttonIds;
|
||||
private final List<Node> list;
|
||||
private final ILogicClickList logic;
|
||||
private final Content content;
|
||||
private final ElementClickList parent;
|
||||
private final int depth;
|
||||
|
||||
private GuiButtonList button;
|
||||
private ElementClickList child;
|
||||
|
||||
public ElementClickList(int x, int y, List<Node> list, int[] buttonIds, Content content, ILogicClickList logic)
|
||||
{
|
||||
this(x, y, list, buttonIds, content, logic, null);
|
||||
}
|
||||
|
||||
private ElementClickList(int x, int y, List<Node> list, int[] buttonIds, Content content, ILogicClickList logic, ElementClickList parent)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.buttonIds = buttonIds;
|
||||
this.logic = logic;
|
||||
this.content = content;
|
||||
this.parent = parent;
|
||||
this.depth = this.parent != null ? this.parent.depth + 1 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
container.add(this.button = new GuiButtonList(this.getButtonId(), this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.content, new IListButtonLogic<Node>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonValue<Node> values)
|
||||
{
|
||||
content.getPersistence(logic.getId() + (depth + 1)).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(ButtonValue<Node> values)
|
||||
{
|
||||
return logic.translate(getKeys());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipString(ButtonValue<Node> values)
|
||||
{
|
||||
if(values != null && values.getObject() != null)
|
||||
{
|
||||
return values.getObject().getKey() + " (" + (values.getIndex() + 1) + "/" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return logic.getId() + depth;
|
||||
}
|
||||
}));
|
||||
|
||||
Node node = this.getValues().getObject();
|
||||
this.logic.consumeKey(this.getKeys());
|
||||
|
||||
if(node.getEntries() != null)
|
||||
{
|
||||
this.child = new ElementClickList(this.x, this.y + 24, node.getEntries(), this.buttonIds, this.content, this.logic, this);
|
||||
this.child.initButtons(container);
|
||||
}
|
||||
else if(this.depth < this.buttonIds.length)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.getButtonId(), this.x, this.y + 24, 114, 20, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ButtonValue<Node> getValues()
|
||||
{
|
||||
if(this.button != null)
|
||||
{
|
||||
return this.content.<Node>getPersistence(this.button.getLogic().getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.getButtonId())
|
||||
{
|
||||
this.button.actionPerformed(container, button);
|
||||
return true;
|
||||
}
|
||||
else if(this.child != null)
|
||||
{
|
||||
return this.child.actionPerformed(container, button);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private int getButtonId()
|
||||
{
|
||||
return this.buttonIds[this.depth - 1];
|
||||
}
|
||||
|
||||
private String[] getKeys()
|
||||
{
|
||||
return this.getKeys(new String[this.depth]);
|
||||
}
|
||||
|
||||
private String[] getKeys(String[] keys)
|
||||
{
|
||||
if(keys != null && this.depth <= keys.length)
|
||||
{
|
||||
keys[this.depth - 1] = this.getValues().getObject().getKey();
|
||||
}
|
||||
|
||||
return this.parent != null ? this.parent.getKeys(keys) : keys;
|
||||
}
|
||||
}
|
||||
@@ -1,158 +1,157 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.persistence.ButtonValue;
|
||||
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 exopandora.worldhandler.gui.logic.ILogicColorMenu;
|
||||
import exopandora.worldhandler.gui.logic.ILogicMapped;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementColorMenu extends Element
|
||||
{
|
||||
private static final List<EnumColor> COLORS = new ArrayList<EnumColor>();
|
||||
|
||||
static
|
||||
{
|
||||
COLORS.add(EnumColor.DEFAULT);
|
||||
COLORS.add(EnumColor.YELLOW);
|
||||
COLORS.add(EnumColor.GOLD);
|
||||
COLORS.add(EnumColor.DARK_RED);
|
||||
COLORS.add(EnumColor.RED);
|
||||
COLORS.add(EnumColor.LIGHT_PURPLE);
|
||||
COLORS.add(EnumColor.DARK_PURPLE);
|
||||
COLORS.add(EnumColor.BLUE);
|
||||
COLORS.add(EnumColor.DARK_BLUE);
|
||||
COLORS.add(EnumColor.DARK_AQUA);
|
||||
COLORS.add(EnumColor.AQUA);
|
||||
COLORS.add(EnumColor.GREEN);
|
||||
COLORS.add(EnumColor.DARK_GREEN);
|
||||
COLORS.add(EnumColor.BLACK);
|
||||
COLORS.add(EnumColor.DARK_GRAY);
|
||||
COLORS.add(EnumColor.GRAY);
|
||||
COLORS.add(EnumColor.WHITE);
|
||||
}
|
||||
|
||||
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)
|
||||
public ElementColorMenu(int x, int y, String translationKey, ColoredString string)
|
||||
{
|
||||
this(content, x, y, translationKey, string, ids, new ILogicColorMenu(){});
|
||||
this(x, y, translationKey, string, new ILogicColorMenu(){});
|
||||
}
|
||||
|
||||
public ElementColorMenu(Content content, int x, int y, String translationKey, ColoredString string, int[] ids, ILogicColorMenu logic)
|
||||
public ElementColorMenu(int x, int y, String translationKey, ColoredString string, 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::validate);
|
||||
this.textField.setTextFormatter(this.string::textFormatter);
|
||||
this.textField.setText(this.string.getText());
|
||||
this.textField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
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());
|
||||
}
|
||||
this.string.setText(text);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
if(this.logic.drawButtons())
|
||||
container.add(this.textField);
|
||||
|
||||
if(this.logic.doDrawButtons())
|
||||
{
|
||||
container.add(this.colorList = new GuiButtonList(this.ids[0], this.x + 118, this.y + 24, 114, 20, this.content, new ColorListButtonLogic()
|
||||
container.add(new GuiButtonList<EnumColor>(this.x + 118, this.y + 24, COLORS, 114, 20, container, new ILogicMapped<EnumColor>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonValue<Integer> values)
|
||||
public String translate(EnumColor item)
|
||||
{
|
||||
string.setColor(values.getIndex());
|
||||
return item + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + item.getFormat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toTooltip(EnumColor item)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatTooltip(EnumColor item, int index, int max)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumColor item)
|
||||
{
|
||||
ElementColorMenu.this.string.setColor(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return logic.getId();
|
||||
return ElementColorMenu.this.logic.getId();
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(this.ids[1], this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? ChatFormatting.ITALIC : ChatFormatting.RESET) + "I"));
|
||||
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))
|
||||
container.add(new GuiButtonBase(this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? ChatFormatting.ITALIC : ChatFormatting.RESET) + "I", () ->
|
||||
{
|
||||
if(this.textField.textboxKeyTyped(charTyped, keyCode))
|
||||
{
|
||||
this.string.setText(this.textField.getText());
|
||||
container.initButtons();
|
||||
}
|
||||
}
|
||||
this.string.setItalic(!this.string.isItalic());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 - 1, this.y + 48, 20, 20, (this.string.isBold() ? ChatFormatting.BOLD : ChatFormatting.RESET) + "B", () ->
|
||||
{
|
||||
this.string.setBold(!this.string.isBold());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, (this.string.isUnderlined() ? ChatFormatting.UNDERLINE : ChatFormatting.RESET) + "U", () ->
|
||||
{
|
||||
this.string.setUnderlined(!this.string.isUnderlined());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, (this.string.isStriked() ? ChatFormatting.STRIKETHROUGH : ChatFormatting.RESET) + "S", () ->
|
||||
{
|
||||
this.string.setStriked(!this.string.isStriked());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, (this.string.isObfuscated() ? ChatFormatting.OBFUSCATED : ChatFormatting.RESET) + "O", () ->
|
||||
{
|
||||
this.string.setObfuscated(!this.string.isObfuscated());
|
||||
container.initGui();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
public void tick()
|
||||
{
|
||||
if(this.logic.drawTextfield())
|
||||
{
|
||||
this.textField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
this.textField.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.textField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList.Persistence;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.gui.logic.ILogicMapped;
|
||||
import exopandora.worldhandler.helper.Node;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementMultiButtonList extends Element
|
||||
{
|
||||
private final List<Node> items;
|
||||
private final ILogicClickList logic;
|
||||
private final ElementMultiButtonList parent;
|
||||
private final int depth;
|
||||
private final int maxDepth;
|
||||
|
||||
public ElementMultiButtonList(int x, int y, List<Node> list, int maxDepth, ILogicClickList logic)
|
||||
{
|
||||
this(x, y, list, maxDepth, logic, null);
|
||||
}
|
||||
|
||||
private ElementMultiButtonList(int x, int y, List<Node> list, int maxDepth, ILogicClickList logic, ElementMultiButtonList parent)
|
||||
{
|
||||
super(x, y);
|
||||
this.items = list;
|
||||
this.logic = logic;
|
||||
this.parent = parent;
|
||||
this.depth = this.parent != null ? this.parent.getDepth() + 1 : 0;
|
||||
this.maxDepth = maxDepth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
container.add(new GuiButtonList<Node>(this.x, this.y, this.items, 114, 20, container, new ILogicMapped<Node>()
|
||||
{
|
||||
@Override
|
||||
public String translate(Node item)
|
||||
{
|
||||
return ElementMultiButtonList.this.logic.translate(ElementMultiButtonList.this.buildKey(container, ElementMultiButtonList.this.logic::buildTranslationKey), ElementMultiButtonList.this.getDepth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toTooltip(Node item)
|
||||
{
|
||||
return item.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatTooltip(Node item, int index, int max)
|
||||
{
|
||||
return ILogicMapped.super.formatTooltip(item, index, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Node item)
|
||||
{
|
||||
ElementMultiButtonList.this.getPersistence(container, 1).setIndex(0);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return ElementMultiButtonList.this.getId();
|
||||
}
|
||||
}));
|
||||
|
||||
Node node = this.getNode(container);
|
||||
this.logic.onClick(this.buildKey(container, this.logic::buildEventKey), this.getDepth());
|
||||
|
||||
if(node.getEntries() != null)
|
||||
{
|
||||
ElementMultiButtonList child = new ElementMultiButtonList(this.x, this.y + 24, node.getEntries(), this.maxDepth, this.logic, this);
|
||||
child.initButtons(container);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x = this.getDepth() + 1; x < this.maxDepth; x++)
|
||||
{
|
||||
GuiButtonBase button = new GuiButtonBase(this.x, this.y + 24 * x, 114, 20, null, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected int getDepth()
|
||||
{
|
||||
return this.depth;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ElementMultiButtonList getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
protected String getId()
|
||||
{
|
||||
return this.getId(0);
|
||||
}
|
||||
|
||||
protected String getId(int offset)
|
||||
{
|
||||
return String.format("%s%d", ElementMultiButtonList.this.logic.getId(), ElementMultiButtonList.this.depth + offset);
|
||||
}
|
||||
|
||||
protected Persistence getPersistence(Container container)
|
||||
{
|
||||
return this.getPersistence(container, 0);
|
||||
}
|
||||
|
||||
protected Persistence getPersistence(Container container, int offset)
|
||||
{
|
||||
return container.getContent().getPersistence(this.getId(offset), Persistence::new);
|
||||
}
|
||||
|
||||
protected Node getNode(Container container)
|
||||
{
|
||||
return this.items.get(this.getPersistence(container).getIndex());
|
||||
}
|
||||
|
||||
protected String buildKey(Container container, BiFunction<List<String>, Integer, String> factory)
|
||||
{
|
||||
List<String> nodes = new ArrayList<String>(ElementMultiButtonList.this.depth + 1);
|
||||
ElementMultiButtonList element = ElementMultiButtonList.this;
|
||||
|
||||
while(element != null)
|
||||
{
|
||||
nodes.add(element.getNode(container).getKey());
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
Collections.reverse(nodes);
|
||||
return factory.apply(nodes, ElementMultiButtonList.this.depth);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,43 @@
|
||||
package exopandora.worldhandler.gui.content.element.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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 exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ElementPageList<T, K> extends Element
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementPageList<T> extends Element
|
||||
{
|
||||
private final List<T> list;
|
||||
private final ILogicPageList<T, K> logic;
|
||||
private final int length;
|
||||
private final List<T> items;
|
||||
private final ILogicPageList<T> logic;
|
||||
private final Persistence persistence;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int[] ids;
|
||||
private final ButtonValue<Integer> values;
|
||||
private final int length;
|
||||
|
||||
public ElementPageList(int x, int y, List<T> list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList<T, K> logic)
|
||||
public ElementPageList(int x, int y, List<T> items, int width, int height, int length, Container container, ILogicPageList<T> logic)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.length = length;
|
||||
this.items = Objects.requireNonNull(items);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.logic = logic;
|
||||
this.values = content.getPersistence(logic.getId());
|
||||
this.ids = ids;
|
||||
this.length = length;
|
||||
this.logic = Objects.requireNonNull(logic);
|
||||
this.items.sort((a, b) -> this.logic.translate(a).compareTo(this.logic.translate(b)));
|
||||
this.persistence = container.getContent().getPersistence(logic.getId(), Persistence::new);
|
||||
|
||||
this.list.sort((a, b) -> this.logic.translate(a).compareTo(this.logic.translate(b)));
|
||||
|
||||
if(this.values.getObject() == null)
|
||||
if(!this.items.isEmpty())
|
||||
{
|
||||
this.values.setObject(0);
|
||||
this.values.setIndex(Math.max(0, this.list.indexOf(this.logic.getObject(initial))));
|
||||
|
||||
if(initial == null)
|
||||
{
|
||||
this.logic.onClick(this.list.get(0));
|
||||
}
|
||||
this.logic.onClick(this.items.get(this.persistence.getSelectedIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +50,18 @@ public class ElementPageList<T, K> extends Element
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
boolean extended = (this.list.size() == this.length + 1);
|
||||
boolean extended = (this.items.size() == this.length + 1);
|
||||
|
||||
if(!extended)
|
||||
{
|
||||
int buttonWidth = (this.width - 4) / 2;
|
||||
|
||||
GuiButtonWorldHandler left = new GuiButtonWorldHandler(this.ids[0], this.x, this.y + (this.height + 4) * this.length, buttonWidth + 1, this.height, "<");
|
||||
GuiButtonWorldHandler right = new GuiButtonWorldHandler(this.ids[1], this.x + 5 + buttonWidth, this.y + (this.height + 4) * this.length, buttonWidth, this.height, ">");
|
||||
|
||||
left.enabled = this.values.getObject() > 0;
|
||||
right.enabled = this.values.getObject() < this.getTotalPages() - 1;
|
||||
|
||||
GuiButtonBase left = new GuiButtonBase(this.x, this.y + (this.height + 4) * this.length, buttonWidth + 1, this.height, "<", () -> this.goLeft(container));
|
||||
left.enabled = this.persistence.getPage() > 0;
|
||||
container.add(left);
|
||||
|
||||
GuiButtonBase right = new GuiButtonBase(this.x + 5 + buttonWidth, this.y + (this.height + 4) * this.length, buttonWidth, this.height, ">", () -> this.goRight(container));
|
||||
right.enabled = this.persistence.getPage() < this.getTotalPages() - 1;
|
||||
container.add(right);
|
||||
}
|
||||
|
||||
@@ -81,84 +69,118 @@ public class ElementPageList<T, K> extends Element
|
||||
|
||||
for(int x = 0; x < length; x++)
|
||||
{
|
||||
int index = this.values.getObject() * length + x;
|
||||
int index = this.persistence.getPage() * length + x;
|
||||
GuiButtonBase button;
|
||||
|
||||
if(index < this.list.size())
|
||||
if(index < this.items.size())
|
||||
{
|
||||
T entry = this.list.get(index);
|
||||
this.logic.onRegister(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer), this.logic.getRegistryName(entry), this.values.getIndex() != index, entry, container);
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.ids[2], this.x, this.y + (this.height + 4) * x, this.width, this.height, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.ids[0])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value - Math.min(10, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value - 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value + Math.min(10, this.getTotalPages() - 1 - value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value + 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[2])
|
||||
{
|
||||
for(int x = 0; x < this.list.size(); x++)
|
||||
{
|
||||
T entry = this.list.get(x);
|
||||
|
||||
if(TextFormatting.shortenString(this.logic.translate(entry), this.width, Minecraft.getMinecraft().fontRenderer).equals(button.displayString))
|
||||
T item = this.items.get(index);
|
||||
String text = TextFormatting.shortenString(this.logic.translate(item), this.width, Minecraft.getInstance().fontRenderer);
|
||||
button = this.logic.onRegister(this.x, this.y + (this.height + 4) * x, this.width, this.height, text, item, () ->
|
||||
{
|
||||
this.values.setIndex(x);
|
||||
this.logic.onClick(entry);
|
||||
container.initGui();
|
||||
return true;
|
||||
this.persistence.setSelectedIndex(index);
|
||||
this.logic.onClick(item);
|
||||
});
|
||||
|
||||
if(this.logic.doDisable())
|
||||
{
|
||||
button.enabled = this.persistence.getSelectedIndex() != index;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
button = new GuiButtonBase(this.x, this.y + (this.height + 4) * x, this.width, this.height, null, null);
|
||||
button.enabled = false;
|
||||
}
|
||||
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
public void tick()
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawString((this.values.getObject() + 1) + "/" + this.getTotalPages(), this.x, this.y - 11, ConfigSkin.getHeadlineColor());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
Minecraft.getInstance().fontRenderer.drawString(String.format("%d/%d", this.persistence.getPage() + 1, this.getTotalPages()), this.x, this.y - 11, Config.getSkin().getHeadlineColor());
|
||||
}
|
||||
|
||||
private void goLeft(Container container)
|
||||
{
|
||||
int page = this.persistence.getPage();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.persistence.setPage(page - Math.min(10, page));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setPage(page - 1);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
private void goRight(Container container)
|
||||
{
|
||||
int page = this.persistence.getPage();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.persistence.setPage(page + Math.min(10, this.getTotalPages() - 1 - page));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setPage(page + 1);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
private int getTotalPages()
|
||||
{
|
||||
return (int) Math.ceil((float) this.list.size() / this.length);
|
||||
return (int) Math.ceil((float) this.items.size() / this.length);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Persistence
|
||||
{
|
||||
private int page;
|
||||
private int selectedIndex;
|
||||
|
||||
public Persistence()
|
||||
{
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Persistence(int page, int selectedIndex)
|
||||
{
|
||||
this.page = page;
|
||||
this.selectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
public int getPage()
|
||||
{
|
||||
return this.page;
|
||||
}
|
||||
|
||||
public void setPage(int page)
|
||||
{
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getSelectedIndex()
|
||||
{
|
||||
return this.selectedIndex;
|
||||
}
|
||||
|
||||
public void setSelectedIndex(int selectedIndex)
|
||||
{
|
||||
this.selectedIndex = selectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogic
|
||||
{
|
||||
String getId();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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 extends ILogic
|
||||
{
|
||||
String translate(String... keys);
|
||||
void consumeKey(String... keys);
|
||||
|
||||
default void consumeKeyImpl(String... keys)
|
||||
{
|
||||
this.consumeKey(keys[0] + "." + keys[1]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogicColorMenu extends ILogic
|
||||
{
|
||||
default Predicate<String> getValidator()
|
||||
{
|
||||
return Predicates.notNull();
|
||||
}
|
||||
|
||||
default boolean drawTextfield()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean drawButtons()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
default String getId()
|
||||
{
|
||||
return "color";
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package exopandora.worldhandler.gui.content.element.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ILogicPageList<T, K> extends ILogic
|
||||
{
|
||||
String translate(T key);
|
||||
String getRegistryName(T key);
|
||||
|
||||
void onClick(T clicked);
|
||||
void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, T value, Container container);
|
||||
|
||||
T getObject(K object);
|
||||
}
|
||||
@@ -4,46 +4,39 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumMode;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
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.container.impl.GuiWorldHandler;
|
||||
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.gui.logic.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentAdvancements extends Content
|
||||
{
|
||||
private final AdvancementHelper helper = new AdvancementHelper();
|
||||
private final BuilderAdvancement builderAdvancement = new BuilderAdvancement(EnumMode.values()[0]);
|
||||
|
||||
private GuiButtonList modeButton;
|
||||
|
||||
private final List<Advancement> advancements = Lists.newArrayList(new AdvancementManager(null).getAdvancements()).parallelStream().filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList());
|
||||
private final List<EnumMode> modes = Arrays.stream(EnumMode.values()).filter(mode -> !mode.equals(EnumMode.EVERYTHING)).collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
@@ -54,44 +47,41 @@ public class ContentAdvancements extends Content
|
||||
@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>()
|
||||
List<Advancement> advancements = new AdvancementManager().getAllAdvancements().stream()
|
||||
.filter(advancement -> advancement.getDisplay() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ElementPageList<Advancement> list = new ElementPageList<Advancement>(x, y, advancements, 114, 20, 3, container, new ILogicPageList<Advancement>()
|
||||
{
|
||||
@Override
|
||||
public String translate(Advancement key)
|
||||
public String translate(Advancement item)
|
||||
{
|
||||
return I18n.format(key.getDisplay().getTitle().getUnformattedText());
|
||||
return item.getDisplay().getTitle().getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Advancement clicked)
|
||||
public String toTooltip(Advancement item)
|
||||
{
|
||||
builderAdvancement.setAdvancement(clicked.getId());
|
||||
return item.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(Advancement key)
|
||||
public void onClick(Advancement item)
|
||||
{
|
||||
return key.getId().toString();
|
||||
ContentAdvancements.this.builderAdvancement.setAdvancement(item.getId());
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, Advancement value, Container container)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Advancement item, ActionHandler actionHandler)
|
||||
{
|
||||
GuiButtonWorldHandler button;
|
||||
container.add(button = new GuiButtonWorldHandler(id, x, y, width, height, display, value.getId().toString(), EnumTooltip.TOP_RIGHT));
|
||||
button.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement getObject(String object)
|
||||
{
|
||||
return helper.ADVANCEMENT_MANAGER.getAdvancement(Type.parseResourceLocation(object));
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "advancements";
|
||||
return "advancement";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,35 +91,27 @@ public class ContentAdvancements extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(this.modeButton = new GuiButtonList(2, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic<EnumMode>()
|
||||
container.add(new GuiButtonList<EnumMode>(x + 118, y, this.modes, 114, 20, container, new ILogicMapped<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, ButtonValue<EnumMode> values)
|
||||
public String translate(EnumMode item)
|
||||
{
|
||||
builderAdvancement.setMode(values.getObject());
|
||||
return I18n.format("gui.worldhandler.advancements." + item.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
public String toTooltip(EnumMode item)
|
||||
{
|
||||
return this.values.length;
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMode getObject(int index)
|
||||
public void onClick(EnumMode item)
|
||||
{
|
||||
return this.values[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonValue<EnumMode> values)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.advancements." + values.getObject().toString());
|
||||
ContentAdvancements.this.builderAdvancement.setMode(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,32 +121,18 @@ public class ContentAdvancements extends Content
|
||||
}
|
||||
}));
|
||||
|
||||
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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.advancements.grant"), () ->
|
||||
{
|
||||
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;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.GRANT));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.advancements.revoke"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.REVOKE));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.actions.reset"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderAdvancement.getBuilder(EnumActionType.REVOKE, EnumMode.EVERYTHING)).withParent(Contents.ADVANCEMENTS)));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.config.GuiConfigWorldHandler;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentButcher extends ContentChild
|
||||
{
|
||||
private GuiTextFieldTooltip radiusField;
|
||||
@@ -35,50 +34,80 @@ public class ContentButcher extends ContentChild
|
||||
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]{0,8}"));
|
||||
this.radiusField.setValidator(string ->
|
||||
{
|
||||
if(string == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!string.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt(string);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
this.radiusField.setText(this.radius);
|
||||
this.radiusField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.radius = text;
|
||||
|
||||
if(!this.radius.isEmpty())
|
||||
{
|
||||
this.builderButcher.setDistance(Integer.valueOf(this.radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderButcher.setDistance(0);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler slaughter;
|
||||
GuiButtonBase 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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(this.radiusField);
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.configure"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.BUTCHER_SETTINGS.withParent(Contents.BUTCHER)));
|
||||
}));
|
||||
|
||||
slaughter.enabled = this.radius != null && !this.radius.isEmpty();
|
||||
container.add(slaughter = new GuiButtonBase(2, x + 116 / 2, y + 60, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.slaughter"), () ->
|
||||
{
|
||||
for(ResourceLocation entry : Config.getButcher().getEntities())
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderButcher(entry, Integer.valueOf(this.radius)));
|
||||
}
|
||||
}));
|
||||
|
||||
slaughter.enabled = this.radius != null && !this.radius.isEmpty() && !Config.CLIENT.getButcher().getEntities().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.radiusField.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.radiusField.drawTextBox();
|
||||
this.radiusField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,30 +115,4 @@ public class ContentButcher extends ContentChild
|
||||
{
|
||||
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,108 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentButcherSettings extends ContentChild
|
||||
{
|
||||
private ResourceLocation entity;
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
List<EntityType<?>> list = ForgeRegistries.ENTITIES.getValues().stream().filter(EntityType::isSummonable).collect(Collectors.toList());
|
||||
|
||||
ElementPageList<EntityType<?>> entities = new ElementPageList<EntityType<?>>(x, y, list, 114, 20, 3, container, new ILogicPageList<EntityType<?>>()
|
||||
{
|
||||
@Override
|
||||
public String translate(EntityType<?> item)
|
||||
{
|
||||
TextFormatting color = TextFormatting.RED;
|
||||
|
||||
if(Config.CLIENT.getButcher().containsEntity(item.getRegistryName()))
|
||||
{
|
||||
color = TextFormatting.GREEN;
|
||||
}
|
||||
|
||||
return color + I18n.format(item.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toTooltip(EntityType<?> item)
|
||||
{
|
||||
return item.getRegistryName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EntityType<?> item)
|
||||
{
|
||||
ContentButcherSettings.this.entity = item.getRegistryName();
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, EntityType<?> item, ActionHandler actionHandler)
|
||||
{
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "entities";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
Config.CLIENT.getButcher().addEntity(this.entity);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
Config.CLIENT.getButcher().removeEntity(this.entity);
|
||||
container.initButtons();
|
||||
}));
|
||||
|
||||
boolean contains = Config.CLIENT.getButcher().containsEntity(this.entity);
|
||||
|
||||
button1.enabled = !contains;
|
||||
button2.enabled = contains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.parent.getTitle();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiConnecting;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -12,73 +13,61 @@ import net.minecraft.client.gui.GuiWorldSelection;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 24, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.singleplayer"), () ->
|
||||
{
|
||||
case 2:
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldSelection(container));
|
||||
break;
|
||||
case 3:
|
||||
ServerData server = Minecraft.getMinecraft().getCurrentServerData();
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldSelection(container));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 48, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.multiplayer"), () ->
|
||||
{
|
||||
ServerData server = Minecraft.getInstance().getCurrentServerData();
|
||||
|
||||
if(server != null)
|
||||
{
|
||||
Minecraft.getInstance().world.sendQuittingDisconnectingPacket();
|
||||
Minecraft.getInstance().loadWorld((WorldClient)null);
|
||||
|
||||
if(server != null)
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
|
||||
{
|
||||
Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket();
|
||||
Minecraft.getMinecraft().loadWorld((WorldClient)null);
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), server);
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiConnecting(new GuiMainMenu(), Minecraft.getInstance(), server));
|
||||
Minecraft.getInstance().mouseHelper.grabMouse();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
String worldName = Minecraft.getInstance().getIntegratedServer().getWorldName();
|
||||
String folderName = Minecraft.getInstance().getIntegratedServer().getFolderName();
|
||||
|
||||
Minecraft.getInstance().world.sendQuittingDisconnectingPacket();
|
||||
Minecraft.getInstance().loadWorld(null);
|
||||
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
|
||||
{
|
||||
String worldName = Minecraft.getMinecraft().getIntegratedServer().getWorldName();
|
||||
String folderName = Minecraft.getMinecraft().getIntegratedServer().getFolderName();
|
||||
|
||||
Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket();
|
||||
Minecraft.getMinecraft().loadWorld((WorldClient)null);
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
Minecraft.getMinecraft().launchIntegratedServer(folderName, worldName, null);
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
}
|
||||
}));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Minecraft.getInstance().launchIntegratedServer(folderName, worldName, null);
|
||||
Minecraft.getInstance().displayGuiScreen(null);
|
||||
Minecraft.getInstance().mouseHelper.grabMouse();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,107 +1,103 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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.builder.impl.BuilderSetBlock;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.ActionHelper;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import net.minecraft.block.Block;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.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 GuiButtonBase(x, y + 96, 232, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonBase(x + 24, y, 208, 20, Blocks.CRAFTING_TABLE.getNameTextComponent().getFormattedText(), () ->
|
||||
{
|
||||
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++)
|
||||
BlockHelper.setBlockNearPlayer(Blocks.CRAFTING_TABLE);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y + 24, 208, 20, Blocks.ENDER_CHEST.getNameTextComponent().getFormattedText(), () ->
|
||||
{
|
||||
BlockHelper.setBlockNearPlayer(Blocks.ENDER_CHEST);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y + 48, 208, 20, Blocks.ANVIL.getNameTextComponent().getFormattedText(), () ->
|
||||
{
|
||||
BlockHelper.setBlockNearPlayer(Blocks.ANVIL);
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 24, y + 72, 208, 20, Blocks.ENCHANTING_TABLE.getNameTextComponent().getFormattedText(), () ->
|
||||
{
|
||||
double angle = Minecraft.getInstance().player.getHorizontalFacing().getHorizontalIndex() * Math.PI / 2;
|
||||
double sin = Math.sin(angle);
|
||||
double cos = Math.cos(angle);
|
||||
|
||||
for(int xOffset = -2; xOffset <= 2; xOffset++)
|
||||
{
|
||||
for(int yOffset = 0; yOffset <= 1; yOffset++)
|
||||
{
|
||||
for(int y = 0; y <= 1; y++)
|
||||
for(int zOffset = 1; zOffset <= 4; zOffset++)
|
||||
{
|
||||
for(int z = 1; z <= 4; z++)
|
||||
Block block = null;
|
||||
int cx = (int) Math.round(xOffset * cos - zOffset * sin);
|
||||
int cz = (int) Math.round(xOffset * sin + zOffset * cos);
|
||||
|
||||
if(!(xOffset >= -1 && xOffset <= 1 && zOffset < 4))
|
||||
{
|
||||
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()));
|
||||
}
|
||||
block = Blocks.BOOKSHELF;
|
||||
}
|
||||
else if(xOffset == 0 && yOffset == 0 && zOffset == 2)
|
||||
{
|
||||
block = Blocks.ENCHANTING_TABLE;
|
||||
}
|
||||
|
||||
if(block != null)
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(cx, CoordinateType.GLOBAL), new CoordinateInt(yOffset, CoordinateType.GLOBAL), new CoordinateInt(cz, CoordinateType.GLOBAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
ActionHelper.backToGame();
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonItem(x, y, 20, 20, new ItemStack(Blocks.CRAFTING_TABLE), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderGive(container.getPlayer(), Blocks.CRAFTING_TABLE.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 24, 20, 20, new ItemStack(Blocks.ENDER_CHEST), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ENDER_CHEST.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 48, 20, 20, new ItemStack(Blocks.ANVIL), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ANVIL.getRegistryName()));
|
||||
}));
|
||||
container.add(new GuiButtonItem(x, y + 72, 20, 20, new ItemStack(Blocks.ENCHANTING_TABLE), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(new BuilderGive(container.getPlayer(), Blocks.ENCHANTING_TABLE.getRegistryName()));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentContinue extends ContentChild
|
||||
{
|
||||
private ICommandBuilder builder;
|
||||
@@ -59,53 +57,30 @@ public class ContentContinue extends ContentChild
|
||||
}
|
||||
|
||||
this.commandField.setCursorPositionZero();
|
||||
this.commandField.setValidator(text -> text.equals(this.commandField.getText()));
|
||||
}
|
||||
|
||||
@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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(this.commandField);
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.generic.yes"), () ->
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builder, this.special);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.parent));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builder, this.special);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(this.parent));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 116 / 2, y + 60, 116, 20, I18n.format("gui.worldhandler.generic.no"), () -> ActionHelper.back(this)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.commandField.drawTextBox();
|
||||
this.commandField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@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()
|
||||
{
|
||||
|
||||
@@ -7,18 +7,14 @@ import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderCustomItem;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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;
|
||||
@@ -26,16 +22,20 @@ 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.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentCustomItem extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip itemField;
|
||||
@@ -49,8 +49,6 @@ public class ContentCustomItem extends Content
|
||||
private String selectedPage = "start";
|
||||
private String item;
|
||||
|
||||
private GuiButtonList colorButton;
|
||||
|
||||
private final List<EnumAttributes> attributes = Stream.concat(EnumAttributes.getAttributesFor(Applyable.BOTH).stream(), EnumAttributes.getAttributesFor(Applyable.PLAYER).stream()).collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
@@ -66,9 +64,9 @@ public class ContentCustomItem extends Content
|
||||
{
|
||||
double ammount = this.builderCutomItem.getAttributeAmmount(attribute);
|
||||
|
||||
if(ammount > ConfigSliders.getMaxItemAttributes())
|
||||
if(ammount > Config.getSliders().getMaxItemAttributes())
|
||||
{
|
||||
this.builderCutomItem.setAttribute(attribute, ConfigSliders.getMaxItemAttributes());
|
||||
this.builderCutomItem.setAttribute(attribute, Config.getSliders().getMaxItemAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +74,9 @@ public class ContentCustomItem extends Content
|
||||
{
|
||||
short level = this.builderCutomItem.getEnchantmentLevel(enchantment);
|
||||
|
||||
if(level > ConfigSliders.getMaxItemEnchantment())
|
||||
if(level > Config.getSliders().getMaxItemEnchantment())
|
||||
{
|
||||
this.builderCutomItem.setEnchantment(enchantment, (short) ConfigSliders.getMaxItemEnchantment());
|
||||
this.builderCutomItem.setEnchantment(enchantment, (short) Config.getSliders().getMaxItemEnchantment());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,63 +87,73 @@ public class ContentCustomItem extends Content
|
||||
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.item_id"));
|
||||
this.itemField.setValidator(Predicates.<String>notNull());
|
||||
this.itemField.setText(this.item);
|
||||
this.itemField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.item = text;
|
||||
this.builderCutomItem.setItem(this.item);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_1"));
|
||||
this.itemLore1Field.setValidator(Predicates.<String>notNull());
|
||||
this.itemLore1Field.setText(this.builderCutomItem.getLore1());
|
||||
this.itemLore1Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.builderCutomItem.setLore1(text);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_2"));
|
||||
this.itemLore2Field.setValidator(Predicates.<String>notNull());
|
||||
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
|
||||
this.itemLore2Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.builderCutomItem.setLore2(text);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
if(this.startPage == 1)
|
||||
{
|
||||
ElementColorMenu colors = new ElementColorMenu(this, x, y, "gui.worldhandler.items.custom_item.start.custom_name", this.builderCutomItem.getName(), new int[] {10, 11, 12, 13, 14, 15});
|
||||
container.add(colors);
|
||||
container.add(new ElementColorMenu(x, y, "gui.worldhandler.items.custom_item.start.custom_name", this.builderCutomItem.getName()));
|
||||
}
|
||||
}
|
||||
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>()
|
||||
ElementPageList<Enchantment> enchantments = new ElementPageList<Enchantment>(x + 118, y, new ArrayList<Enchantment>(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
public String translate(Enchantment item)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
return I18n.format(item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
public String toTooltip(Enchantment item)
|
||||
{
|
||||
return key.toString();
|
||||
return item.getRegistryName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
public void onClick(Enchantment item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, ResourceLocation value, Container container)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Enchantment item, ActionHandler actionHandler)
|
||||
{
|
||||
container.add(new GuiSlider<ResourceLocation>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, 0, ConfigSliders.getMaxItemEnchantment(), 0, new SimpleResponder<ResourceLocation>(response ->
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(this.toTooltip(item), text, value ->
|
||||
{
|
||||
builderCutomItem.setEnchantment(Enchantment.REGISTRY.getObject(value), response.shortValue());
|
||||
})));
|
||||
ContentCustomItem.this.builderCutomItem.setEnchantment(item, value.shortValue());
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(String object)
|
||||
public boolean doDisable()
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return new ResourceLocation(object.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,44 +162,43 @@ public class ContentCustomItem extends Content
|
||||
return "enchantments";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(enchantments);
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, this.attributes, null, 114, 20, 3, this, new int[] {13, 14, 15}, new ILogicPageList<EnumAttributes, Object>()
|
||||
ElementPageList<EnumAttributes> attributes = new ElementPageList<EnumAttributes>(x + 118, y, this.attributes, 114, 20, 3, container, new ILogicPageList<EnumAttributes>()
|
||||
{
|
||||
@Override
|
||||
public String translate(EnumAttributes key)
|
||||
public String translate(EnumAttributes item)
|
||||
{
|
||||
return I18n.format("attribute.name." + key.getAttribute());
|
||||
return item.getTranslation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes clicked)
|
||||
public String toTooltip(EnumAttributes item)
|
||||
{
|
||||
return item.getAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(EnumAttributes key)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, EnumAttributes item, ActionHandler actionHandler)
|
||||
{
|
||||
return key.getAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, EnumAttributes value, Container container)
|
||||
{
|
||||
container.add(new GuiSlider<EnumAttributes>(Contents.CUSTOM_ITEM, container, value, x, y, width, height, display, -ConfigSliders.getMaxItemAttributes(), ConfigSliders.getMaxItemAttributes(), 0, new AttributeResponder(response ->
|
||||
return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxItemAttributes(), Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderAttribute(item, text, value ->
|
||||
{
|
||||
builderCutomItem.setAttribute(value, response);
|
||||
})));
|
||||
ContentCustomItem.this.builderCutomItem.setAttribute(item, value);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAttributes getObject(Object object)
|
||||
public boolean doDisable()
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,135 +215,104 @@ public class ContentCustomItem extends Content
|
||||
@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;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
GuiButtonBase button5;
|
||||
GuiButtonBase 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(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(3, x, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start")));
|
||||
container.add(button4 = new GuiButtonWorldHandler(4, x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.enchantment")));
|
||||
container.add(button5 = new GuiButtonWorldHandler(5, x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.attributes")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start"), () ->
|
||||
{
|
||||
this.selectedPage = "start";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.enchantment"), () ->
|
||||
{
|
||||
this.selectedPage = "enchant";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.attributes"), () ->
|
||||
{
|
||||
this.selectedPage = "attributes";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.selectedPage.equals("start"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
button1.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, ">"));
|
||||
container.add(button5 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
|
||||
{
|
||||
this.startPage--;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button6 = new GuiButtonBase(x + 118 + 60, y + 72, 55, 20, ">", () ->
|
||||
{
|
||||
this.startPage++;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
button7.enabled = this.startPage != 0;
|
||||
button8.enabled = this.startPage != 1;
|
||||
if(this.startPage == 0)
|
||||
{
|
||||
button5.enabled = false;
|
||||
container.add(this.itemField);
|
||||
container.add(this.itemLore1Field);
|
||||
container.add(this.itemLore2Field);
|
||||
}
|
||||
else if(this.startPage == 1)
|
||||
{
|
||||
button6.enabled = false;
|
||||
}
|
||||
}
|
||||
else if(this.selectedPage.equals("enchant"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
button2.enabled = false;
|
||||
}
|
||||
else if(this.selectedPage.equals("attributes"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
button3.enabled = false;
|
||||
}
|
||||
|
||||
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.custom_item.custom_item")));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.items.custom_item.custom_item"), this::send));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button6 = new GuiButtonWorldHandler(9, x, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block"), this::send));
|
||||
}
|
||||
|
||||
button6.enabled = ResourceHelper.isRegisteredItem(this.item);
|
||||
button4.enabled = ResourceHelper.isRegistered(ResourceHelper.stringToResourceLocation(this.item), ForgeRegistries.ITEMS);
|
||||
}
|
||||
|
||||
private void send()
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderCutomItem, this.builderCutomItem.getName().isSpecial());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
switch(button.id)
|
||||
if(this.selectedPage.equals("start") && this.startPage == 0)
|
||||
{
|
||||
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;
|
||||
this.itemField.tick();
|
||||
this.itemLore1Field.tick();
|
||||
this.itemLore2Field.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.selectedPage.equals("start"))
|
||||
if(this.selectedPage.equals("start") && this.startPage == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
this.itemField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.itemLore1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.itemLore2Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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.GuiButtonBase;
|
||||
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.persistence.ButtonValue;
|
||||
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.logic.ILogicMapped;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentEditBlocks extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip x1Field;
|
||||
@@ -41,15 +42,13 @@ public class ContentEditBlocks extends Content
|
||||
private GuiTextFieldTooltip block1Field;
|
||||
private GuiTextFieldTooltip block2Field;
|
||||
|
||||
private final BuilderFill builderFill = new BuilderFill().addPositionObservers();
|
||||
private final BuilderClone builderClone = new BuilderClone().addPositionObservers();
|
||||
private final BuilderFill builderFill = BlockHelper.addPositionObservers(new BuilderFill(), builder -> builder::setPosition1, builder -> builder::setPosition2);
|
||||
private final BuilderClone builderClone = BlockHelper.addPositionObservers(new BuilderClone(), builder -> builder::setPosition1, builder -> builder::setPosition2);
|
||||
private final BuilderWH builderWH = new BuilderWH();
|
||||
|
||||
private String block1;
|
||||
private String block2;
|
||||
|
||||
private GuiButtonList cloneButton;
|
||||
|
||||
private String selectedPage = "coordinates";
|
||||
|
||||
@Override
|
||||
@@ -77,51 +76,103 @@ public class ContentEditBlocks extends Content
|
||||
this.x1Field = new GuiTextFieldTooltip(x + 118, y, 55, 20);
|
||||
this.x1Field.setValidator(this.getCoordinatePredicate("X1"));
|
||||
this.x1Field.setText("X1: " + BlockHelper.getPos1().getX());
|
||||
this.x1Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
this.y1Field = new GuiTextFieldTooltip(x + 118, y + 24, 55, 20);
|
||||
this.y1Field.setValidator(this.getCoordinatePredicate("Y1"));
|
||||
this.y1Field.setText("Y1: " + BlockHelper.getPos1().getY());
|
||||
this.y1Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
this.z1Field = new GuiTextFieldTooltip(x + 118, y + 48, 55, 20);
|
||||
this.z1Field.setValidator(this.getCoordinatePredicate("Z1"));
|
||||
this.z1Field.setText("Z1: " + BlockHelper.getPos1().getZ());
|
||||
this.z1Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
this.x2Field = new GuiTextFieldTooltip(x + 118 + 59, y, 55, 20);
|
||||
this.x2Field.setValidator(this.getCoordinatePredicate("X2"));
|
||||
this.x2Field.setText("X2: " + BlockHelper.getPos2().getX());
|
||||
this.x2Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
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.y2Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
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.z2Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), this.parseCoordinate(text)));
|
||||
});
|
||||
|
||||
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.block1Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.block1 = text;
|
||||
this.builderFill.setBlock1(this.block1);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
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);
|
||||
this.block2Field.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.block2 = text;
|
||||
this.builderFill.setBlock2(this.block2);
|
||||
container.initButtons();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.edit_blocks.coordinates"), () ->
|
||||
{
|
||||
this.selectedPage = "coordinates";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
{
|
||||
this.selectedPage = "fill";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
{
|
||||
this.selectedPage = "replace";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
{
|
||||
this.selectedPage = "clone";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
int yOffset1 = 0;
|
||||
int yOffset2 = 0;
|
||||
@@ -131,15 +182,57 @@ public class ContentEditBlocks extends Content
|
||||
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
button1.enabled = false;
|
||||
|
||||
yOffset1 = 72;
|
||||
yOffset2 = 72;
|
||||
width1 = 56;
|
||||
width2 = 56;
|
||||
xOffset2 = 58;
|
||||
|
||||
container.add(this.x1Field);
|
||||
container.add(this.y1Field);
|
||||
container.add(this.z1Field);
|
||||
container.add(this.x2Field);
|
||||
container.add(this.y2Field);
|
||||
container.add(this.z2Field);
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
button2.enabled = false;
|
||||
|
||||
yOffset1 = 24;
|
||||
yOffset2 = 48;
|
||||
width1 = 114;
|
||||
width2 = 114;
|
||||
xOffset2 = 0;
|
||||
|
||||
container.add(this.block1Field);
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.fill"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderFill.getBuilderForFill());
|
||||
}));
|
||||
button1.enabled = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS);
|
||||
}
|
||||
else if(this.selectedPage.equals("replace"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
|
||||
yOffset1 = 48;
|
||||
yOffset2 = 48;
|
||||
width1 = 56;
|
||||
width2 = 56;
|
||||
xOffset2 = 58;
|
||||
|
||||
container.add(this.block1Field);
|
||||
container.add(this.block2Field);
|
||||
container.add(button1 = new GuiButtonBase(8, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderFill.getBuilderForReplace());
|
||||
}));
|
||||
button1.enabled = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS) && ResourceHelper.isRegistered(this.builderFill.getBlock2(), ForgeRegistries.BLOCKS);
|
||||
}
|
||||
else if(this.selectedPage.equals("clone"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
|
||||
@@ -149,56 +242,24 @@ public class ContentEditBlocks extends Content
|
||||
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>()
|
||||
container.add(new GuiButtonList<EnumMask>(x + 118, y, Arrays.asList(EnumMask.values()), 114, 20, container, new ILogicMapped<EnumMask>()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button, ButtonValue<EnumMask> values)
|
||||
public String translate(EnumMask item)
|
||||
{
|
||||
builderClone.setMask(values.getObject());
|
||||
return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + item.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax()
|
||||
public String toTooltip(EnumMask item)
|
||||
{
|
||||
return EnumMask.values().length;
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMask getObject(int index)
|
||||
public void onClick(EnumMask item)
|
||||
{
|
||||
return EnumMask.values()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonValue<EnumMask> values)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + values.getObject().toString());
|
||||
ContentEditBlocks.this.builderClone.setMask(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,56 +269,45 @@ public class ContentEditBlocks extends Content
|
||||
}
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(11, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderClone);
|
||||
}));
|
||||
}
|
||||
|
||||
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")));
|
||||
container.add(new GuiButtonBase(x + 118, y + yOffset1, width1, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_1"), () ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118 + xOffset2, y + yOffset2, width2, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_2"), () ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
container.initGui();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
switch(button.id)
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
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;
|
||||
this.x1Field.tick();
|
||||
this.y1Field.tick();
|
||||
this.z1Field.tick();
|
||||
|
||||
this.x2Field.tick();
|
||||
this.y2Field.tick();
|
||||
this.z2Field.tick();
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
this.block1Field.tick();
|
||||
}
|
||||
else if(this.selectedPage.equals("replace"))
|
||||
{
|
||||
this.block1Field.tick();
|
||||
this.block2Field.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,93 +316,22 @@ public class ContentEditBlocks extends Content
|
||||
{
|
||||
if(this.selectedPage.equals("coordinates"))
|
||||
{
|
||||
this.x1Field.drawTextBox();
|
||||
this.y1Field.drawTextBox();
|
||||
this.z1Field.drawTextBox();
|
||||
this.x1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.y1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.z1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
|
||||
this.x2Field.drawTextBox();
|
||||
this.y2Field.drawTextBox();
|
||||
this.z2Field.drawTextBox();
|
||||
this.x2Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.y2Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.z2Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
else if(this.selectedPage.equals("fill"))
|
||||
{
|
||||
this.block1Field.drawTextBox();
|
||||
this.block1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
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);
|
||||
this.block1Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.block2Field.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +340,7 @@ public class ContentEditBlocks extends Content
|
||||
return string -> string.matches(coordinate + ": [-]?[0-9]*");
|
||||
}
|
||||
|
||||
private int filterCoordinateText(String input)
|
||||
private int parseCoordinate(String input)
|
||||
{
|
||||
if(input != null)
|
||||
{
|
||||
|
||||
@@ -2,29 +2,29 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderEnchantment;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentEnchantment extends Content
|
||||
{
|
||||
private final BuilderEnchantment builderEnchantment = new BuilderEnchantment();
|
||||
@@ -38,39 +38,32 @@ public class ContentEnchantment extends Content
|
||||
@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>()
|
||||
ElementPageList<Enchantment> enchantments = new ElementPageList<Enchantment>(x, y, new ArrayList<Enchantment>(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
public String translate(Enchantment item)
|
||||
{
|
||||
return I18n.format(Enchantment.REGISTRY.getObject(key).getName());
|
||||
return I18n.format(item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
public String toTooltip(Enchantment item)
|
||||
{
|
||||
return key.toString();
|
||||
return item.getRegistryName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
public void onClick(Enchantment item)
|
||||
{
|
||||
builderEnchantment.setEnchantment(clicked);
|
||||
builderEnchantment.setLevel(1);
|
||||
ContentEnchantment.this.builderEnchantment.setEnchantment(item);
|
||||
ContentEnchantment.this.builderEnchantment.setLevel(1);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, ResourceLocation value, Container container)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Enchantment item, ActionHandler actionHandler)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registry, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(String object)
|
||||
{
|
||||
return Type.parseResourceLocation(object);
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,29 +79,18 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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 ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 1, ForgeRegistries.ENCHANTMENTS.getValue(this.builderEnchantment.getEnchantment()).getMaxLevel(), 1, container, new LogicSliderSimple("enchantment", I18n.format("gui.worldhandler.items.enchantment.level"), 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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.enchantment.enchant"), () ->
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderEnchantment);
|
||||
container.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builderEnchantment);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderExperience;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentExperience extends Content
|
||||
{
|
||||
private final BuilderExperience builderExperience = new BuilderExperience();
|
||||
private GuiButtonWorldHandler addButton;
|
||||
private GuiButtonWorldHandler removeButton;
|
||||
|
||||
private GuiButtonBase buttonAdd;
|
||||
private GuiButtonBase buttonRemove;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
@@ -35,64 +35,51 @@ public class ContentExperience extends Content
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
if(this.builderExperience.getLevel() > ConfigSliders.getMaxExperience())
|
||||
if(this.builderExperience.getLevel() > Config.getSliders().getMaxExperience())
|
||||
{
|
||||
this.builderExperience.setLevel((int) ConfigSliders.getMaxExperience());
|
||||
this.builderExperience.setLevel((int) Config.getSliders().getMaxExperience());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiSlider<String>(this, container, "experience", x + 116 / 2, y, 114, 20, I18n.format("gui.worldhandler.title.player.experience"), 0, ConfigSliders.getMaxExperience(), 0, new SimpleResponder<String>(value ->
|
||||
container.add(new GuiSlider(x + 116 / 2, y, 114, 20, 0, Config.getSliders().getMaxExperience(), 0, container, new LogicSliderSimple("experience", I18n.format("gui.worldhandler.title.player.experience"), value ->
|
||||
{
|
||||
this.builderExperience.setLevel(value);
|
||||
})));
|
||||
|
||||
container.add(this.addButton = new GuiButtonWorldHandler(3, x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add")));
|
||||
container.add(this.removeButton = new GuiButtonWorldHandler(4, x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove")));
|
||||
container.add(new GuiButtonWorldHandler(5, x + 116 / 2, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), EnumTooltip.TOP_RIGHT));
|
||||
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
|
||||
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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(this.buttonAdd = new GuiButtonBase(x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
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;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builderExperience.getBuilderForAddLevels());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(this.buttonRemove = new GuiButtonBase(x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderExperience.getBuilderForRemoveLevels());
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 116 / 2, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderExperience.getBuilderForResetLevels());
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
|
||||
this.buttonAdd.enabled = enabled;
|
||||
this.buttonRemove.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
boolean enabled = this.builderExperience.getLevel() > 0;
|
||||
|
||||
this.buttonAdd.enabled = enabled;
|
||||
this.buttonRemove.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamerule;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
@@ -16,15 +15,17 @@ import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.GameRules.ValueType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentGamerules extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip valueField;
|
||||
@@ -47,56 +48,48 @@ public class ContentGamerules extends Content
|
||||
this.valueField.setValidator(Predicates.notNull());
|
||||
this.valueField.setText(this.value);
|
||||
this.valueField.setCursorPositionEnd();
|
||||
this.valueField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.value = text;
|
||||
this.builderGamerule.setValue(this.value);
|
||||
});
|
||||
|
||||
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>()
|
||||
ElementPageList<String> rules = new ElementPageList<String>(x, y, new ArrayList<String>(GameRules.getDefinitions().keySet()), 114, 20, 3, container, new ILogicPageList<String>()
|
||||
{
|
||||
@Override
|
||||
public String translate(String key)
|
||||
public String translate(String item)
|
||||
{
|
||||
String translated = I18n.format(key);
|
||||
|
||||
if(!translated.equals(key))
|
||||
{
|
||||
return translated;
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.gamerules.rule." + key);
|
||||
return I18n.format("gui.worldhandler.gamerules.rule." + item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String clicked)
|
||||
public String toTooltip(String item)
|
||||
{
|
||||
builderGamerule.setRule(clicked);
|
||||
booleanValue = Minecraft.getMinecraft().world.getGameRules().areSameType(clicked, ValueType.BOOLEAN_VALUE);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String item)
|
||||
{
|
||||
ContentGamerules.this.builderGamerule.setRule(item);
|
||||
ContentGamerules.this.booleanValue = GameRules.getDefinitions().get(item).getType().equals(ValueType.BOOLEAN_VALUE);
|
||||
|
||||
if(booleanValue)
|
||||
if(ContentGamerules.this.booleanValue)
|
||||
{
|
||||
builderGamerule.setValue(null);
|
||||
ContentGamerules.this.builderGamerule.setValue(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
builderGamerule.setValue(value);
|
||||
ContentGamerules.this.builderGamerule.setValue(ContentGamerules.this.value);
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(String key)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, String item, ActionHandler actionHandler)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, String value, Container container)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(String object)
|
||||
{
|
||||
return object;
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,36 +105,36 @@ public class ContentGamerules extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(true)));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderGamerule.getBuilderForValue(String.valueOf(false)));
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(4, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
container.add(this.valueField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderGamerule);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
switch(button.id)
|
||||
if(!this.booleanValue)
|
||||
{
|
||||
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;
|
||||
this.valueField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,26 +143,7 @@ public class ContentGamerules extends Content
|
||||
{
|
||||
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);
|
||||
this.valueField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,105 +1,94 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
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.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.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) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonIcon(x, y, 22, 20, EnumIcon.TIME_DAWN, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn())), ActionHelper::timeDawn));
|
||||
container.add(new GuiButtonIcon(x + 26, y, 22, 20, EnumIcon.TIME_NOON, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon())), ActionHelper::timeNoon));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y, 22, 20, EnumIcon.TIME_SUNSET, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset())), ActionHelper::timeSunset));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y, 23, 20, EnumIcon.TIME_MIDNIGHT, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight())), ActionHelper::timeMidnight));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y, 24, 20, EnumIcon.DIFFICULTY_PEACEFUL, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), ActionHelper::difficultyPeaceful));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y, 23, 20, EnumIcon.DIFFICULTY_EASY, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), ActionHelper::difficultyEasy));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y, 22, 20, EnumIcon.DIFFICULTY_NORMAL, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), ActionHelper::difficultyNormal));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y, 22, 20, EnumIcon.DIFFICULTY_HARD, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), ActionHelper::difficultyHard));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y, 22, 20, EnumIcon.SETTINGS, I18n.format("gui.worldhandler.shortcuts.tooltip.settings"), () ->
|
||||
{
|
||||
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;
|
||||
}
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.SETTINGS.withParent(Contents.MAIN)));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonIcon(x, y + 24, 22, 20, EnumIcon.WEATHER_SUN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
|
||||
container.add(new GuiButtonIcon(x + 26, y + 24, 22, 20, EnumIcon.WEATHER_RAIN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y + 24, 22, 20, EnumIcon.WEATHER_STORM, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y + 24, 23, 20, EnumIcon.BUTCHER, I18n.format("gui.worldhandler.shortcuts.tooltip.butcher"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.BUTCHER.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y + 24, 24, 20, EnumIcon.POTION, I18n.format("gui.worldhandler.shortcuts.tooltip.potions"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.POTIONS.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y + 24, 23, 20, EnumIcon.GAMEMODE_SURVIVAL, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_CREATIVE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_ADVENTURE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
|
||||
container.add(new GuiButtonIcon(x + 26 * 8 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_SPECTATOR, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), ActionHelper::gamemodeSpectator));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 48, 74, 20, I18n.format("gui.worldhandler.items"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CUSTOM_ITEM));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 78, y + 48, 76, 20, I18n.format("gui.worldhandler.blocks"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.EDIT_BLOCKS));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 158, y + 48, 74, 20, I18n.format("gui.worldhandler.entities"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.SUMMON));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 72, 74, 20, I18n.format("gui.worldhandler.world"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.WORLD_INFO));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 78, y + 72, 76, 20, I18n.format("gui.worldhandler.player"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.PLAYER));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 158, y + 72, 74, 20, I18n.format("gui.worldhandler.scoreboard"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.SCOREBOARD_OBJECTIVES));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 74, 20, I18n.format("gui.worldhandler.change_world"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CHANGE_WORLD.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 78, y + 96, 76, 20, I18n.format("gui.worldhandler.resourcepack"), () ->
|
||||
{
|
||||
Minecraft.getInstance().gameSettings.saveOptions();
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiScreenResourcePacks(container));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 158, y + 96, 74, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
@@ -11,23 +10,25 @@ 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.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
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.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentMultiplayer extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip playerField;
|
||||
@@ -87,172 +88,191 @@ public class ContentMultiplayer extends Content
|
||||
this.playerField.setFocused(false);
|
||||
this.playerField.setText(this.builderKick.getPlayer());
|
||||
this.playerField.setMaxStringLength(16);
|
||||
this.playerField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.setPlayer(this.playerField.getText());
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
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());
|
||||
this.reasonField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.setReason(this.reasonField.getText());
|
||||
container.initButtons();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
GuiButtonBase button5;
|
||||
GuiButtonBase button6;
|
||||
GuiButtonBase button7;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.multiplayer.kick") + " / " + I18n.format("gui.worldhandler.multiplayer.ban"), () ->
|
||||
{
|
||||
this.selected = "kickBan";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.multiplayer.pardon"), () ->
|
||||
{
|
||||
this.selected = "pardon";
|
||||
this.shiftDown = 24;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions"), () ->
|
||||
{
|
||||
this.selected = "permissions";
|
||||
this.shiftDown = 12;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime"), () ->
|
||||
{
|
||||
this.selected = "runtime";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button5 = new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist"), () ->
|
||||
{
|
||||
this.selected = "whitelist";
|
||||
this.shiftDown = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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));
|
||||
container.add(this.playerField);
|
||||
container.add(this.reasonField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.kick"), this.builderKick.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderKick);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.ban"), this.builderBan.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderBan);
|
||||
}));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
button9.enabled = false;
|
||||
button6.enabled = false;
|
||||
button7.enabled = false;
|
||||
}
|
||||
|
||||
button1.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("pardon"))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.pardon"), this.builderPardon.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPardon);
|
||||
}));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button6.enabled = false;
|
||||
}
|
||||
|
||||
button2.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("permissions"))
|
||||
{
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonTooltip(x + 118, y + 24 + 12, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions.give"), this.builderOp.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderOp);
|
||||
}));
|
||||
container.add(button7 = new GuiButtonTooltip(x + 118, y + 48 + 12, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions.take"), this.builderDeop.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderDeop);
|
||||
}));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button6.enabled = false;
|
||||
button7.enabled = false;
|
||||
}
|
||||
|
||||
button3.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("pardon"))
|
||||
else if(this.selected.equals("runtime"))
|
||||
{
|
||||
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())
|
||||
container.add(new GuiButtonTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime.save_world"), this.builderSaveAll.toActualCommand(), () ->
|
||||
{
|
||||
button8.enabled = false;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builderSaveAll);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime.autosave", I18n.format("gui.worldhandler.generic.on")), this.builderSaveOn.toActualCommand(), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderSaveOn);
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 48, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.multiplayer.runtime.autosave", I18n.format("gui.worldhandler.generic.off")), this.builderSaveOff.toActualCommand(), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderSaveOff).withParent(Contents.MULTIPLAYER)));
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 118, y + 72, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.multiplayer.runtime.stop_server"), this.builderStop.toActualCommand(), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderStop).withParent(Contents.MULTIPLAYER)));
|
||||
}));
|
||||
|
||||
button4.enabled = false;
|
||||
}
|
||||
else if(this.selected.equals("permissions"))
|
||||
else if(this.selected.equals("whitelist"))
|
||||
{
|
||||
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));
|
||||
container.add(this.playerField);
|
||||
container.add(button6 = new GuiButtonBase(x + 118, y + 24, 44, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderWhitelist.getBuilder(EnumMode.ADD));
|
||||
}));
|
||||
container.add(button7 = new GuiButtonBase(x + 118 + 47, y + 24, 44, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderWhitelist.getBuilder(EnumMode.REMOVE));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.whitelist", I18n.format("gui.worldhandler.generic.on")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderWhitelist.getBuilder(EnumMode.ON));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist.whitelist", I18n.format("gui.worldhandler.generic.off")), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderWhitelist.getBuilder(EnumMode.OFF));
|
||||
}));
|
||||
|
||||
container.add(new GuiButtonIcon(x + 232 - 20, y + 24, 20, 20, EnumIcon.RELOAD, I18n.format("gui.worldhandler.multiplayer.whitelist.reload"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderWhitelist.getBuilder(EnumMode.RELOAD));
|
||||
}));
|
||||
|
||||
if(this.playerField.getText().isEmpty())
|
||||
{
|
||||
button8.enabled = false;
|
||||
button9.enabled = false;
|
||||
button6.enabled = false;
|
||||
button7.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) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
switch(button.id)
|
||||
if(this.selected.equals("kickBan"))
|
||||
{
|
||||
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;
|
||||
this.reasonField.tick();
|
||||
}
|
||||
|
||||
if(!this.selected.equals("runtime"))
|
||||
{
|
||||
this.playerField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,12 +281,12 @@ public class ContentMultiplayer extends Content
|
||||
{
|
||||
if(this.selected.equals("kickBan"))
|
||||
{
|
||||
this.reasonField.drawTextBox();
|
||||
this.reasonField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
if(!this.selected.equals("runtime"))
|
||||
{
|
||||
this.playerField.drawTextBox();
|
||||
this.playerField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,29 +332,6 @@ public class ContentMultiplayer extends Content
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -1,41 +1,39 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano.Type;
|
||||
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.ActionHelper;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
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.state.properties.NoteBlockInstrument;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentNoteEditor extends Content
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private final BuilderNoteEditor builderNoteEditor = new BuilderNoteEditor();
|
||||
|
||||
private boolean isActive;
|
||||
@@ -49,137 +47,127 @@ public class ContentNoteEditor extends Content
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK);
|
||||
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.NOTE_BLOCK);
|
||||
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")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.isActive)
|
||||
{
|
||||
BlockPos pos = this.builderNoteEditor.getBlockPos();
|
||||
SoundEvent sound = this.getSoundEvent(pos.down());
|
||||
|
||||
container.add(new GuiButtonKeyboard(4, x - 3 + 15, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), Orientation.NORMAL, 0.53F, container, this, pos, sound));
|
||||
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 GuiButtonPiano(x - 3 + 15, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), sound, 0.53F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(1));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 2, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.a"), sound, 0.6F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(3));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 3, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.b"), sound, 0.67F, Type.RIGHT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(5));
|
||||
}));
|
||||
|
||||
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 GuiButtonPiano(x - 3 + 15 * 4, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.c"), sound, 0.7F, Type.LEFT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(6));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 5, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.d"), sound, 0.8F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(8));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 6, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.e"), sound, 0.9F, Type.RIGHT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(10));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 7, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.f"), sound, 0.95F, Type.LEFT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(11));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 8, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.g"), sound, 1.05F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(13));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 9, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.a"), sound, 1.2F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(15));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 10, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.b"), sound, 1.32F, Type.RIGHT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(17));
|
||||
}));
|
||||
|
||||
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 GuiButtonPiano(x - 3 + 15 * 11, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.c"), sound, 1.4F, Type.LEFT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(18));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 12, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.d"), sound, 1.6F, Type.NORMAL, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(20));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 13, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.e"), sound, 1.8F, Type.RIGHT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(22));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 + 15 * 14, y, 14, 92, I18n.format("gui.worldhandler.blocks.note_block_editor.f"), sound, 1.9F, Type.LEFT, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(23));
|
||||
}));
|
||||
|
||||
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 GuiButtonPiano(x - 3 - 5 + 15, y, 9, 58, "F#", sound, 0.5F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(0));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 2, y, 9, 58, "G#", sound, 0.56F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(2));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 3, y, 9, 58, "A#", sound, 0.63F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(4));
|
||||
}));
|
||||
|
||||
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 GuiButtonPiano(x - 3 - 5 + 15 * 5, y, 9, 58, "C#", sound, 0.75F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(7));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 6, y, 9, 58, "D#", sound, 0.85F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(9));
|
||||
}));
|
||||
|
||||
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 GuiButtonPiano(x - 3 - 5 + 15 * 8, y, 9, 58, "F#", sound, 1.0F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(12));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 9, y, 9, 58, "G#", sound, 1.1F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(14));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 10, y, 9, 58, "A#", sound, 1.25F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(16));
|
||||
}));
|
||||
|
||||
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 actionPerformed(Container container, GuiButton button) throws Exception
|
||||
{
|
||||
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;
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 12, y, 9, 58, "C#", sound, 1.5F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(19));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 13, y, 9, 58, "D#", sound, 1.7F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(21));
|
||||
}));
|
||||
container.add(new GuiButtonPiano(x - 3 - 5 + 15 * 15, y, 9, 58, "F#", sound, 2.0F, Type.BLACK, () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderNoteEditor.getBuilderForNote(24));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +176,7 @@ public class ContentNoteEditor extends Content
|
||||
{
|
||||
if(this.isActive)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("worldhandler:textures/misc/note.png"));
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
|
||||
|
||||
container.drawTexturedModalRect(x - 1, y - 1, 0, 0, 8, 59);
|
||||
container.drawTexturedModalRect(x - 1, y - 1 + 59, 0, 59, 13, 35);
|
||||
@@ -203,68 +191,26 @@ public class ContentNoteEditor extends Content
|
||||
{
|
||||
float scale = 4;
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.color3f(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);
|
||||
GlStateManager.translatef(container.width / 2 - 8 * scale, container.height / 2 - 15 - 8 * scale, 0);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(new ItemStack(Blocks.NOTE_BLOCK), 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());
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", WorldHandler.KEY_WORLD_HANDLER.getKey().getName());
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().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;
|
||||
return NoteBlockInstrument.byState(Minecraft.getInstance().world.getBlockState(blockPos)).getSound();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,25 +6,27 @@ import exopandora.worldhandler.WorldHandler;
|
||||
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.BuilderSpawnpoint;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentPlayer extends Content
|
||||
{
|
||||
private String selectedMain = "start";
|
||||
@@ -39,7 +41,7 @@ public class ContentPlayer extends Content
|
||||
|
||||
private final BuilderGeneric builderSetworldspawn = new BuilderGeneric("setworldspawn");
|
||||
private final BuilderSpawnpoint builderSpawnpoint = new BuilderSpawnpoint(WorldHandler.USERNAME);
|
||||
private final BuilderGeneric builderKill = new BuilderGeneric("kill");
|
||||
private final BuilderPlayer builderKill = new BuilderPlayer("kill");
|
||||
private final BuilderGeneric builderClear = new BuilderGeneric("clear");
|
||||
|
||||
private final BuilderMultiCommand builderMiscellaneous = new BuilderMultiCommand(this.builderSetworldspawn, this.builderSpawnpoint, this.builderKill, this.builderClear);
|
||||
@@ -65,104 +67,94 @@ public class ContentPlayer extends Content
|
||||
this.coinsField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
|
||||
this.xpField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
|
||||
|
||||
this.updateScreen(container);
|
||||
this.tick(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
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")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.entities.player.start"), () ->
|
||||
{
|
||||
this.selectedMain = "start";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.player.score"), () ->
|
||||
{
|
||||
this.selectedMain = "score";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.player.position"), () ->
|
||||
{
|
||||
this.selectedMain = "position";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.miscellaneous"), () ->
|
||||
{
|
||||
this.selectedMain = "miscellaneous";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
button3.enabled = false;
|
||||
button1.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("score"))
|
||||
{
|
||||
button4.enabled = false;
|
||||
button2.enabled = false;
|
||||
}
|
||||
else if(this.selectedMain.equals("position"))
|
||||
{
|
||||
button5.enabled = false;
|
||||
button3.enabled = false;
|
||||
|
||||
container.add(new GuiButtonWorldHandler(8, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.position.copy_position")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.position.copy_position"), () ->
|
||||
{
|
||||
int posX = MathHelper.floor(Minecraft.getInstance().player.posX);
|
||||
int posY = MathHelper.floor(Minecraft.getInstance().player.posY);
|
||||
int posZ = MathHelper.floor(Minecraft.getInstance().player.posZ);
|
||||
|
||||
Minecraft.getInstance().keyboardListener.setClipboardString(posX + " " + posY + " " + posZ);
|
||||
}));
|
||||
}
|
||||
else if(this.selectedMain.equals("miscellaneous"))
|
||||
{
|
||||
button6.enabled = false;
|
||||
button4.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")));
|
||||
container.add(new GuiButtonBase(x + 118, y, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_spawn"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderSpawnpoint).withParent(Contents.PLAYER)));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_global_spawn"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderSetworldspawn).withParent(Contents.PLAYER)));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.kill"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderKill).withParent(Contents.PLAYER)));
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.clear_inventory"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderClear).withParent(Contents.PLAYER)));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
public void tick(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) throws Exception
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.posXField.setText("X: " + MathHelper.floor(Minecraft.getInstance().player.posX));
|
||||
this.posYField.setText("Y: " + MathHelper.floor(Minecraft.getInstance().player.posY));
|
||||
this.posZField.setText("Z: " + MathHelper.floor(Minecraft.getInstance().player.posZ));
|
||||
this.scoreField.setText(I18n.format("gui.worldhandler.entities.player.score") + ": " + Minecraft.getInstance().player.getScore());
|
||||
this.coinsField.setText(I18n.format("gui.worldhandler.entities.player.score.experience") + ": " + Minecraft.getInstance().player.experienceLevel + "L");
|
||||
this.xpField.setText(I18n.format("gui.worldhandler.entities.player.score.experience_coins") + ": " + Minecraft.getInstance().player.experienceTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,25 +164,26 @@ public class ContentPlayer extends Content
|
||||
{
|
||||
int xPos = x + 175;
|
||||
int yPos = y + 82;
|
||||
int playerNameWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(Minecraft.getMinecraft().player.getName()) / 2;
|
||||
int playerNameWidth = Minecraft.getInstance().fontRenderer.getStringWidth(Minecraft.getInstance().player.getName().getFormattedText()) / 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);
|
||||
Gui.drawRect(container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
|
||||
Minecraft.getInstance().fontRenderer.drawString(Minecraft.getInstance().player.getName().getFormattedText(), 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);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiInventory.drawEntityOnScreen(xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, Minecraft.getInstance().player);
|
||||
GlStateManager.blendFuncSeparate(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();
|
||||
this.scoreField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.xpField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.coinsField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
else if(this.selectedMain.equals("position"))
|
||||
{
|
||||
this.posXField.drawTextBox();
|
||||
this.posYField.drawTextBox();
|
||||
this.posZField.drawTextBox();
|
||||
this.posXField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.posYField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.posZField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +191,7 @@ public class ContentPlayer extends Content
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderSpawnpoint.setPlayer(username);
|
||||
this.builderKill.setPlayer(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,29 +2,30 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPotionEffect;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPotionItem;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.responder.SimpleResponder;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentPotions extends ContentChild
|
||||
{
|
||||
private int potionPage;
|
||||
@@ -41,18 +42,18 @@ public class ContentPotions extends ContentChild
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
if(this.builderPotion.getAmplifier() > ConfigSliders.getMaxPotionAmplifier())
|
||||
if(this.builderPotion.getAmplifier() > Config.getSliders().getMaxPotionAmplifier())
|
||||
{
|
||||
this.builderPotion.setAmplifier((byte) ConfigSliders.getMaxPotionAmplifier());
|
||||
this.builderPotion.setAmplifier((byte) Config.getSliders().getMaxPotionAmplifier());
|
||||
}
|
||||
|
||||
for(Potion potion : this.builderPotionItem.getPotions())
|
||||
{
|
||||
byte amplifier = this.builderPotionItem.getAmplifier(potion);
|
||||
|
||||
if(amplifier > ConfigSliders.getMaxPotionAmplifier())
|
||||
if(amplifier > Config.getSliders().getMaxPotionAmplifier())
|
||||
{
|
||||
this.builderPotionItem.setAmplifier(potion, (byte) ConfigSliders.getMaxPotionAmplifier());
|
||||
this.builderPotionItem.setAmplifier(potion, (byte) Config.getSliders().getMaxPotionAmplifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,43 +61,31 @@ public class ContentPotions extends ContentChild
|
||||
@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>()
|
||||
ElementPageList<Potion> potions = new ElementPageList<Potion>(x, y, new ArrayList<Potion>(ForgeRegistries.POTIONS.getValues()), 114, 20, 3, container, new ILogicPageList<Potion>()
|
||||
{
|
||||
@Override
|
||||
public String translate(ResourceLocation key)
|
||||
public String translate(Potion item)
|
||||
{
|
||||
return I18n.format(Potion.REGISTRY.getObject(key).getName());
|
||||
return I18n.format(item.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ResourceLocation clicked)
|
||||
public String toTooltip(Potion item)
|
||||
{
|
||||
builderPotion.setEffect(clicked);
|
||||
return item.getRegistryName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(ResourceLocation key)
|
||||
public void onClick(Potion item)
|
||||
{
|
||||
return key.toString();
|
||||
ContentPotions.this.builderPotion.setEffect(item);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registryKey, boolean enabled, ResourceLocation value, Container container)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Potion item, ActionHandler actionHandler)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(id, x, y, width, height, display, registryKey, EnumTooltip.TOP_RIGHT);
|
||||
button.enabled = enabled;
|
||||
container.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getObject(Potion object)
|
||||
{
|
||||
if(object != null)
|
||||
{
|
||||
return object.getRegistryName();
|
||||
}
|
||||
|
||||
return null;
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,28 +101,48 @@ public class ContentPotions extends ContentChild
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonWorldHandler button7;
|
||||
GuiButtonWorldHandler button8;
|
||||
GuiButtonWorldHandler button9;
|
||||
GuiButtonWorldHandler button10;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
GuiButtonBase button5;
|
||||
|
||||
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")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
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")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.potions.effect.give"), () ->
|
||||
{
|
||||
this.next(container);
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotion.getRemoveCommand());
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove_all"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotion.getClearCommand());
|
||||
container.initGui();
|
||||
}));
|
||||
}
|
||||
else if(this.potionPage == 1)
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
container.add(new GuiButtonWorldHandler(8, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potions.effect.ambient", (this.builderPotionItem.getAmbient(potion) ? I18n.format("gui.worldhandler.generic.on") : I18n.format("gui.worldhandler.generic.off")))));
|
||||
container.add(new GuiButtonWorldHandler(9, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potions.effect.particles", (this.builderPotion.getHideParticles() ? I18n.format("gui.worldhandler.generic.off") : I18n.format("gui.worldhandler.generic.on")))));
|
||||
container.add(new GuiSlider<Potion>(this, container, "potions_amplifier" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect.amplifier"), 0, ConfigSliders.getMaxPotionAmplifier(), 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiButtonBase(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")), () ->
|
||||
{
|
||||
this.builderPotionItem.setAmbient(potion, !this.builderPotionItem.getAmbient(potion));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiButtonBase(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")), () ->
|
||||
{
|
||||
this.builderPotion.setHideParticles(!this.builderPotion.getHideParticles());
|
||||
this.builderPotionItem.setShowParticles(potion, !this.builderPotionItem.getShowParticles(potion));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + potion.getRegistryName(), I18n.format("gui.worldhandler.potions.effect.amplifier"), value ->
|
||||
{
|
||||
this.builderPotion.setAmplifier(value.byteValue());
|
||||
this.builderPotionItem.setAmplifier(potion, value.byteValue());
|
||||
@@ -143,17 +152,17 @@ public class ContentPotions extends ContentChild
|
||||
{
|
||||
Potion potion = this.builderPotion.getEffectAsPotion();
|
||||
|
||||
container.add(new GuiSlider<Potion>(this, container, "seconds" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format("gui.worldhandler.potion.time.seconds"), 0, 59, 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + potion.getRegistryName(), I18n.format("gui.worldhandler.potion.time.seconds"), value ->
|
||||
{
|
||||
this.builderPotion.setSeconds(value.intValue());
|
||||
this.builderPotionItem.setSeconds(potion, value.intValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "minutes" + potion.getRegistryName(), x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, 59, 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, 59, 0, container, new LogicSliderSimple("m" + potion.getRegistryName(), I18n.format("gui.worldhandler.potion.time.minutes"), value ->
|
||||
{
|
||||
this.builderPotion.setMinutes(value.intValue());
|
||||
this.builderPotionItem.setMinutes(potion, value.intValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "hours" + potion.getRegistryName(), x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potion.time.hours"), 0, 99, 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiSlider(x + 118, y + 48, 114, 20, 0, 99, 0, container, new LogicSliderSimple("h" + potion.getRegistryName(), I18n.format("gui.worldhandler.potion.time.hours"), value ->
|
||||
{
|
||||
this.builderPotion.setHours(value.intValue());
|
||||
this.builderPotionItem.setHours(potion, value.intValue());
|
||||
@@ -161,90 +170,66 @@ public class ContentPotions extends ContentChild
|
||||
}
|
||||
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));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y, 114, 20, I18n.format("gui.worldhandler.potions.effect"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotion.getGiveCommand());
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 24, 56, 20, I18n.format("gui.worldhandler.potions.effect.tipped_arrow"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.TIPPED_ARROW));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonTooltip(x + 178, y + 24, 55, 20, I18n.format("gui.worldhandler.potions.effect.bottle"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonTooltip(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.potions.effect.splash"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.SPLASH_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button5 = new GuiButtonTooltip(x + 178, y + 48, 55, 20, I18n.format("gui.worldhandler.potions.effect.lingering"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.LINGERING_POTION));
|
||||
this.potionPage = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
boolean enabled = this.builderPotion.getAmplifier() >= 0;
|
||||
|
||||
button6.enabled = enabled;
|
||||
button7.enabled = enabled;
|
||||
button8.enabled = enabled;
|
||||
button9.enabled = enabled;
|
||||
button10.enabled = enabled;
|
||||
button1.enabled = enabled;
|
||||
button2.enabled = enabled;
|
||||
button3.enabled = enabled;
|
||||
button4.enabled = enabled;
|
||||
button5.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, ">"));
|
||||
container.add(new GuiButtonBase(4, x + 118, y + 72, 56, 20, "<", () ->
|
||||
{
|
||||
this.potionPage--;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button1 = new GuiButtonBase(5, x + 118 + 60, y + 72, 55, 20, ">", () ->
|
||||
{
|
||||
this.next(container);
|
||||
}));
|
||||
|
||||
button6.enabled = this.potionPage < 3;
|
||||
button1.enabled = this.potionPage < 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
private void next(Container container)
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.potionPage++;
|
||||
container.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderRecipe;
|
||||
import exopandora.worldhandler.builder.impl.BuilderRecipe.EnumMode;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentRecipes extends Content
|
||||
{
|
||||
private final BuilderRecipe builderRecipe = new BuilderRecipe();
|
||||
@@ -39,53 +39,41 @@ public class ContentRecipes extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
List<IRecipe> recipes = new ArrayList<IRecipe>();
|
||||
List<IRecipe> recipes = Minecraft.getInstance().player.getRecipeBook().getRecipes().stream()
|
||||
.flatMap(recipe -> recipe.getRecipes().stream())
|
||||
.filter(recipe -> !recipe.isDynamic())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for(IRecipe recipe : CraftingManager.REGISTRY)
|
||||
{
|
||||
if(!recipe.isDynamic())
|
||||
{
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
ElementPageList<IRecipe, String> list = new ElementPageList<IRecipe, String>(x, y, recipes, null, 114, 20, 3, this, new int[] {4, 5, 6}, new ILogicPageList<IRecipe, String>()
|
||||
ElementPageList<IRecipe> list = new ElementPageList<IRecipe>(x, y, recipes, 114, 20, 3, container, new ILogicPageList<IRecipe>()
|
||||
{
|
||||
@Override
|
||||
public String translate(IRecipe key)
|
||||
public String translate(IRecipe item)
|
||||
{
|
||||
if(!key.getRecipeOutput().equals(ItemStack.EMPTY))
|
||||
if(!item.getRecipeOutput().equals(ItemStack.EMPTY))
|
||||
{
|
||||
return key.getRecipeOutput().getDisplayName();
|
||||
return item.getRecipeOutput().getDisplayName().getFormattedText();
|
||||
}
|
||||
|
||||
return key.getRegistryName().toString();
|
||||
return item.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IRecipe clicked)
|
||||
public String toTooltip(IRecipe item)
|
||||
{
|
||||
builderRecipe.setRecipe(clicked.getRegistryName());
|
||||
return item.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(IRecipe key)
|
||||
public void onClick(IRecipe item)
|
||||
{
|
||||
return key.getRegistryName().toString();
|
||||
ContentRecipes.this.builderRecipe.setRecipe(item);
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(int id, int x, int y, int width, int height, String display, String registry, boolean enabled, IRecipe value, Container container)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, IRecipe item, ActionHandler actionHandler)
|
||||
{
|
||||
GuiButtonWorldHandler button;
|
||||
container.add(button = new GuiButtonWorldHandler(id, x, y, width, height, display, value.getRegistryName().toString(), EnumTooltip.TOP_RIGHT));
|
||||
button.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe getObject(String object)
|
||||
{
|
||||
return CraftingManager.REGISTRY.getObject(Type.parseResourceLocation(object));
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,29 +89,19 @@ public class ContentRecipes extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(0, x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back")));
|
||||
container.add(new GuiButtonWorldHandler(1, x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame")));
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
container.add(new GuiButtonWorldHandler(2, x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.recipes.give")));
|
||||
container.add(new GuiButtonWorldHandler(3, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.recipes.take")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
{
|
||||
switch(button.id)
|
||||
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.recipes.give"), () ->
|
||||
{
|
||||
case 2:
|
||||
WorldHandler.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.GIVE));
|
||||
container.initButtons();
|
||||
break;
|
||||
case 3:
|
||||
WorldHandler.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.TAKE));
|
||||
container.initButtons();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CommandHelper.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.GIVE));
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.recipes.take"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderRecipe.getBuilderForMode(EnumMode.TAKE));
|
||||
container.initButtons();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,31 +1,38 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives.EnumMode;
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.element.impl.ElementMultiButtonList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.helper.RegistryTranslator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.stats.StatType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
private GuiTextFieldTooltip objectField;
|
||||
@@ -44,65 +51,76 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
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);
|
||||
this.objectField.setText(ContentScoreboard.getObjective());
|
||||
this.objectField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
ContentScoreboard.setObjective(text);
|
||||
this.builderObjectives.setObjective(ContentScoreboard.getObjective());
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
if(this.selectedObjective.equals("create"))
|
||||
{
|
||||
ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), new int[] {7, 8}, this, new ILogicClickList()
|
||||
ElementMultiButtonList objectives = new ElementMultiButtonList(x + 118, y + 24, HELPER.getObjectives(), 2, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public void consumeKey(String... keys)
|
||||
public String translate(String key, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
ResourceLocation resource = this.makeResourceLocation(key);
|
||||
|
||||
if(resource != null)
|
||||
{
|
||||
this.consumeKeyImpl(keys);
|
||||
StatType<?> type = IRegistry.field_212634_w.func_212608_b(resource);
|
||||
|
||||
if(type != null)
|
||||
{
|
||||
if(type.equals(StatList.CUSTOM))
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.custom");
|
||||
}
|
||||
else if(type.equals(StatList.ENTITY_KILLED))
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.killed");
|
||||
}
|
||||
else if(type.equals(StatList.ENTITY_KILLED_BY))
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.killed_by");
|
||||
}
|
||||
|
||||
return I18n.format(type.getTranslationKey());
|
||||
}
|
||||
|
||||
String translation = RegistryTranslator.translate(resource);
|
||||
|
||||
if(translation != null)
|
||||
{
|
||||
return I18n.format(translation);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key)))
|
||||
{
|
||||
builderObjectives.setCriteria(keys[0]);
|
||||
return I18n.format("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.scoreboard.objectives.stat." + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translate(String... keys)
|
||||
public void onClick(String key, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
ContentScoreboardObjectives.this.builderObjectives.setCriteria(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildEventKey(List<String> keys, int depth)
|
||||
{
|
||||
if(this.isRegistryItem(keys.get(keys.size() - 1)))
|
||||
{
|
||||
return this.translate(keys[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
String format = "gui.worldhandler.scoreboard.objectives.criteria." + keys[0];
|
||||
String result = I18n.format(format);
|
||||
|
||||
if(result.equals(format))
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation(keys[0]);
|
||||
|
||||
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(keys[0]))
|
||||
{
|
||||
result = I18n.format("entity." + keys[0] + ".name");
|
||||
}
|
||||
else if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(keys[0])))
|
||||
{
|
||||
result = I18n.format("gui.worldhandler.color." + keys[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = I18n.format(keys[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return String.join(":", keys);
|
||||
}
|
||||
|
||||
return ILogicClickList.super.buildEventKey(keys, depth);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,38 +128,66 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
return "objectives";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ResourceLocation makeResourceLocation(String key)
|
||||
{
|
||||
return ResourceLocation.makeResourceLocation(key.replace(".", ":"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private boolean isRegistryItem(String key)
|
||||
{
|
||||
return this.isRegistryItem(this.makeResourceLocation(key));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private boolean isRegistryItem(ResourceLocation resource)
|
||||
{
|
||||
IForgeRegistry<?>[] registries = new IForgeRegistry<?>[] {ForgeRegistries.BLOCKS, ForgeRegistries.ITEMS, ForgeRegistries.ENTITIES};
|
||||
|
||||
for(IForgeRegistry<?> registry : registries)
|
||||
{
|
||||
if(registry.containsKey(resource))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(IRegistry.field_212623_l.func_212607_c(resource))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
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(), new int[] {9, 10}, this, new ILogicClickList()
|
||||
ElementMultiButtonList slots = new ElementMultiButtonList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), 2, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate(String... keys)
|
||||
public String translate(String key, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
if(depth == 0)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.color." + keys[1]);
|
||||
return I18n.format("gui.worldhandler.scoreboard.slot." + key);
|
||||
}
|
||||
else
|
||||
else if(depth == 1)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.slot." + keys[0]);
|
||||
return I18n.format("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeKey(String... keys)
|
||||
public void onClick(String key, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
{
|
||||
this.consumeKeyImpl(keys);
|
||||
}
|
||||
else
|
||||
{
|
||||
builderObjectives.setSlot(keys[0]);
|
||||
}
|
||||
ContentScoreboardObjectives.this.builderObjectives.setSlot(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,73 +204,71 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.create"), () ->
|
||||
{
|
||||
this.selectedObjective = "create";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.display"), () ->
|
||||
{
|
||||
this.selectedObjective = "display";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.undisplay"), () ->
|
||||
{
|
||||
this.selectedObjective = "undisplay";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.remove"), () ->
|
||||
{
|
||||
this.selectedObjective = "remove";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
button3.enabled = !this.selectedObjective.equals("create");
|
||||
button4.enabled = !this.selectedObjective.equals("display");
|
||||
button5.enabled = !this.selectedObjective.equals("undisplay");
|
||||
button6.enabled = !this.selectedObjective.equals("remove");
|
||||
button1.enabled = !this.selectedObjective.equals("create");
|
||||
button2.enabled = !this.selectedObjective.equals("display");
|
||||
button3.enabled = !this.selectedObjective.equals("undisplay");
|
||||
button4.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");
|
||||
this.builderObjectives.setMode(EnumMode.REMOVE);
|
||||
}
|
||||
|
||||
if(!this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
this.builderObjectives.setObjective(this.objective);
|
||||
container.add(this.objectField);
|
||||
this.builderObjectives.setObjective(ContentScoreboard.getObjective());
|
||||
}
|
||||
|
||||
container.add(button3 = new GuiButtonWorldHandler(6, x + 118, y + 72 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform")));
|
||||
button3.enabled = enabled;
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderObjectives);
|
||||
container.initGui();
|
||||
}));
|
||||
button1.enabled = this.selectedObjective.equals("undisplay") || ContentScoreboard.isObjectiveValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
switch(button.id)
|
||||
if(!this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
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;
|
||||
this.objectField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,27 +277,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
{
|
||||
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);
|
||||
this.objectField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,191 +1,247 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumPoints;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumTag;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTag;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTrigger;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
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 net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.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 final BuilderTag builderTag = new BuilderTag();
|
||||
private final BuilderTrigger builderTrigger = new BuilderTrigger();
|
||||
private final BuilderMultiCommand builderTriggerMulti = new BuilderMultiCommand(this.builderTrigger, this.builderPlayers);
|
||||
|
||||
private String selectedPlayer = "add|set|remove";
|
||||
private String tag;
|
||||
|
||||
private GuiButtonWorldHandler addButton;
|
||||
private GuiButtonWorldHandler removeButton;
|
||||
private GuiButtonBase addButton;
|
||||
private GuiButtonBase removeButton;
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderPlayers;
|
||||
if(this.selectedPlayer.equals("add|set|remove"))
|
||||
{
|
||||
return this.builderPlayers;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
return this.builderTag;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("enable"))
|
||||
{
|
||||
return this.builderTriggerMulti;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
if(this.builderPlayers.getPoints() > ConfigSliders.getMaxPlayerPoints())
|
||||
if(this.builderPlayers.getPoints() > Config.getSliders().getMaxPlayerPoints())
|
||||
{
|
||||
this.builderPlayers.setPoints((int) ConfigSliders.getMaxPlayerPoints());
|
||||
this.builderPlayers.setPoints((int) Config.getSliders().getMaxPlayerPoints());
|
||||
}
|
||||
|
||||
if(this.builderTrigger.getValue() > Config.getSliders().getMaxTriggerValue())
|
||||
{
|
||||
this.builderTrigger.setValue((int) Config.getSliders().getMaxTriggerValue());
|
||||
}
|
||||
}
|
||||
|
||||
@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.objectField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.objective"));
|
||||
this.objectField.setValidator(Predicates.notNull());
|
||||
this.objectField.setText(ContentScoreboard.getObjective());
|
||||
this.objectField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
ContentScoreboard.setObjective(text);
|
||||
this.builderPlayers.setObjective(ContentScoreboard.getObjective());
|
||||
this.builderTrigger.setObjective(ContentScoreboard.getObjective());
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag"));
|
||||
this.tagField.setValidator(this.nonNullNoSpace);
|
||||
this.tagField.setValidator(string -> string != null && !string.contains(" "));
|
||||
this.tagField.setText(this.tag);
|
||||
this.tagField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.tag = text;
|
||||
this.builderTag.setName(this.tag);
|
||||
container.initButtons();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points"), () ->
|
||||
{
|
||||
this.selectedPlayer = "add|set|remove";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag"), () ->
|
||||
{
|
||||
this.selectedPlayer = "tag";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.trigger"), () ->
|
||||
{
|
||||
this.selectedPlayer = "enable";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
button3.enabled = !this.selectedPlayer.equals("add|set|remove");
|
||||
button4.enabled = !this.selectedPlayer.equals("tag");
|
||||
button5.enabled = !this.selectedPlayer.equals("enable");
|
||||
button1.enabled = !this.selectedPlayer.equals("add|set|remove");
|
||||
button2.enabled = !this.selectedPlayer.equals("tag");
|
||||
button3.enabled = !this.selectedPlayer.equals("enable");
|
||||
|
||||
boolean enabled = ContentScoreboard.isObjectiveValid();
|
||||
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, ConfigSliders.getMaxPlayerPoints(), 0, new SimpleResponder<String>(value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxPlayerPoints(), 0, container, new LogicSliderSimple("points", I18n.format("gui.worldhandler.scoreboard.players.points"), value ->
|
||||
{
|
||||
this.builderPlayers.setPoints(value);
|
||||
})));
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.ADD));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.REMOVE));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button1 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.SET, 0));
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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 points = enabled && this.builderPlayers.getPoints() > 0;
|
||||
|
||||
boolean enabled = objective && this.builderPlayers.getPoints() > 0;
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
button5.enabled = objective;
|
||||
this.addButton.enabled = points;
|
||||
this.removeButton.enabled = points;
|
||||
button1.enabled = enabled;
|
||||
}
|
||||
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")));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTag.getBuilderForMode(BuilderTag.EnumMode.ADD));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTag.getBuilderForMode(BuilderTag.EnumMode.REMOVE));
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
boolean enabled = this.tag != null && !this.tag.isEmpty();
|
||||
boolean tag = this.tag != null && !this.tag.isEmpty();
|
||||
|
||||
button3.enabled = enabled;
|
||||
button4.enabled = enabled;
|
||||
button1.enabled = tag;
|
||||
button2.enabled = tag;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("enable"))
|
||||
{
|
||||
container.add(button3 = new GuiButtonWorldHandler(10, x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.enable")));
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxTriggerValue(), 0, container, new LogicSliderSimple("enable", I18n.format("gui.worldhandler.generic.value"), value ->
|
||||
{
|
||||
this.builderTrigger.setValue(value.intValue());
|
||||
})));
|
||||
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.add"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTrigger.getBuilderForMode(BuilderTrigger.EnumMode.ADD));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.set"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTrigger.getBuilderForMode(BuilderTrigger.EnumMode.SET));
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderPlayers.getBuilderForEnable());
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
button3.enabled = objective;
|
||||
this.addButton.enabled = enabled && this.builderTrigger.getValue() > 0;
|
||||
this.removeButton.enabled = enabled;
|
||||
button1.enabled = enabled;
|
||||
}
|
||||
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
this.builderPlayers.setTag(this.tag);
|
||||
container.add(this.tagField);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.builderPlayers.setObjective(this.objective);
|
||||
container.add(this.objectField);
|
||||
this.builderPlayers.setObjective(ContentScoreboard.getObjective());
|
||||
this.builderTrigger.setObjective(ContentScoreboard.getObjective());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
public void tick(Container container)
|
||||
{
|
||||
if(this.selectedPlayer.equals("add|set|remove"))
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
boolean objective = this.builderPlayers.getObjective() != null && !this.builderPlayers.getObjective().isEmpty();
|
||||
boolean enabled = objective && this.builderPlayers.getPoints() > 0;
|
||||
this.tagField.tick();
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean enabled = ContentScoreboard.isObjectiveValid();
|
||||
|
||||
this.addButton.enabled = enabled;
|
||||
this.removeButton.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
{
|
||||
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;
|
||||
if(this.selectedPlayer.equals("add|set|remove"))
|
||||
{
|
||||
boolean points = enabled && this.builderPlayers.getPoints() > 0;
|
||||
|
||||
this.addButton.enabled = points;
|
||||
this.removeButton.enabled = points;
|
||||
}
|
||||
else if(this.selectedPlayer.equals("enable"))
|
||||
{
|
||||
this.addButton.enabled = enabled && this.builderTrigger.getValue() > 0;
|
||||
this.removeButton.enabled = enabled;
|
||||
}
|
||||
|
||||
this.objectField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,42 +250,11 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
{
|
||||
if(this.selectedPlayer.equals("tag"))
|
||||
{
|
||||
this.tagField.drawTextBox();
|
||||
this.tagField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
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);
|
||||
this.objectField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,5 +274,6 @@ public class ContentScoreboardPlayers extends ContentScoreboard
|
||||
public void onPlayerNameChanged(String username)
|
||||
{
|
||||
this.builderPlayers.setPlayer(username);
|
||||
this.builderTag.setPlayer(username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardTeams.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTeams;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTeams.EnumMode;
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.element.impl.ElementMultiButtonList;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentScoreboard;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import exopandora.worldhandler.gui.logic.ILogicClickList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentScoreboardTeams extends ContentScoreboard
|
||||
{
|
||||
private GuiTextFieldTooltip teamField;
|
||||
@@ -30,7 +31,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
private String team;
|
||||
private String selectedTeam = "add";
|
||||
|
||||
private final BuilderScoreboardTeams builderTeams = new BuilderScoreboardTeams();
|
||||
private final BuilderTeams builderTeams = new BuilderTeams();
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
@@ -44,39 +45,53 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
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);
|
||||
this.teamField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.team = text;
|
||||
this.builderTeams.setTeam(this.team);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
if(this.selectedTeam.equals("option"))
|
||||
{
|
||||
ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), new int[] {6, 7}, this, new ILogicClickList()
|
||||
ElementMultiButtonList options = new ElementMultiButtonList(x + 118, y + 24, HELPER.getOptions(), 2, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate(String... keys)
|
||||
public String translate(String key, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
if(depth == 0)
|
||||
{
|
||||
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(keys[1])))
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.options." + key);
|
||||
}
|
||||
else if(depth == 1)
|
||||
{
|
||||
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key)))
|
||||
{
|
||||
return I18n.format("gui.worldhandler.color." + keys[1]);
|
||||
return I18n.format("gui.worldhandler.color." + key);
|
||||
}
|
||||
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.suboption." + keys[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.options." + keys[0]);
|
||||
return I18n.format("gui.worldhandler.scoreboard.team.suboption." + key);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeKey(String... keys)
|
||||
public String buildEventKey(List<String> keys, int depth)
|
||||
{
|
||||
if(keys.length > 1)
|
||||
return ILogicClickList.super.buildTranslationKey(keys, depth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(String key, int depth)
|
||||
{
|
||||
if(depth == 0)
|
||||
{
|
||||
builderTeams.setValue(keys[1]);
|
||||
ContentScoreboardTeams.this.builderTeams.setRule(key);
|
||||
}
|
||||
else
|
||||
else if(depth == 1)
|
||||
{
|
||||
builderTeams.setRule(keys[0]);
|
||||
ContentScoreboardTeams.this.builderTeams.setValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,23 +109,39 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.create"), () ->
|
||||
{
|
||||
this.selectedTeam = "add";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.join") + " / " + I18n.format("gui.worldhandler.scoreboard.team.leave"), () ->
|
||||
{
|
||||
this.selectedTeam = "join|leave";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.remove") + " / " + I18n.format("gui.worldhandler.scoreboard.team.empty"), () ->
|
||||
{
|
||||
this.selectedTeam = "remove|empty";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.options"), () ->
|
||||
{
|
||||
this.selectedTeam = "option";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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");
|
||||
button1.enabled = !this.selectedTeam.equals("add");
|
||||
button2.enabled = !this.selectedTeam.equals("join|leave");
|
||||
button3.enabled = !this.selectedTeam.equals("remove|empty");
|
||||
button4.enabled = !this.selectedTeam.equals("option");
|
||||
|
||||
this.builderTeams.setMode(this.selectedTeam);
|
||||
|
||||
@@ -124,96 +155,61 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
{
|
||||
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")));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.join"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.JOIN));
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.leave"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.LEAVE));
|
||||
container.initButtons();
|
||||
}));
|
||||
|
||||
button3.enabled = enabled;
|
||||
button1.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")));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.remove"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.REMOVE));
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.empty"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTeams.getBuilderForMode(EnumMode.EMPTY));
|
||||
container.initButtons();
|
||||
}));
|
||||
|
||||
button3.enabled = enabled;
|
||||
button4.enabled = enabled;
|
||||
button1.enabled = enabled;
|
||||
button2.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;
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 48 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderTeams);
|
||||
container.initButtons();
|
||||
}));
|
||||
button1.enabled = enabled;
|
||||
}
|
||||
|
||||
container.add(this.teamField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
public void tick(Container container)
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.teamField.tick();
|
||||
}
|
||||
|
||||
@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);
|
||||
this.teamField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.element.impl.ElementPageList;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.BooleanSetting;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.IntegerSetting;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentSettings extends ContentChild
|
||||
{
|
||||
private static final List<Setting<?>> SETTINGS = new ArrayList<Setting<?>>();
|
||||
|
||||
static
|
||||
{
|
||||
SETTINGS.add(new BooleanSetting("command_syntax", Config.CLIENT.getSettings()::commandSyntax, Config.CLIENT.getSettings()::setCommandSyntax));
|
||||
SETTINGS.add(new BooleanSetting("shortcuts", Config.CLIENT.getSettings()::shortcuts, Config.CLIENT.getSettings()::setShortcuts));
|
||||
SETTINGS.add(new BooleanSetting("key_shortcuts", Config.CLIENT.getSettings()::shortcutKeys, Config.CLIENT.getSettings()::setShortcutKeys));
|
||||
SETTINGS.add(new BooleanSetting("tooltips", Config.CLIENT.getSettings()::tooltips, Config.CLIENT.getSettings()::setTooltips));
|
||||
SETTINGS.add(new BooleanSetting("watch", Config.CLIENT.getSettings()::watch, Config.CLIENT.getSettings()::setWatch));
|
||||
SETTINGS.add(new BooleanSetting("smooth_watch", Config.CLIENT.getSettings()::smoothWatch, Config.CLIENT.getSettings()::setSmoothWatch));
|
||||
SETTINGS.add(new BooleanSetting("pause_game", Config.CLIENT.getSettings()::pause, Config.CLIENT.getSettings()::setPause));
|
||||
SETTINGS.add(new BooleanSetting("custom_times", Config.CLIENT.getSettings()::customTimes, Config.CLIENT.getSettings()::setCustomTimes));
|
||||
SETTINGS.add(new BooleanSetting("permission_query", Config.CLIENT.getSettings()::permissionQuery, Config.CLIENT.getSettings()::setPermissionQuery));
|
||||
SETTINGS.add(new BooleanSetting("highlight_blocks", Config.CLIENT.getSettings()::highlightBlocks, Config.CLIENT.getSettings()::setHighlightBlocks));
|
||||
SETTINGS.add(new IntegerSetting("custom_time_dawn", Config.CLIENT.getSettings()::getDawn, Config.CLIENT.getSettings()::setDawn));
|
||||
SETTINGS.add(new IntegerSetting("custom_time_noon", Config.CLIENT.getSettings()::getNoon, Config.CLIENT.getSettings()::setNoon));
|
||||
SETTINGS.add(new IntegerSetting("custom_time_sunset", Config.CLIENT.getSettings()::getSunset, Config.CLIENT.getSettings()::setSunset));
|
||||
SETTINGS.add(new IntegerSetting("custom_time_midnight", Config.CLIENT.getSettings()::getMidnight, Config.CLIENT.getSettings()::setMidnight));
|
||||
}
|
||||
|
||||
private Setting<?> setting;
|
||||
private GuiTextFieldTooltip valueField;
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
ElementPageList<Setting<?>> settings = new ElementPageList<Setting<?>>(x, y, SETTINGS, 114, 20, 3, container, new ILogicPageList<Setting<?>>()
|
||||
{
|
||||
@Override
|
||||
public String translate(Setting<?> item)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.config.key.settings." + item.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toTooltip(Setting<?> item)
|
||||
{
|
||||
return I18n.format("gui.worldhandler.config.comment.settings." + item.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Setting<?> item)
|
||||
{
|
||||
ContentSettings.this.setting = item;
|
||||
container.initButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Setting<?> item, ActionHandler actionHandler)
|
||||
{
|
||||
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "settings";
|
||||
}
|
||||
});
|
||||
|
||||
container.add(settings);
|
||||
|
||||
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.value"));
|
||||
this.valueField.setValidator(string ->
|
||||
{
|
||||
if(string == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!string.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt(string);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
if(this.setting instanceof BooleanSetting)
|
||||
{
|
||||
BooleanSetting setting = (BooleanSetting) this.setting;
|
||||
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
|
||||
{
|
||||
setting.set(true);
|
||||
container.initButtons();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable"), () ->
|
||||
{
|
||||
setting.set(false);
|
||||
container.initButtons();
|
||||
}));
|
||||
|
||||
boolean enabled = setting.get();
|
||||
|
||||
button1.enabled = !enabled;
|
||||
button2.enabled = enabled;
|
||||
}
|
||||
else if(this.setting instanceof IntegerSetting)
|
||||
{
|
||||
IntegerSetting setting = (IntegerSetting) this.setting;
|
||||
this.valueField.setText(String.valueOf(setting.get()));
|
||||
|
||||
container.add(this.valueField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.set"), () ->
|
||||
{
|
||||
String text = this.valueField.getText();
|
||||
|
||||
if(text.isEmpty())
|
||||
{
|
||||
setting.set(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.set(Integer.parseInt(text));
|
||||
}
|
||||
|
||||
container.initButtons();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
if(this.setting instanceof IntegerSetting)
|
||||
{
|
||||
this.valueField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.setting instanceof IntegerSetting)
|
||||
{
|
||||
this.valueField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.config.category.settings");
|
||||
}
|
||||
|
||||
public abstract static class Setting<T>
|
||||
{
|
||||
private final String key;
|
||||
private final Supplier<T> getter;
|
||||
private final Consumer<T> setter;
|
||||
|
||||
public Setting(String key, Supplier<T> getter, Consumer<T> setter)
|
||||
{
|
||||
this.key = key;
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public T get()
|
||||
{
|
||||
return this.getter.get();
|
||||
}
|
||||
|
||||
public void set(T value)
|
||||
{
|
||||
this.setter.accept(value);
|
||||
}
|
||||
|
||||
public static class BooleanSetting extends Setting<Boolean>
|
||||
{
|
||||
public BooleanSetting(String key, Supplier<Boolean> getter, Consumer<Boolean> setter)
|
||||
{
|
||||
super(key, getter, setter);
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntegerSetting extends Setting<Integer>
|
||||
{
|
||||
public IntegerSetting(String key, Supplier<Integer> getter, Consumer<Integer> setter)
|
||||
{
|
||||
super(key, getter, setter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
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.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
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.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
@@ -18,31 +15,28 @@ 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.gui.logic.ILogicColorMenu;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentSignEditor extends Content
|
||||
{
|
||||
private static final ResourceLocation LOGO = new ResourceLocation(Main.MODID, "textures/logo.png");
|
||||
|
||||
private int selectedLine = 0;
|
||||
private boolean editColor;
|
||||
|
||||
private GuiTextFieldTooltip commandField;
|
||||
private GuiTextFieldTooltip textlineField;
|
||||
|
||||
private final BuilderSignEditor builderSignEditor = new BuilderSignEditor();
|
||||
|
||||
@@ -57,7 +51,7 @@ public class ContentSignEditor extends Content
|
||||
@Override
|
||||
public void init(Container container)
|
||||
{
|
||||
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
|
||||
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
|
||||
this.builderSignEditor.setPosition(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
|
||||
@@ -65,30 +59,35 @@ public class ContentSignEditor extends Content
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
if(this.isActive)
|
||||
{
|
||||
{
|
||||
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.commmand"));
|
||||
this.commandField.setValidator(Predicates.notNull());
|
||||
this.commandField.setText(this.builderSignEditor.getCommand(this.selectedLine));
|
||||
this.commandField.setCursorPositionEnd();
|
||||
this.commandField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.builderSignEditor.setCommand(this.selectedLine, text);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
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()
|
||||
ElementColorMenu colors = new ElementColorMenu(x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.builderSignEditor.getColoredString(this.selectedLine), new ILogicColorMenu()
|
||||
{
|
||||
@Override
|
||||
public Predicate<String> getValidator()
|
||||
public boolean validate(String text)
|
||||
{
|
||||
return string -> Minecraft.getMinecraft().fontRenderer.getStringWidth(string) <= 90;
|
||||
return Minecraft.getInstance().fontRenderer.getStringWidth(text) <= 90;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawButtons()
|
||||
public boolean doDrawButtons()
|
||||
{
|
||||
return editColor;
|
||||
return ContentSignEditor.this.editColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "color" + selectedLine;
|
||||
return "color" + ContentSignEditor.this.selectedLine;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -99,71 +98,63 @@ public class ContentSignEditor extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler button3;
|
||||
GuiButtonWorldHandler button4;
|
||||
GuiButtonWorldHandler button5;
|
||||
GuiButtonWorldHandler button6;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_1"), () ->
|
||||
{
|
||||
this.selectedLine = 0;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_2"), () ->
|
||||
{
|
||||
this.selectedLine = 1;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_3"), () ->
|
||||
{
|
||||
this.selectedLine = 2;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_4"), () ->
|
||||
{
|
||||
this.selectedLine = 3;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.editColor)
|
||||
{
|
||||
container.add(new GuiButtonWorldHandler(7, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.done")));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.done"), () -> this.toggleEditColor(container)));
|
||||
}
|
||||
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")));
|
||||
container.add(this.commandField);
|
||||
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.format_text_line"), () -> this.toggleEditColor(container)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block"), () ->
|
||||
{
|
||||
CommandHelper.sendCommand(this.builderSignEditor, this.builderSignEditor.isSpecial());
|
||||
}));
|
||||
}
|
||||
|
||||
button3.enabled = this.selectedLine != 0;
|
||||
button4.enabled = this.selectedLine != 1;
|
||||
button5.enabled = this.selectedLine != 2;
|
||||
button6.enabled = this.selectedLine != 3;
|
||||
button1.enabled = this.selectedLine != 0;
|
||||
button2.enabled = this.selectedLine != 1;
|
||||
button3.enabled = this.selectedLine != 2;
|
||||
button4.enabled = this.selectedLine != 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
private void toggleEditColor(Container container)
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.editColor = !this.editColor;
|
||||
container.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
@@ -171,49 +162,27 @@ public class ContentSignEditor extends Content
|
||||
{
|
||||
if(!this.editColor)
|
||||
{
|
||||
this.commandField.drawTextBox();
|
||||
this.commandField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float scale = 4;
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.color3f(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);
|
||||
GlStateManager.translatef(container.width / 2 - 8.5F * scale, container.height / 2 - 15 - 8.5F * scale, 0);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
Minecraft.getInstance().getItemRenderer().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());
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", WorldHandler.KEY_WORLD_HANDLER.func_197978_k());
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().getLabelColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,39 +9,39 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSummon;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.config.ConfigSliders;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
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.util.UtilPlayer;
|
||||
import exopandora.worldhandler.gui.logic.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.logic.LogicSliderSimple;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentSummon extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip mobField;
|
||||
@@ -73,9 +73,9 @@ public class ContentSummon extends Content
|
||||
{
|
||||
double ammount = this.builderSummon.getAttributeAmmount(attribute);
|
||||
|
||||
if(ammount > ConfigSliders.getMaxSummonAttributes())
|
||||
if(ammount > Config.getSliders().getMaxSummonAttributes())
|
||||
{
|
||||
this.builderSummon.setAttribute(attribute, ConfigSliders.getMaxSummonAttributes());
|
||||
this.builderSummon.setAttribute(attribute, Config.getSliders().getMaxSummonAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,16 +83,16 @@ public class ContentSummon extends Content
|
||||
{
|
||||
byte amplifier = this.builderSummon.getAmplifier(potion);
|
||||
|
||||
if(amplifier > ConfigSliders.getMaxSummonPotionAmplifier())
|
||||
if(amplifier > Config.getSliders().getMaxSummonPotionAmplifier())
|
||||
{
|
||||
this.builderSummon.setAmplifier(potion, (byte) ConfigSliders.getMaxSummonPotionAmplifier());
|
||||
this.builderSummon.setAmplifier(potion, (byte) Config.getSliders().getMaxSummonPotionAmplifier());
|
||||
}
|
||||
|
||||
int minutes = this.builderSummon.getMinutes(potion);
|
||||
|
||||
if(minutes > ConfigSliders.getMaxSummonPotionMinutes())
|
||||
if(minutes > Config.getSliders().getMaxSummonPotionMinutes())
|
||||
{
|
||||
this.builderSummon.setMinutes(potion, (int) ConfigSliders.getMaxSummonPotionMinutes());
|
||||
this.builderSummon.setMinutes(potion, (int) Config.getSliders().getMaxSummonPotionMinutes());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,55 +100,71 @@ public class ContentSummon extends Content
|
||||
@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.mobField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.mob = text;
|
||||
this.builderSummon.setEntity(this.mob);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
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.customNameField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.name = text;
|
||||
this.builderSummon.setCustomName(this.name);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
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);
|
||||
this.passengerField.setTextAcceptHandler((id, text) ->
|
||||
{
|
||||
this.passenger = this.passengerField.getText();
|
||||
this.builderSummon.setPassenger(this.passenger);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
if(this.page.equals("attributes"))
|
||||
{
|
||||
ElementPageList<EnumAttributes, Object> attributes = new ElementPageList<EnumAttributes, Object>(x + 118, y, this.attributes, null, 114, 20, 3, this, new int[] {6, 7, 8}, new ILogicPageList<EnumAttributes, Object>()
|
||||
ElementPageList<EnumAttributes> attributes = new ElementPageList<EnumAttributes>(x + 118, y, this.attributes, 114, 20, 3, container, new ILogicPageList<EnumAttributes>()
|
||||
{
|
||||
@Override
|
||||
public String translate(EnumAttributes key)
|
||||
public String translate(EnumAttributes item)
|
||||
{
|
||||
return key.getTranslation();
|
||||
return item.getTranslation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes clicked)
|
||||
public String toTooltip(EnumAttributes item)
|
||||
{
|
||||
return item.getAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(EnumAttributes item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryName(EnumAttributes key)
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, EnumAttributes item, ActionHandler actionHandler)
|
||||
{
|
||||
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, -ConfigSliders.getMaxSummonAttributes(), ConfigSliders.getMaxSummonAttributes(), 0, new AttributeResponder(response ->
|
||||
return new GuiSlider(x, y, width, height, -Config.getSliders().getMaxSummonAttributes(), Config.getSliders().getMaxSummonAttributes(), 0, container, new LogicSliderAttribute(item, text, value ->
|
||||
{
|
||||
builderSummon.setAttribute(value, response);
|
||||
})));
|
||||
ContentSummon.this.builderSummon.setAttribute(item, value);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAttributes getObject(Object object)
|
||||
public boolean doDisable()
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,92 +181,123 @@ public class ContentSummon extends Content
|
||||
@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;
|
||||
GuiButtonBase button1;
|
||||
GuiButtonBase button2;
|
||||
GuiButtonBase button3;
|
||||
GuiButtonBase button4;
|
||||
GuiButtonBase button5;
|
||||
GuiButtonBase button6;
|
||||
GuiButtonBase button7;
|
||||
GuiButtonItem button8;
|
||||
GuiButtonItem button9;
|
||||
GuiButtonItem button10;
|
||||
GuiButtonItem button11;
|
||||
GuiButtonItem button12;
|
||||
GuiButtonItem button13;
|
||||
GuiButtonBase button13;
|
||||
GuiButtonItem button14;
|
||||
GuiButtonItem button15;
|
||||
GuiButtonWorldHandler button16;
|
||||
GuiButtonItem button16;
|
||||
GuiButtonItem button17;
|
||||
GuiButtonItem button18;
|
||||
GuiButtonItem button19;
|
||||
GuiButtonBase button19;
|
||||
GuiButtonItem button20;
|
||||
GuiButtonItem button21;
|
||||
GuiButtonWorldHandler button22;
|
||||
GuiButtonItem button22;
|
||||
GuiButtonItem button23;
|
||||
GuiButtonItem button24;
|
||||
GuiButtonItem button25;
|
||||
GuiButtonItem button26;
|
||||
GuiButtonItem button27;
|
||||
GuiButtonWorldHandler button28;
|
||||
GuiButtonBase button25;
|
||||
|
||||
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 GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(button4 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.entities.summon.start"), () ->
|
||||
{
|
||||
this.page = "main";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button5 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.summon.potion_effects"), () ->
|
||||
{
|
||||
this.page = "potionEffects";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button6 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.summon.attributes"), () ->
|
||||
{
|
||||
this.page = "attributes";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button7 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.summon.equipment"), () ->
|
||||
{
|
||||
this.page = "equipment";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
button7.enabled = false;
|
||||
button4.enabled = false;
|
||||
|
||||
container.add(this.mobField);
|
||||
container.add(this.customNameField);
|
||||
container.add(this.passengerField);
|
||||
|
||||
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")));
|
||||
container.add(button3 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.title.entities.summon"), this::send));
|
||||
}
|
||||
else
|
||||
{
|
||||
container.add(button5 = new GuiButtonWorldHandler(9, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block")));
|
||||
container.add(button3 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block"), this::send));
|
||||
}
|
||||
|
||||
button5.enabled = EntityList.isRegistered(this.builderSummon.getEntity());
|
||||
button3.enabled = ForgeRegistries.ENTITIES.containsKey(this.builderSummon.getEntity());
|
||||
}
|
||||
else if(this.page.equals("potionEffects"))
|
||||
{
|
||||
button8.enabled = false;
|
||||
button5.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, ">"));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
|
||||
{
|
||||
this.potionPage--;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118 + 60, y + 72, 55, 20, ">", () ->
|
||||
{
|
||||
this.potionPage++;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
int count = 0;
|
||||
|
||||
for(ResourceLocation location : this.getSortedPotionList())
|
||||
{
|
||||
Potion potion = Potion.REGISTRY.getObject(location);
|
||||
Potion potion = ForgeRegistries.POTIONS.getValue(location);
|
||||
|
||||
if(!potion.equals(MobEffects.INSTANT_DAMAGE) && !potion.equals(MobEffects.INSTANT_HEALTH))
|
||||
{
|
||||
if(this.potionPage == 0)
|
||||
{
|
||||
button3.enabled = false;
|
||||
button1.enabled = false;
|
||||
}
|
||||
|
||||
if(this.potionPage == Potion.REGISTRY.getKeys().size() - 3)
|
||||
|
||||
if(this.potionPage == ForgeRegistries.POTIONS.getKeys().size() - 3)
|
||||
{
|
||||
button4.enabled = false;
|
||||
button2.enabled = false;
|
||||
}
|
||||
|
||||
if(count == this.potionPage)
|
||||
{
|
||||
container.add(new GuiSlider<Potion>(this, container, "amplifier" + potion.getRegistryName(), x + 118, y, 114, 20, I18n.format(potion.getName()), 0, ConfigSliders.getMaxSummonPotionAmplifier(), 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxSummonPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + potion.getRegistryName(), I18n.format(potion.getName()), value ->
|
||||
{
|
||||
this.builderSummon.setAmplifier(potion, value.byteValue());
|
||||
})));
|
||||
container.add(new GuiSlider<Potion>(this, container, "duration" + potion.getRegistryName(), x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potion.time.minutes"), 0, ConfigSliders.getMaxSummonPotionMinutes(), 0, new SimpleResponder<Potion>(value ->
|
||||
container.add(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxSummonPotionMinutes(), 0, container, new LogicSliderSimple("duration" + potion.getRegistryName(), I18n.format("gui.worldhandler.potion.time.minutes"), 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"))));
|
||||
container.add(new GuiButtonBase(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")), () ->
|
||||
{
|
||||
this.builderSummon.setShowParticles(potion, !this.builderSummon.getShowParticles(potion));
|
||||
container.initGui();
|
||||
}));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -260,316 +307,275 @@ public class ContentSummon extends Content
|
||||
}
|
||||
else if(this.page.equals("attributes"))
|
||||
{
|
||||
button9.enabled = false;
|
||||
button6.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, ">"));
|
||||
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
|
||||
{
|
||||
this.equipmentPage--;
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button2 = new GuiButtonBase(x + 118 + 60, y + 72, 54, 20, ">", () ->
|
||||
{
|
||||
this.equipmentPage++;
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.equipmentPage == 0)
|
||||
{
|
||||
button3.enabled = false;
|
||||
button1.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(button8 = new GuiButtonItem(x + 118, y, 18, 20, Items.LEATHER_HELMET, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Items.LEATHER_HELMET);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button9 = new GuiButtonItem(x + 118 + 20 - 1, y, 18, 20, Items.IRON_HELMET, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Items.IRON_HELMET);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button10 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_HELMET, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Items.CHAINMAIL_HELMET);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button11 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_HELMET, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Items.GOLDEN_HELMET);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button12 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_HELMET, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Items.DIAMOND_HELMET);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button13 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(3, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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(button14 = new GuiButtonItem(x + 118, y + 24, 18, 20, Items.LEATHER_CHESTPLATE, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Items.LEATHER_CHESTPLATE);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button15 = new GuiButtonItem(x + 118 + 20 - 1, y + 24, 18, 20, Items.IRON_CHESTPLATE, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Items.IRON_CHESTPLATE);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button16 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.CHAINMAIL_CHESTPLATE, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Items.CHAINMAIL_CHESTPLATE);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button17 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_CHESTPLATE, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Items.GOLDEN_CHESTPLATE);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button18 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_CHESTPLATE, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Items.DIAMOND_CHESTPLATE);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button19 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 24, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(2, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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));
|
||||
container.add(button20 = new GuiButtonItem(x + 118, y + 48, 18, 20, Items.LEATHER_LEGGINGS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Items.LEATHER_LEGGINGS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button21 = new GuiButtonItem(x + 118 + 20 - 1, y + 48, 18, 20, Items.IRON_LEGGINGS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Items.IRON_LEGGINGS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button22 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.CHAINMAIL_LEGGINGS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Items.CHAINMAIL_LEGGINGS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button23 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_LEGGINGS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Items.GOLDEN_LEGGINGS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button24 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_LEGGINGS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Items.DIAMOND_LEGGINGS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button25 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 48, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(1, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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());
|
||||
button8.enabled = !this.builderSummon.getArmorItem(3).equals(Items.LEATHER_HELMET.getRegistryName());
|
||||
button9.enabled = !this.builderSummon.getArmorItem(3).equals(Items.IRON_HELMET.getRegistryName());
|
||||
button10.enabled = !this.builderSummon.getArmorItem(3).equals(Items.CHAINMAIL_HELMET.getRegistryName());
|
||||
button11.enabled = !this.builderSummon.getArmorItem(3).equals(Items.GOLDEN_HELMET.getRegistryName());
|
||||
button12.enabled = !this.builderSummon.getArmorItem(3).equals(Items.DIAMOND_HELMET.getRegistryName());
|
||||
button13.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());
|
||||
button14.enabled = !this.builderSummon.getArmorItem(2).equals(Items.LEATHER_CHESTPLATE.getRegistryName());
|
||||
button15.enabled = !this.builderSummon.getArmorItem(2).equals(Items.IRON_CHESTPLATE.getRegistryName());
|
||||
button16.enabled = !this.builderSummon.getArmorItem(2).equals(Items.CHAINMAIL_CHESTPLATE.getRegistryName());
|
||||
button17.enabled = !this.builderSummon.getArmorItem(2).equals(Items.GOLDEN_CHESTPLATE.getRegistryName());
|
||||
button18.enabled = !this.builderSummon.getArmorItem(2).equals(Items.DIAMOND_CHESTPLATE.getRegistryName());
|
||||
button19.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());
|
||||
button20.enabled = !this.builderSummon.getArmorItem(1).equals(Items.LEATHER_LEGGINGS.getRegistryName());
|
||||
button21.enabled = !this.builderSummon.getArmorItem(1).equals(Items.IRON_LEGGINGS.getRegistryName());
|
||||
button22.enabled = !this.builderSummon.getArmorItem(1).equals(Items.CHAINMAIL_LEGGINGS.getRegistryName());
|
||||
button23.enabled = !this.builderSummon.getArmorItem(1).equals(Items.GOLDEN_LEGGINGS.getRegistryName());
|
||||
button24.enabled = !this.builderSummon.getArmorItem(1).equals(Items.DIAMOND_LEGGINGS.getRegistryName());
|
||||
button25.enabled = !this.builderSummon.getArmorItem(1).equals(Blocks.AIR.getRegistryName());
|
||||
}
|
||||
else if(this.equipmentPage == 1)
|
||||
{
|
||||
button4.enabled = false;
|
||||
button2.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(button8 = new GuiButtonItem(x + 118, y, 18, 20, Items.LEATHER_BOOTS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Items.LEATHER_BOOTS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button9 = new GuiButtonItem(x + 118 + 20 - 1, y, 18, 20, Items.IRON_BOOTS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Items.IRON_BOOTS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button10 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_BOOTS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Items.CHAINMAIL_BOOTS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button11 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_BOOTS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Items.GOLDEN_BOOTS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button12 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_BOOTS, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Items.DIAMOND_BOOTS);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button13 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setArmorItem(0, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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(button14 = new GuiButtonItem(x + 118, y + 24, 18, 20, Items.WOODEN_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Items.WOODEN_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button15 = new GuiButtonItem(x + 118 + 20 - 1, y + 24, 18, 20, Items.STONE_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Items.STONE_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button16 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.IRON_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Items.IRON_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button17 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Items.GOLDEN_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button18 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Items.DIAMOND_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button19 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 24, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(0, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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));
|
||||
container.add(button20 = new GuiButtonItem(x + 118, y + 48, 18, 20, Items.WOODEN_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Items.WOODEN_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button21 = new GuiButtonItem(x + 118 + 20 - 1, y + 48, 18, 20, Items.STONE_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Items.STONE_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button22 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.IRON_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Items.IRON_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button23 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Items.GOLDEN_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button24 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_SWORD, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Items.DIAMOND_SWORD);
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(button25 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 48, 20, 20, null, () ->
|
||||
{
|
||||
this.builderSummon.setHandItem(1, Blocks.AIR);
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
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());
|
||||
button8.enabled = !this.builderSummon.getArmorItem(0).equals(Items.LEATHER_BOOTS.getRegistryName());
|
||||
button9.enabled = !this.builderSummon.getArmorItem(0).equals(Items.IRON_BOOTS.getRegistryName());
|
||||
button10.enabled = !this.builderSummon.getArmorItem(0).equals(Items.CHAINMAIL_BOOTS.getRegistryName());
|
||||
button11.enabled = !this.builderSummon.getArmorItem(0).equals(Items.GOLDEN_BOOTS.getRegistryName());
|
||||
button12.enabled = !this.builderSummon.getArmorItem(0).equals(Items.DIAMOND_BOOTS.getRegistryName());
|
||||
button13.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());
|
||||
button14.enabled = !this.builderSummon.getHandItem(0).equals(Items.WOODEN_SWORD.getRegistryName());
|
||||
button15.enabled = !this.builderSummon.getHandItem(0).equals(Items.STONE_SWORD.getRegistryName());
|
||||
button16.enabled = !this.builderSummon.getHandItem(0).equals(Items.IRON_SWORD.getRegistryName());
|
||||
button17.enabled = !this.builderSummon.getHandItem(0).equals(Items.GOLDEN_SWORD.getRegistryName());
|
||||
button18.enabled = !this.builderSummon.getHandItem(0).equals(Items.DIAMOND_SWORD.getRegistryName());
|
||||
button19.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());
|
||||
button20.enabled = !this.builderSummon.getHandItem(1).equals(Items.WOODEN_SWORD.getRegistryName());
|
||||
button21.enabled = !this.builderSummon.getHandItem(1).equals(Items.STONE_SWORD.getRegistryName());
|
||||
button22.enabled = !this.builderSummon.getHandItem(1).equals(Items.IRON_SWORD.getRegistryName());
|
||||
button23.enabled = !this.builderSummon.getHandItem(1).equals(Items.GOLDEN_SWORD.getRegistryName());
|
||||
button24.enabled = !this.builderSummon.getHandItem(1).equals(Items.DIAMOND_SWORD.getRegistryName());
|
||||
button25.enabled = !this.builderSummon.getHandItem(1).equals(Blocks.AIR.getRegistryName());
|
||||
}
|
||||
|
||||
button10.enabled = false;
|
||||
button7.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
private void send()
|
||||
{
|
||||
switch(button.id)
|
||||
CommandHelper.sendCommand(this.builderSummon, this.builderSummon.getCustomName().isSpecial());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
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;
|
||||
this.mobField.tick();
|
||||
this.customNameField.tick();
|
||||
this.passengerField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,14 +584,14 @@ public class ContentSummon extends Content
|
||||
{
|
||||
if(this.page.equals("main"))
|
||||
{
|
||||
this.mobField.drawTextBox();
|
||||
this.customNameField.drawTextBox();
|
||||
this.passengerField.drawTextBox();
|
||||
this.mobField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.customNameField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.passengerField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
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"));
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/beacon.png"));
|
||||
|
||||
for(int row = 0; row < 3; row++)
|
||||
{
|
||||
@@ -594,46 +600,10 @@ public class ContentSummon extends Content
|
||||
}
|
||||
}
|
||||
|
||||
@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())));
|
||||
List<ResourceLocation> potions = new ArrayList<ResourceLocation>(ForgeRegistries.POTIONS.getKeys());
|
||||
potions.sort((a, b) -> I18n.format(ForgeRegistries.POTIONS.getValue(a).getName()).compareTo(I18n.format(ForgeRegistries.POTIONS.getValue(b).getName())));
|
||||
|
||||
return potions;
|
||||
}
|
||||
@@ -663,7 +633,7 @@ public class ContentSummon extends Content
|
||||
|
||||
if(this.page.equals("potionEffects"))
|
||||
{
|
||||
headline[1] = (this.potionPage + 1) + "/" + (Potion.REGISTRY.getKeys().size() - 2);
|
||||
headline[1] = (this.potionPage + 1) + "/" + (ForgeRegistries.POTIONS.getKeys().size() - 2);
|
||||
}
|
||||
else if(this.page.equals("equipment"))
|
||||
{
|
||||
|
||||
@@ -3,22 +3,23 @@ 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.GuiButtonBase;
|
||||
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.helper.ActionHelper;
|
||||
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.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentWorldInfo extends Content
|
||||
{
|
||||
private String selectedMain = "start";
|
||||
@@ -37,12 +38,7 @@ public class ContentWorldInfo extends Content
|
||||
@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();
|
||||
}
|
||||
World world = this.getWorld();
|
||||
|
||||
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));
|
||||
@@ -53,17 +49,16 @@ public class ContentWorldInfo extends Content
|
||||
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 = new GuiTextFieldTooltip(x + 118, y, 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 = new GuiTextFieldTooltip(x + 118, y + 24, 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 = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
|
||||
this.seedField.setText(I18n.format("gui.worldhandler.world_info.world.seed") + ": " + this.getSeed(world));
|
||||
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();
|
||||
@@ -75,16 +70,28 @@ public class ContentWorldInfo extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonWorldHandler start;
|
||||
GuiButtonWorldHandler world;
|
||||
GuiButtonWorldHandler stats;
|
||||
GuiButtonBase start;
|
||||
GuiButtonBase world;
|
||||
GuiButtonBase 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(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::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")));
|
||||
container.add(start = new GuiButtonBase(x, y + 12, 114, 20, I18n.format("gui.worldhandler.world_info.start"), () ->
|
||||
{
|
||||
this.selectedMain = "start";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(world = new GuiButtonBase(x, y + 36, 114, 20, I18n.format("gui.worldhandler.world_info.world"), () ->
|
||||
{
|
||||
this.selectedMain = "world";
|
||||
container.initGui();
|
||||
}));
|
||||
container.add(stats = new GuiButtonBase(x, y + 60, 114, 20, I18n.format("gui.worldhandler.world_info.statistics"), () ->
|
||||
{
|
||||
this.selectedMain = "stats";
|
||||
container.initGui();
|
||||
}));
|
||||
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
@@ -92,7 +99,15 @@ public class ContentWorldInfo extends Content
|
||||
}
|
||||
else if(this.selectedMain.equals("world"))
|
||||
{
|
||||
GuiButtonBase seed;
|
||||
|
||||
world.enabled = false;
|
||||
container.add(seed = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.world_info.world.copy_seed"), () ->
|
||||
{
|
||||
Minecraft.getInstance().keyboardListener.setClipboardString(this.getSeed(this.getWorld()));
|
||||
}));
|
||||
|
||||
seed.enabled = Minecraft.getInstance().getIntegratedServer() != null;
|
||||
}
|
||||
else if(this.selectedMain.equals("stats"))
|
||||
{
|
||||
@@ -101,32 +116,11 @@ public class ContentWorldInfo extends Content
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen(Container container)
|
||||
public void tick(Container container)
|
||||
{
|
||||
this.updateCurrentTime();
|
||||
this.updateTotalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(Container container, GuiButton button) throws Exception
|
||||
{
|
||||
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;
|
||||
}
|
||||
this.seedField.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,51 +128,31 @@ public class ContentWorldInfo extends Content
|
||||
{
|
||||
if(this.selectedMain.equals("start"))
|
||||
{
|
||||
this.posXField.drawTextBox();
|
||||
this.posYField.drawTextBox();
|
||||
this.posZField.drawTextBox();
|
||||
this.posXField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.posYField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.posZField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
else if(this.selectedMain.equals("world"))
|
||||
{
|
||||
this.worldField.drawTextBox();
|
||||
this.terrainField.drawTextBox();
|
||||
this.seedField.drawTextBox();
|
||||
this.worldField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.terrainField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.seedField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
else if(this.selectedMain.equals("stats"))
|
||||
{
|
||||
this.totalTimeField.drawTextBox();
|
||||
this.currentTimeField.drawTextBox();
|
||||
this.totalTimeField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
this.currentTimeField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentTime()
|
||||
{
|
||||
this.currentTimeField.setText(I18n.format("gui.worldhandler.world_info.statistics.world_time") + ": " + TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldInfo().getWorldTime()));
|
||||
this.currentTimeField.setText(I18n.format("gui.worldhandler.world_info.statistics.world_time") + ": " + TextFormatting.formatWorldTime(Minecraft.getInstance().world.getWorldInfo().getDayTime()));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
this.totalTimeField.setText(I18n.format("gui.worldhandler.world_info.statistics.played") + ": " + TextFormatting.getTotalTimePlayed(Minecraft.getInstance().world.getWorldInfo().getGameTime()));
|
||||
}
|
||||
|
||||
private <T> String getWorldInfo(Function<WorldInfo, T> function, World world)
|
||||
@@ -191,14 +165,19 @@ public class ContentWorldInfo extends Content
|
||||
return I18n.format("gui.worldhandler.world_info.n_a");
|
||||
}
|
||||
|
||||
private void updateCursorPosition()
|
||||
private World getWorld()
|
||||
{
|
||||
int length = I18n.format("gui.worldhandler.world_info.start.spawn").length();
|
||||
|
||||
if(this.seedField.getCursorPosition() < length + 2)
|
||||
if(Minecraft.getInstance().getIntegratedServer() != null)
|
||||
{
|
||||
this.seedField.setCursorPosition(length + 1);
|
||||
return Minecraft.getInstance().getIntegratedServer().getWorld(DimensionType.OVERWORLD);
|
||||
}
|
||||
|
||||
return Minecraft.getInstance().world;
|
||||
}
|
||||
|
||||
private String getSeed(World world)
|
||||
{
|
||||
return Minecraft.getInstance().getIntegratedServer() != null ? String.valueOf(world.getWorldInfo().getSeed()) : I18n.format("gui.worldhandler.world_info.n_a");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,10 +3,10 @@ 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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class ContentChild extends Content
|
||||
{
|
||||
protected Content parent;
|
||||
|
||||
@@ -5,14 +5,29 @@ 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;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class ContentScoreboard extends Content
|
||||
{
|
||||
protected static final ScoreboardHelper HELPER = new ScoreboardHelper();
|
||||
protected static String objective;
|
||||
private static String objective;
|
||||
|
||||
protected static boolean isObjectiveValid()
|
||||
{
|
||||
return ContentScoreboard.objective != null && ContentScoreboard.objective.length() > 0;
|
||||
}
|
||||
|
||||
protected static void setObjective(String objective)
|
||||
{
|
||||
ContentScoreboard.objective = objective;
|
||||
}
|
||||
|
||||
protected static String getObjective()
|
||||
{
|
||||
return ContentScoreboard.objective;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
|
||||
10
src/main/java/exopandora/worldhandler/gui/logic/ILogic.java
Normal file
10
src/main/java/exopandora/worldhandler/gui/logic/ILogic.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ILogic
|
||||
{
|
||||
String getId();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ILogicClickList extends ILogic
|
||||
{
|
||||
String translate(String key, int depth);
|
||||
|
||||
default String buildTranslationKey(List<String> keys, int depth)
|
||||
{
|
||||
return keys.get(depth);
|
||||
}
|
||||
|
||||
default String buildEventKey(List<String> keys, int depth)
|
||||
{
|
||||
return String.join(".", keys);
|
||||
}
|
||||
|
||||
void onClick(String key, int depth);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ILogicColorMenu extends ILogic
|
||||
{
|
||||
default boolean validate(String text)
|
||||
{
|
||||
return text != null;
|
||||
}
|
||||
|
||||
default boolean doDrawButtons()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
default String getId()
|
||||
{
|
||||
return "color";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ILogicMapped<T> extends ILogic
|
||||
{
|
||||
String translate(T item);
|
||||
String toTooltip(T item);
|
||||
|
||||
default String formatTooltip(T item, int index, int max)
|
||||
{
|
||||
String tooltip = this.toTooltip(item);
|
||||
|
||||
if(tooltip != null)
|
||||
{
|
||||
return String.format("%s (%d/%d)", tooltip, index, max);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void onClick(T item);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ILogicPageList<T> extends ILogicMapped<T>
|
||||
{
|
||||
GuiButtonBase onRegister(int x, int y, int width, int height, String text, T item, ActionHandler actionHandler);
|
||||
|
||||
default boolean doDisable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LogicSliderAttribute extends LogicSliderSimple
|
||||
{
|
||||
private final EnumAttributes attribute;
|
||||
|
||||
public LogicSliderAttribute(EnumAttributes attribute, String text, Consumer<Integer> listener)
|
||||
{
|
||||
super(attribute.getAttribute(), text, listener);
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatSuffix(int value)
|
||||
{
|
||||
return " " + this.attribute.getOperation().getDeclaration();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package exopandora.worldhandler.gui.logic;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiSlider.ILogicSlider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LogicSliderSimple implements ILogicSlider
|
||||
{
|
||||
private final String id;
|
||||
private final String text;
|
||||
private final Consumer<Integer> listener;
|
||||
|
||||
public LogicSliderSimple(String id, String text, Consumer<Integer> listener)
|
||||
{
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatPrefix(int value)
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatSuffix(int value)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatValue(int value)
|
||||
{
|
||||
return ": " + String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeSliderValue(int value)
|
||||
{
|
||||
this.listener.accept(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user