Update rolling machine to use new gui system. Work towards #1412
This commit is contained in:
parent
6e1b608113
commit
b5ad12a4bb
4 changed files with 47 additions and 56 deletions
|
@ -24,67 +24,40 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import techreborn.tiles.TileRollingMachine;
|
import techreborn.tiles.TileRollingMachine;
|
||||||
|
|
||||||
public class GuiRollingMachine extends GuiContainer {
|
public class GuiRollingMachine extends GuiBase {
|
||||||
|
|
||||||
public static final ResourceLocation texture = new ResourceLocation("techreborn",
|
|
||||||
"textures/gui/rolling_machine.png");
|
|
||||||
TileRollingMachine rollingMachine;
|
TileRollingMachine rollingMachine;
|
||||||
|
|
||||||
public GuiRollingMachine(final EntityPlayer player, final TileRollingMachine tileRollingmachine) {
|
public GuiRollingMachine(final EntityPlayer player, final TileRollingMachine tileRollingmachine) {
|
||||||
super(tileRollingmachine.createContainer(player));
|
super(player, tileRollingmachine, tileRollingmachine.createContainer(player));
|
||||||
this.xSize = 176;
|
|
||||||
this.ySize = 167;
|
|
||||||
this.rollingMachine = tileRollingmachine;
|
this.rollingMachine = tileRollingmachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||||
this.drawDefaultBackground();
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||||
this.mc.getTextureManager().bindTexture(GuiRollingMachine.texture);
|
|
||||||
final int k = (this.width - this.xSize) / 2;
|
|
||||||
final int l = (this.height - this.ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
|
||||||
|
|
||||||
int j = this.rollingMachine.getBurnTimeRemainingScaled(24);
|
int gridYPos = 22;
|
||||||
this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19);
|
this.drawSlot(30, gridYPos, layer); this.drawSlot(48, gridYPos, layer); this.drawSlot(66, gridYPos, layer);
|
||||||
|
this.drawSlot(30, gridYPos + 18, layer); this.drawSlot(48, gridYPos + 18, layer); this.drawSlot(66, gridYPos + 18, layer);
|
||||||
|
this.drawSlot(30, gridYPos + 36, layer); this.drawSlot(48, gridYPos + 36, layer); this.drawSlot(66, gridYPos + 36, layer);
|
||||||
|
|
||||||
j = this.rollingMachine.getEnergyScaled(12);
|
this.drawSlot(8, 70, layer);
|
||||||
if (j > 0) {
|
this.drawOutputSlot(124, gridYPos + 18, layer);
|
||||||
this.drawTexturedModalRect(k + 7, l + 33 + 12 - j, 176, 12 - j, 14, j + 2);
|
|
||||||
}
|
this.builder.drawJEIButton(this, 150, 4, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||||
final String name = I18n.format("tile.techreborn:rolling_machine.name");
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6,
|
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||||
4210752);
|
|
||||||
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8,
|
|
||||||
this.ySize - 96 + 2, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.builder.drawProgressBar(this, this.rollingMachine.getProgressScaled(100), 100, 92, 43, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||||
public void initGui() {
|
this.builder.drawMultiEnergyBar(this, 9, 17, (int) this.rollingMachine.getEnergy(), (int) this.rollingMachine.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
this.buttonList.clear();
|
|
||||||
final int k = (this.width - this.xSize) / 2;
|
|
||||||
final int l = (this.height - this.ySize) / 2;
|
|
||||||
this.buttonList.add(new GuiButton(0, k + 4, l + 4, 20, 20, "R"));
|
|
||||||
super.initGui();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
this.renderHoveredToolTip(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,12 +316,12 @@ public class TechRebornJeiPlugin implements IModPlugin {
|
||||||
addRecipeClickArea(GuiDistillationTower.class, 150, 4, 18, 18, RecipeCategoryUids.DISTILLATION_TOWER);
|
addRecipeClickArea(GuiDistillationTower.class, 150, 4, 18, 18, RecipeCategoryUids.DISTILLATION_TOWER);
|
||||||
addRecipeClickArea(GuiScrapboxinator.class, 150, 4, 18, 18, RecipeCategoryUids.SCRAPBOX);
|
addRecipeClickArea(GuiScrapboxinator.class, 150, 4, 18, 18, RecipeCategoryUids.SCRAPBOX);
|
||||||
addRecipeClickArea(GuiFusionReactor.class, 150, 4, 18, 18, RecipeCategoryUids.FUSION_REACTOR);
|
addRecipeClickArea(GuiFusionReactor.class, 150, 4, 18, 18, RecipeCategoryUids.FUSION_REACTOR);
|
||||||
|
addRecipeClickArea(GuiRollingMachine.class, 150, 4, 20, 12, RecipeCategoryUids.ROLLING_MACHINE);
|
||||||
|
|
||||||
//OLD ONES
|
//OLD ONES
|
||||||
addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
|
addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
|
||||||
VanillaRecipeCategoryUid.FUEL);
|
VanillaRecipeCategoryUid.FUEL);
|
||||||
addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||||
addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
|
|
||||||
addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
|
addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
|
||||||
VanillaRecipeCategoryUid.FUEL);
|
VanillaRecipeCategoryUid.FUEL);
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.IRecipeCategory;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import techreborn.client.gui.GuiRollingMachine;
|
|
||||||
import techreborn.compat.jei.RecipeCategoryUids;
|
import techreborn.compat.jei.RecipeCategoryUids;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
|
@ -47,11 +47,13 @@ public class RollingMachineRecipeCategory implements IRecipeCategory<RollingMach
|
||||||
private final ICraftingGridHelper craftingGridHelper;
|
private final ICraftingGridHelper craftingGridHelper;
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
|
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/rolling_machine.png");
|
||||||
|
|
||||||
public RollingMachineRecipeCategory(IGuiHelper guiHelper) {
|
public RollingMachineRecipeCategory(IGuiHelper guiHelper) {
|
||||||
background = guiHelper.createDrawable(GuiRollingMachine.texture, 29, 16, 116, 54);
|
background = guiHelper.createDrawable(texture, 29, 16, 116, 54);
|
||||||
title = I18n.translateToLocal("tile.techreborn:rolling_machine.name");
|
title = I18n.translateToLocal("tile.techreborn:rolling_machine.name");
|
||||||
|
|
||||||
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiRollingMachine.texture, 176, 14, 20, 18);
|
IDrawableStatic progressStatic = guiHelper.createDrawable(texture, 176, 14, 20, 18);
|
||||||
progress = guiHelper.createAnimatedDrawable(progressStatic, 250, IDrawableAnimated.StartDirection.LEFT, false);
|
progress = guiHelper.createAnimatedDrawable(progressStatic, 250, IDrawableAnimated.StartDirection.LEFT, false);
|
||||||
|
|
||||||
craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOTS[0], OUTPUT_SLOTS[0]);
|
craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOTS[0], OUTPUT_SLOTS[0]);
|
||||||
|
|
|
@ -224,13 +224,24 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("rollingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
|
return new ContainerBuilder("rollingmachine").player(player.inventory)
|
||||||
.addInventory().tile(this.craftMatrix).slot(0, 30, 17).slot(1, 48, 17).slot(2, 66, 17).slot(3, 30, 35)
|
.inventory().hotbar()
|
||||||
.slot(4, 48, 35).slot(5, 66, 35).slot(6, 30, 53).slot(7, 48, 53).slot(8, 66, 53)
|
.addInventory().tile(this.craftMatrix)
|
||||||
.onCraft(inv -> this.inventory.setInventorySlotContents(1,
|
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
||||||
RollingMachineRecipe.instance.findMatchingRecipe(inv, this.world)))
|
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||||
.addInventory().tile(this).outputSlot(0, 124, 35).energySlot(2, 8, 51).syncEnergyValue()
|
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
||||||
.syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this);
|
.onCraft(inv -> this.inventory.setInventorySlotContents(1, RollingMachineRecipe.instance.findMatchingRecipe(inv, this.world)))
|
||||||
|
.addInventory().tile(this)
|
||||||
|
.outputSlot(0, 124, 40)
|
||||||
|
.energySlot(2, 8, 70)
|
||||||
|
.syncEnergyValue().syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProgressScaled(final int scale) {
|
||||||
|
if (tickTime != 0 && runTime != 0) {
|
||||||
|
return tickTime * scale / runTime;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RollingTileContainer extends Container {
|
private static class RollingTileContainer extends Container {
|
||||||
|
@ -241,4 +252,9 @@ public class TileRollingMachine extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeUpgraded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue