Updated reactor GUI. Closes #1422

This commit is contained in:
drcrazy 2018-01-29 18:17:32 +03:00
parent 2e115242a2
commit a6df9441ec
5 changed files with 325 additions and 300 deletions

View file

@ -42,6 +42,7 @@ public class ClientMultiBlocks {
checkMachine();
}
@Deprecated
public static void checkCoils() {
if ((isCoil(3, 0, 1)) && (isCoil(3, 0, 0)) && (isCoil(3, 0, 0 - 1)) && (isCoil(0 - 3, 0, 1))
&& (isCoil(0 - 3, 0, 0)) && (isCoil(0 - 3, 0, 0 - 1)) && (isCoil(2, 0, 2)) && (isCoil(2, 0, 1))
@ -52,6 +53,7 @@ public class ClientMultiBlocks {
}
}
@Deprecated
private static boolean isCoil(int x, int y, int z) {
reactor.addComponent(new BlockPos(x, y, z), ModBlocks.FUSION_COIL.getDefaultState());
return true;

View file

@ -24,123 +24,116 @@
package techreborn.client.gui;
import java.io.IOException;
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.util.math.BlockPos;
import net.minecraft.client.resources.I18n;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
import reborncore.client.multiblock.MultiblockSet;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.client.ClientMultiBlocks;
import techreborn.client.gui.widget.GuiButtonHologram;
import techreborn.init.ModBlocks;
import techreborn.proxies.ClientProxy;
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
import java.io.IOException;
public class GuiFusionReactor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/fusion_reactor.png");
public class GuiFusionReactor extends GuiBase {
TileFusionControlComputer tile;
public GuiFusionReactor(final EntityPlayer player, final TileFusionControlComputer fusion) {
super(fusion.createContainer(player));
this.tile = fusion;
public GuiFusionReactor(final EntityPlayer player, final TileFusionControlComputer tile) {
super(player, tile, tile.createContainer(player));
this.tile = tile;
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.format("tile.techreborn:fusion_control_computer.name");
this.fontRenderer.drawString(name, 87, 6, 4210752);
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
this.fontRenderer.drawString(PowerSystem.getLocaliszedPower(this.tile.getEnergy()), 11, 8,
16448255);
this.fontRenderer.drawString("Coils: " + (this.tile.getCoilStatus() == 1 ? "Yes" : "No"), 11, 16,
16448255);
if (this.tile.getNeededPower() > 1 && this.tile.getCrafingTickTime() < 1)
this.fontRenderer.drawString("Start: "
+ this.percentage(this.tile.getNeededPower(), (int) this.tile.getEnergy())
+ "%", 11, 24, 16448255);
this.drawSlot(34, 47, layer);
this.drawSlot(126, 47, layer);
this.drawOutputSlot(80, 47, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@Override
public void initGui() {
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
final GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, "");
this.buttonList.add(button);
super.initGui();
final BlockPos coordinates = new BlockPos(
this.tile.getPos().getX()
- EnumFacing.getFront(this.tile.getFacingInt()).getFrontOffsetX() * 2,
this.tile.getPos().getY() - 1, this.tile.getPos().getZ()
- EnumFacing.getFront(this.tile.getFacingInt()).getFrontOffsetZ() * 2);
if (coordinates.equals(MultiblockRenderEvent.anchor)) {
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawProgressBar(this, this.tile.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, TRBuilder.ProgressDirection.LEFT, layer);
this.builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
if (tile.checkCoils()) {
addHologramButton(6, 4, 212, layer);
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
} else {
button.displayString = "A";
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_,
final int p_146976_3_) {
this.drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiFusionReactor.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);
this.drawTexturedModalRect(k + 88, l + 36, 176, 0, 14, 14);
// progressBar
this.drawTexturedModalRect(k + 111, l + 34, 176, 14, this.tile.getProgressScaled(), 16);
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));
}
public int percentage(final int MaxValue, final int CurrentValue) {
if (CurrentValue == 0)
return 0;
return (int) (CurrentValue * 100.0f / MaxValue);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
if (button.id == 212) {
if (button.id == 212 && !GuiBase.showSlotConfig) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
// This code here makes a basic multiblock and then sets to
// theselected one.
final MultiblockSet set = new MultiblockSet(ClientMultiBlocks.reactor);
// This code here makes a basic multiblock and then sets to the selected one.
final Multiblock multiblock = new Multiblock();
IBlockState coil = ModBlocks.FUSION_COIL.getDefaultState();
this.addComponent(3, 0, 1, coil, multiblock);
this.addComponent(3, 0, 0, coil, multiblock);
this.addComponent(3, 0, -1, coil, multiblock);
this.addComponent(-3, 0, 1, coil, multiblock);
this.addComponent(-3, 0, 0, coil, multiblock);
this.addComponent(-3, 0, -1, coil, multiblock);
this.addComponent(2, 0, 2, coil, multiblock);
this.addComponent(2, 0, 1, coil, multiblock);
this.addComponent(2, 0, -1, coil, multiblock);
this.addComponent(2, 0, -2, coil, multiblock);
this.addComponent(-2, 0, 2, coil, multiblock);
this.addComponent(-2, 0, 1, coil, multiblock);
this.addComponent(-2, 0, -1, coil, multiblock);
this.addComponent(-2, 0, -2, coil, multiblock);
this.addComponent(1, 0, 3, coil, multiblock);
this.addComponent(1, 0, 2, coil, multiblock);
this.addComponent(1, 0, -2, coil, multiblock);
this.addComponent(1, 0, -3, coil, multiblock);
this.addComponent(-1, 0, 3, coil, multiblock);
this.addComponent(-1, 0, 2, coil, multiblock);
this.addComponent(-1, 0, -2, coil, multiblock);
this.addComponent(-1, 0, -3, coil, multiblock);
this.addComponent(0, 0, 3, coil, multiblock);
this.addComponent(0, 0, -3, coil, multiblock);
final MultiblockSet set = new MultiblockSet(multiblock);
ClientProxy.multiblockRenderEvent.setMultiblock(set);
ClientProxy.multiblockRenderEvent.parent = this.tile.getPos();
// new Location(this.fusionController.getPos().getX(),
// this.fusionController.getPos().getY(), this.fusionController.getPos().getZ(),
// this.fusionController.getWorld());
MultiblockRenderEvent.anchor = new BlockPos(this.tile.getPos().getX(),
this.tile.getPos().getY() - 1, this.tile.getPos().getZ());
button.displayString = "A";
MultiblockRenderEvent.anchor = new BlockPos(this.tile.getPos().getX(), this.tile.getPos().getY() - 1,
this.tile.getPos().getZ());
} else {
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
}
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
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);
}
}