2016-12-29 21:29:00 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.client.gui.GuiPageButtonList.GuiResponder;
|
|
|
|
import net.minecraft.client.gui.GuiSlider;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public class GuiFireworkBox extends GuiContainer implements GuiResponder {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
private final TileEntityFireworkBox tile;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public GuiFireworkBox(TileEntity tile) {
|
2016-12-29 21:29:00 +01:00
|
|
|
super(new ContainerFireworkBox());
|
2019-05-02 09:10:29 +02:00
|
|
|
this.tile = (TileEntityFireworkBox) tile;
|
2016-12-29 21:29:00 +01:00
|
|
|
this.xSize = 300;
|
|
|
|
this.ySize = 120;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void initGui() {
|
2016-12-29 21:29:00 +01:00
|
|
|
super.initGui();
|
|
|
|
|
|
|
|
this.buttonList.add(new CustomSlider(this, 0, this.guiLeft, this.guiTop, "Value Play", 0F, 5F, this.tile.intValuePlay, IntFormatter.INSTANCE));
|
2019-05-02 09:10:29 +02:00
|
|
|
this.buttonList.add(new CustomSlider(this, 1, this.guiLeft, this.guiTop + 20, "Average Charge Amount", 1F, 4F, this.tile.chargeAmount, IntFormatter.INSTANCE));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 2, this.guiLeft, this.guiTop + 40, "Average Flight Time", 1F, 3F, this.tile.flightTime, IntFormatter.INSTANCE));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 3, this.guiLeft, this.guiTop + 60, "Effect Chance", 0F, 1F, this.tile.trailOrFlickerChance, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 4, this.guiLeft, this.guiTop + 80, "Flicker/Trail Ratio", 0F, 1F, this.tile.flickerChance, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 5, this.guiLeft, this.guiTop + 100, "Color Amount", 1, 6, this.tile.colorAmount, IntFormatter.INSTANCE));
|
|
|
|
|
|
|
|
this.buttonList.add(new CustomSlider(this, 6, this.guiLeft + 150, this.guiTop, "Small Ball", 0F, 1F, this.tile.typeChance0, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 7, this.guiLeft + 150, this.guiTop + 20, "Large Ball", 0F, 1F, this.tile.typeChance1, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 8, this.guiLeft + 150, this.guiTop + 40, "Star Shape", 0F, 1F, this.tile.typeChance2, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 9, this.guiLeft + 150, this.guiTop + 60, "Creeper Shape", 0F, 1F, this.tile.typeChance3, null));
|
|
|
|
this.buttonList.add(new CustomSlider(this, 10, this.guiLeft + 150, this.guiTop + 80, "Burst", 0F, 1F, this.tile.typeChance4, null));
|
|
|
|
|
|
|
|
this.buttonList.add(new CustomSlider(this, 11, this.guiLeft + 150, this.guiTop + 100, "Area of Effect", 0, 4, this.tile.areaOfEffect, IntFormatter.INSTANCE));
|
2016-12-29 21:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void setEntryValue(int id, float value) {
|
2016-12-29 21:29:00 +01:00
|
|
|
GuiButton button = this.buttonList.get(id);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (button instanceof GuiSlider) {
|
|
|
|
if (!((GuiSlider) button).isMouseDown) {
|
|
|
|
System.out.println("SETTING VALUE FOR " + id + "!!");
|
2016-12-29 21:29:00 +01:00
|
|
|
PacketHandlerHelper.sendNumberPacket(this.tile, value, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawGuiContainerForegroundLayer(int x, int y) {
|
2017-06-29 18:30:02 +02:00
|
|
|
AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile);
|
2016-12-29 21:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void setEntryValue(int id, boolean value) {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void setEntryValue(int id, String value) {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private static class CustomSlider extends GuiSlider {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
private final GuiResponder responder;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public CustomSlider(GuiResponder guiResponder, int idIn, int x, int y, String name, float min, float max, float defaultValue, FormatHelper formatter) {
|
2016-12-29 21:29:00 +01:00
|
|
|
super(guiResponder, idIn, x, y, name, min, max, defaultValue, formatter);
|
|
|
|
this.responder = guiResponder;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void mouseReleased(int mouseX, int mouseY) {
|
2016-12-29 21:29:00 +01:00
|
|
|
super.mouseReleased(mouseX, mouseY);
|
|
|
|
this.responder.setEntryValue(this.id, this.getSliderValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private static class IntFormatter implements GuiSlider.FormatHelper {
|
2016-12-29 21:29:00 +01:00
|
|
|
|
|
|
|
public static final IntFormatter INSTANCE = new IntFormatter();
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public String getText(int id, String name, float value) {
|
|
|
|
return name + ": " + (int) value;
|
2016-12-29 21:29:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|