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;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
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;
|
||||
|
||||
public class GuiImplosionCompressor extends GuiContainer {
|
||||
import java.io.IOException;
|
||||
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn",
|
||||
"textures/gui/implosion_compressor.png");
|
||||
public class GuiImplosionCompressor extends GuiBase {
|
||||
|
||||
TileImplosionCompressor compressor;
|
||||
TileImplosionCompressor tile;
|
||||
|
||||
public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor compressor) {
|
||||
super(compressor.createContainer(player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.compressor = compressor;
|
||||
public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor tile) {
|
||||
super(player, tile, tile.createContainer(player));
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
this.drawDefaultBackground();
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.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);
|
||||
final GuiBase.Layer layer = Layer.BACKGROUND;
|
||||
|
||||
if (!this.compressor.getMutliBlock()) {
|
||||
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
|
||||
this.fontRenderer.drawString(I18n.format("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
|
||||
}
|
||||
drawSlot(50, 27, layer);
|
||||
drawSlot(50,47,layer);
|
||||
drawSlot(92,36,layer);
|
||||
drawSlot(110,36,layer);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture);
|
||||
int j = this.compressor.getProgressScaled(24);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
|
||||
}
|
||||
if(tile.getMutliBlock()) {
|
||||
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
|
||||
j = this.compressor.getEnergyScaled(12);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||
}
|
||||
this.builder.drawJEIButton(this, 150, 4, layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
||||
final String name = I18n.format("tile.techreborn:implosion_compressor.name");
|
||||
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
||||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
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
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue