mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Add a background to the Firework Box GUI and re-position the sliders
This commit is contained in:
parent
f524eccc01
commit
5c13128acf
2 changed files with 20 additions and 16 deletions
|
@ -20,6 +20,7 @@ import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
@ -31,13 +32,15 @@ import java.text.NumberFormat;
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox> {
|
public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox> {
|
||||||
|
|
||||||
|
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_firework_box");
|
||||||
|
|
||||||
protected final TileEntityFireworkBox tile;
|
protected final TileEntityFireworkBox tile;
|
||||||
|
|
||||||
public GuiFireworkBox(ContainerFireworkBox screenContainer, Inventory inv, Component titleIn) {
|
public GuiFireworkBox(ContainerFireworkBox screenContainer, Inventory inv, Component titleIn) {
|
||||||
super(screenContainer, inv, titleIn);
|
super(screenContainer, inv, titleIn);
|
||||||
this.tile = screenContainer.fireworkbox;
|
this.tile = screenContainer.fireworkbox;
|
||||||
this.imageWidth = 300;
|
this.imageWidth = 302;
|
||||||
this.imageHeight = 120;
|
this.imageHeight = 130;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,20 +48,21 @@ public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
DecimalFormat intFormatter = new DecimalFormat("0");
|
DecimalFormat intFormatter = new DecimalFormat("0");
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop(), Component.literal("Value Play"), 0F, 5F, this.tile.intValuePlay, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 0)));
|
int left = this.getGuiLeft() + 2;
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop() + 20, Component.literal("Average Charge Amount"), 1F, 4F, this.tile.chargeAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 1)));
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 2, Component.literal("Value Play"), 0F, 5F, this.tile.intValuePlay, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 0)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop() + 40, Component.literal("Average Flight Time"), 1F, 3F, this.tile.flightTime, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 2)));
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 23, Component.literal("Average Charge Amount"), 1F, 4F, this.tile.chargeAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 1)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop() + 60, Component.literal("Effect Chance"), 0F, 1F, this.tile.trailOrFlickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 3)));
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 44, Component.literal("Average Flight Time"), 1F, 3F, this.tile.flightTime, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 2)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop() + 80, Component.literal("Flicker/Trail Ratio"), 0F, 1F, this.tile.flickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 4)));
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 65, Component.literal("Effect Chance"), 0F, 1F, this.tile.trailOrFlickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 3)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft(), this.getGuiTop() + 100, Component.literal("Color Amount"), 1, 6, this.tile.colorAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 5)));
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 86, Component.literal("Flicker/Trail Ratio"), 0F, 1F, this.tile.flickerChance, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 4)));
|
||||||
|
this.addRenderableWidget(new CustomSlider(left, this.getGuiTop() + 107, Component.literal("Color Amount"), 1, 6, this.tile.colorAmount, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 5)));
|
||||||
|
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop(), Component.literal("Small Ball"), 0F, 1F, this.tile.typeChance0, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 6)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 2, Component.literal("Small Ball"), 0F, 1F, this.tile.typeChance0, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 6)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop() + 20, Component.literal("Large Ball"), 0F, 1F, this.tile.typeChance1, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 7)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 23, Component.literal("Large Ball"), 0F, 1F, this.tile.typeChance1, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 7)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop() + 40, Component.literal("Star Shape"), 0F, 1F, this.tile.typeChance2, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 8)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 44, Component.literal("Star Shape"), 0F, 1F, this.tile.typeChance2, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 8)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop() + 60, Component.literal("Creeper Shape"), 0F, 1F, this.tile.typeChance3, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 9)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 65, Component.literal("Creeper Shape"), 0F, 1F, this.tile.typeChance3, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 9)));
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop() + 80, Component.literal("Burst"), 0F, 1F, this.tile.typeChance4, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 10)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 86, Component.literal("Burst"), 0F, 1F, this.tile.typeChance4, null, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 10)));
|
||||||
|
|
||||||
this.addRenderableWidget(new CustomSlider(this.getGuiLeft() + 150, this.getGuiTop() + 100, Component.literal("Area of Effect"), 0, 4, this.tile.areaOfEffect, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 11)));
|
this.addRenderableWidget(new CustomSlider(left + 150, this.getGuiTop() + 107, Component.literal("Area of Effect"), 0, 4, this.tile.areaOfEffect, intFormatter, (slider) -> PacketHandlerHelper.sendNumberPacket(this.tile, slider.getValue(), 11)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,7 +72,7 @@ public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int x, int y) {
|
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int x, int y) {
|
||||||
|
guiGraphics.blit(RES_LOC, this.leftPos, this.topPos, 0, 0, this.getXSize(), this.getYSize(), 512, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +92,7 @@ public class GuiFireworkBox extends AbstractContainerScreen<ContainerFireworkBox
|
||||||
protected final CustomSlider.OnApply onApply;
|
protected final CustomSlider.OnApply onApply;
|
||||||
private final double stepSize = 0;
|
private final double stepSize = 0;
|
||||||
public CustomSlider(int x, int y, Component message, double min, double max, double defaultValue, DecimalFormat format, CustomSlider.OnApply onApply) {
|
public CustomSlider(int x, int y, Component message, double min, double max, double defaultValue, DecimalFormat format, CustomSlider.OnApply onApply) {
|
||||||
super(x, y, 150, 20, message, defaultValue);
|
super(x, y, 148, 20, message, defaultValue);
|
||||||
this.sliderName = message;
|
this.sliderName = message;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in a new issue