update Implosion Compressor to GuiBase
This commit is contained in:
parent
aa2df32222
commit
e4b5d3378a
4 changed files with 116 additions and 59 deletions
|
@ -24,69 +24,119 @@
|
||||||
|
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.translation.I18n;
|
||||||
|
import reborncore.client.multiblock.Multiblock;
|
||||||
|
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||||
|
import reborncore.client.multiblock.MultiblockSet;
|
||||||
|
import reborncore.common.misc.Location;
|
||||||
|
import techreborn.Core;
|
||||||
|
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
|
import techreborn.proxies.ClientProxy;
|
||||||
import techreborn.tiles.multiblock.TileImplosionCompressor;
|
import techreborn.tiles.multiblock.TileImplosionCompressor;
|
||||||
|
|
||||||
public class GuiImplosionCompressor extends GuiContainer {
|
import java.io.IOException;
|
||||||
|
|
||||||
public static final ResourceLocation texture = new ResourceLocation("techreborn",
|
public class GuiImplosionCompressor extends GuiBase {
|
||||||
"textures/gui/implosion_compressor.png");
|
|
||||||
|
|
||||||
TileImplosionCompressor compressor;
|
TileImplosionCompressor tile;
|
||||||
|
|
||||||
public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor compressor) {
|
public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor tile) {
|
||||||
super(compressor.createContainer(player));
|
super(player, tile, tile.createContainer(player));
|
||||||
this.xSize = 176;
|
this.tile = tile;
|
||||||
this.ySize = 167;
|
|
||||||
this.compressor = compressor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture);
|
final GuiBase.Layer layer = Layer.BACKGROUND;
|
||||||
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);
|
|
||||||
|
|
||||||
if (!this.compressor.getMutliBlock()) {
|
drawSlot(50, 27, layer);
|
||||||
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
|
drawSlot(50,47,layer);
|
||||||
this.fontRenderer.drawString(I18n.format("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
|
drawSlot(92,36,layer);
|
||||||
|
drawSlot(110,36,layer);
|
||||||
|
|
||||||
|
if(tile.getMutliBlock()) {
|
||||||
|
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture);
|
this.builder.drawJEIButton(this, 150, 4, layer);
|
||||||
int j = this.compressor.getProgressScaled(24);
|
|
||||||
if (j > 0) {
|
|
||||||
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
j = this.compressor.getEnergyScaled(12);
|
|
||||||
if (j > 0) {
|
|
||||||
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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:implosion_compressor.name");
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, 4210752);
|
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||||
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
|
||||||
|
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
|
||||||
|
this.builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
|
if(tile.getMutliBlock()){
|
||||||
|
addHologramButton(6, 4, 212, layer);
|
||||||
|
} else {
|
||||||
|
builder.drawMultiblockMissingBar(this, layer);
|
||||||
|
addHologramButton(76, 56, 212, layer);
|
||||||
|
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addHologramButton(int x, int y, int id, Layer layer) {
|
||||||
|
if (id == 0)
|
||||||
|
buttonList.clear();
|
||||||
|
int factorX = 0;
|
||||||
|
int factorY = 0;
|
||||||
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
factorX = guiLeft;
|
||||||
|
factorY = guiTop;
|
||||||
|
}
|
||||||
|
buttonList.add(new GuiButtonHologram(id, x + factorX, y + factorY, this, layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void actionPerformed(final GuiButton button) throws IOException {
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.actionPerformed(button);
|
||||||
this.renderHoveredToolTip(mouseX, mouseY);
|
if (button.id == 212) {
|
||||||
|
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||||
|
{
|
||||||
|
// This code here makes a basic multiblock and then sets to the selected one.
|
||||||
|
final Multiblock multiblock = new Multiblock();
|
||||||
|
for(int x = -1; x <= 1; x++) {
|
||||||
|
for(int y = -4; y <= -2; y++) {
|
||||||
|
for(int z = -1; z <= 1; z++) {
|
||||||
|
if(!((x == 0) && (y == -3) && (z == 0))) {
|
||||||
|
this.addComponent(x, y, z, ModBlocks.MACHINE_CASINGS.getStateFromMeta(1), multiblock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final MultiblockSet set = new MultiblockSet(multiblock);
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||||
|
ClientProxy.multiblockRenderEvent.parent = new Location(this.tile.getPos().getX(), this.tile.getPos().getY(), this.tile.getPos().getZ(), this.tile.getWorld());
|
||||||
|
MultiblockRenderEvent.anchor = new BlockPos(this.tile.getPos().getX(), this.tile.getPos().getY(), this.tile.getPos().getZ());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) {
|
||||||
|
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import mezz.jei.api.gui.*;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
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.GuiImplosionCompressor;
|
import techreborn.client.gui.GuiImplosionCompressor;
|
||||||
import techreborn.compat.jei.RecipeCategoryUids;
|
import techreborn.compat.jei.RecipeCategoryUids;
|
||||||
|
@ -38,18 +40,15 @@ import techreborn.lib.ModInfo;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class ImplosionCompressorRecipeCategory extends BlankRecipeCategory<ImplosionCompressorRecipeWrapper> {
|
public class ImplosionCompressorRecipeCategory extends BlankRecipeCategory<ImplosionCompressorRecipeWrapper> {
|
||||||
|
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png");
|
||||||
private static final int[] INPUT_SLOTS = { 0, 1 };
|
private static final int[] INPUT_SLOTS = { 0, 1 };
|
||||||
private static final int[] OUTPUT_SLOTS = { 2, 3 };
|
private static final int[] OUTPUT_SLOTS = { 2, 3 };
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private final IDrawable electricity;
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
public ImplosionCompressorRecipeCategory(IGuiHelper guiHelper) {
|
public ImplosionCompressorRecipeCategory(IGuiHelper guiHelper) {
|
||||||
background = guiHelper.createDrawable(GuiImplosionCompressor.texture, 16, 25, 116, 36);
|
background = guiHelper.createDrawable(texture, 0, 95, 120, 42);
|
||||||
IDrawableStatic electricityDrawable = guiHelper.createDrawable(GuiImplosionCompressor.texture, 176, 0, 14, 14);
|
|
||||||
electricity = guiHelper.createAnimatedDrawable(electricityDrawable, 300, IDrawableAnimated.StartDirection.TOP,
|
|
||||||
true);
|
|
||||||
title = I18n.translateToLocal("tile.techreborn:implosion_compressor.name");
|
title = I18n.translateToLocal("tile.techreborn:implosion_compressor.name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +75,6 @@ public class ImplosionCompressorRecipeCategory extends BlankRecipeCategory<Implo
|
||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawExtras(Minecraft minecraft) {
|
|
||||||
super.drawExtras(minecraft);
|
|
||||||
electricity.draw(minecraft, 0, 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(
|
public void setRecipe(
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -91,11 +84,11 @@ public class ImplosionCompressorRecipeCategory extends BlankRecipeCategory<Implo
|
||||||
@Nonnull
|
@Nonnull
|
||||||
IIngredients ingredients) {
|
IIngredients ingredients) {
|
||||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||||
guiItemStacks.init(INPUT_SLOTS[0], true, 20, 0);
|
guiItemStacks.init(INPUT_SLOTS[0], true, 21, 2);
|
||||||
guiItemStacks.init(INPUT_SLOTS[1], true, 20, 18);
|
guiItemStacks.init(INPUT_SLOTS[1], true, 21, 22);
|
||||||
|
|
||||||
guiItemStacks.init(OUTPUT_SLOTS[0], false, 76, 9);
|
guiItemStacks.init(OUTPUT_SLOTS[0], false, 63, 11);
|
||||||
guiItemStacks.init(OUTPUT_SLOTS[1], false, 94, 9);
|
guiItemStacks.init(OUTPUT_SLOTS[1], false, 81, 11);
|
||||||
|
|
||||||
RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
|
RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
|
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
|
||||||
import techreborn.client.gui.GuiImplosionCompressor;
|
import techreborn.client.gui.GuiImplosionCompressor;
|
||||||
|
import techreborn.client.gui.TRBuilder;
|
||||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -45,7 +46,7 @@ public class ImplosionCompressorRecipeWrapper extends BaseRecipeWrapper<Implosio
|
||||||
ImplosionCompressorRecipe baseRecipe) {
|
ImplosionCompressorRecipe baseRecipe) {
|
||||||
super(baseRecipe);
|
super(baseRecipe);
|
||||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||||
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiImplosionCompressor.texture, 176, 14, 21, 11);
|
IDrawableStatic progressStatic = guiHelper.createDrawable(TRBuilder.GUI_SHEET, 100, 151, 16, 10);
|
||||||
this.progress = guiHelper.createAnimatedDrawable(progressStatic, baseRecipe.tickTime(),
|
this.progress = guiHelper.createAnimatedDrawable(progressStatic, baseRecipe.tickTime(),
|
||||||
IDrawableAnimated.StartDirection.LEFT, false);
|
IDrawableAnimated.StartDirection.LEFT, false);
|
||||||
}
|
}
|
||||||
|
@ -53,10 +54,10 @@ public class ImplosionCompressorRecipeWrapper extends BaseRecipeWrapper<Implosio
|
||||||
@Override
|
@Override
|
||||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||||
progress.draw(minecraft, 44, 13);
|
progress.draw(minecraft, 43, 16);
|
||||||
|
|
||||||
int x = -45;
|
int x = -35;
|
||||||
int y = 4;
|
int y = 13;
|
||||||
int lineHeight = minecraft.fontRenderer.FONT_HEIGHT;
|
int lineHeight = minecraft.fontRenderer.FONT_HEIGHT;
|
||||||
|
|
||||||
minecraft.fontRenderer.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444);
|
minecraft.fontRenderer.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444);
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
package techreborn.tiles.multiblock;
|
package techreborn.tiles.multiblock;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -40,10 +42,12 @@ import techreborn.client.container.IContainerProvider;
|
||||||
import techreborn.client.container.builder.BuiltContainer;
|
import techreborn.client.container.builder.BuiltContainer;
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
import techreborn.tiles.TileRollingMachine;
|
||||||
|
|
||||||
public class TileImplosionCompressor extends TilePowerAcceptor
|
public class TileImplosionCompressor extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||||
|
|
||||||
|
public final InventoryCrafting craftMatrix = new InventoryCrafting(new ImplosionCompressorTileContainer(), 3, 3);
|
||||||
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
||||||
public MultiblockChecker multiblockChecker;
|
public MultiblockChecker multiblockChecker;
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
|
@ -153,9 +157,18 @@ public class TileImplosionCompressor extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("implosioncompressor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
|
return new ContainerBuilder("implosioncompressor").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().tile(this).slot(0, 37, 26).slot(1, 37, 44).outputSlot(2, 93, 35).outputSlot(3, 111, 35)
|
.addInventory().tile(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36)
|
||||||
.syncEnergyValue().syncCrafterValue().addInventory().create();
|
.syncEnergyValue().syncCrafterValue().addInventory().create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ImplosionCompressorTileContainer extends Container {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(final EntityPlayer entityplayer) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue