Added multiblock hologram to Vacuum Freezer. Closes #1297
This commit is contained in:
parent
610c2e479e
commit
ae27bf7b9f
1 changed files with 76 additions and 1 deletions
|
@ -24,7 +24,19 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileVacuumFreezer;
|
||||
|
||||
public class GuiVacuumFreezer extends GuiBase {
|
||||
|
@ -36,14 +48,23 @@ public class GuiVacuumFreezer extends GuiBase {
|
|||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
|
||||
// Battery slot
|
||||
this.drawSlot(8, 72, layer);
|
||||
// Input slots
|
||||
this.drawSlot(8, 72, layer);
|
||||
|
||||
this.drawSlot(55, 45, layer);
|
||||
// Output slot
|
||||
this.drawOutputSlot(101, 45, layer);
|
||||
|
||||
this.builder.drawJEIButton(this, 150, 4, layer);
|
||||
|
@ -56,6 +77,60 @@ public class GuiVacuumFreezer extends GuiBase {
|
|||
|
||||
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 76, 48, 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.getMultiBlock()) {
|
||||
addHologramButton(6, 4, 212, layer);
|
||||
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, 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
|
||||
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();
|
||||
IBlockState reinforcedCasing = ModBlocks.MACHINE_CASINGS.getDefaultState().withProperty(BlockMachineCasing.TYPE, "reinforced");
|
||||
|
||||
this.addComponent(0, -1, 0, reinforcedCasing, multiblock);
|
||||
this.addComponent(1, -1, 0, reinforcedCasing, multiblock);
|
||||
this.addComponent(0, -1, 1, reinforcedCasing, multiblock);
|
||||
this.addComponent(-1, -1, 0, reinforcedCasing, multiblock);
|
||||
this.addComponent(0, -1, -1, reinforcedCasing, multiblock);
|
||||
this.addComponent(-1, -1, -1, reinforcedCasing, multiblock);
|
||||
this.addComponent(-1, -1, 1, reinforcedCasing, multiblock);
|
||||
this.addComponent(1, -1, -1, reinforcedCasing, multiblock);
|
||||
this.addComponent(1, -1, 1, reinforcedCasing, multiblock);
|
||||
|
||||
final MultiblockSet set = new MultiblockSet(multiblock);
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||
ClientProxy.multiblockRenderEvent.parent = this.tile.getPos();
|
||||
MultiblockRenderEvent.anchor = this.tile.getPos().down();
|
||||
}
|
||||
} 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
Reference in a new issue