Deduplicate multiblock verification from BlockEntities and Guis (#2133)
* Deduplicate multiblock verification from BlockEntities and Guis * Update REI * Remove unneeded calls
This commit is contained in:
parent
c89d6941ae
commit
4b2042a100
25 changed files with 275 additions and 939 deletions
|
@ -25,22 +25,17 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
public IndustrialBlastFurnaceBlockEntity blockEntity;
|
||||
private final IndustrialBlastFurnaceBlockEntity blockEntity;
|
||||
boolean hasMultiBlock;
|
||||
|
||||
public GuiBlastFurnace(int syncID, final PlayerEntity player, final IndustrialBlastFurnaceBlockEntity blockEntity) {
|
||||
|
@ -61,9 +56,9 @@ public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
|||
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
final GuiBase.Layer layer = Layer.BACKGROUND;
|
||||
|
||||
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
|
||||
|
||||
drawSlot(matrixStack, 50, 27, layer);
|
||||
drawSlot(matrixStack, 50, 47, layer);
|
||||
drawOutputSlotBar(matrixStack, 92, 36, 2, layer);
|
||||
|
@ -93,62 +88,7 @@ public class GuiBlastFurnace extends GuiBase<BuiltScreenHandler> {
|
|||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
|
||||
this.addComponent(0, 0, 0, standardCasing, multiblock);
|
||||
this.addComponent(1, 0, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 0, 1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 0, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 0, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 0, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 0, 1, standardCasing, multiblock);
|
||||
this.addComponent(1, 0, -1, standardCasing, multiblock);
|
||||
this.addComponent(1, 0, 1, standardCasing, multiblock);
|
||||
|
||||
this.addComponent(1, 1, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 1, 1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 1, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 1, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 1, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 1, 1, standardCasing, multiblock);
|
||||
this.addComponent(1, 1, -1, standardCasing, multiblock);
|
||||
this.addComponent(1, 1, 1, standardCasing, multiblock);
|
||||
|
||||
this.addComponent(1, 2, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 2, 1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 2, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 2, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 2, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 2, 1, standardCasing, multiblock);
|
||||
this.addComponent(1, 2, -1, standardCasing, multiblock);
|
||||
this.addComponent(1, 2, 1, standardCasing, multiblock);
|
||||
|
||||
this.addComponent(0, 3, 0, standardCasing, multiblock);
|
||||
this.addComponent(1, 3, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 3, 1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 3, 0, standardCasing, multiblock);
|
||||
this.addComponent(0, 3, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 3, -1, standardCasing, multiblock);
|
||||
this.addComponent(-1, 3, 1, standardCasing, multiblock);
|
||||
this.addComponent(1, 3, -1, standardCasing, multiblock);
|
||||
this.addComponent(1, 3, 1, standardCasing, multiblock);
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x - Direction.byId(blockEntity.getFacingInt()).getOffsetX() * 2,
|
||||
y,
|
||||
z - Direction.byId(blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,22 +25,17 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
public DistillationTowerBlockEntity blockEntity;
|
||||
|
||||
private final DistillationTowerBlockEntity blockEntity;
|
||||
|
||||
public GuiDistillationTower(int syncID, final PlayerEntity player, final DistillationTowerBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
|
@ -70,7 +65,7 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
|||
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
} else {
|
||||
|
@ -83,61 +78,6 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
|
|||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
|
||||
addComponent(0, 0, 0, standardCasing, multiblock);
|
||||
addComponent(1, 0, 0, standardCasing, multiblock);
|
||||
addComponent(0, 0, 1, standardCasing, multiblock);
|
||||
addComponent(-1, 0, 0, standardCasing, multiblock);
|
||||
addComponent(0, 0, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 0, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 0, 1, standardCasing, multiblock);
|
||||
addComponent(1, 0, -1, standardCasing, multiblock);
|
||||
addComponent(1, 0, 1, standardCasing, multiblock);
|
||||
|
||||
addComponent(1, 1, 0, industrialCasing, multiblock);
|
||||
addComponent(0, 1, 1, industrialCasing, multiblock);
|
||||
addComponent(-1, 1, 0, industrialCasing, multiblock);
|
||||
addComponent(0, 1, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, 1, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, 1, 1, industrialCasing, multiblock);
|
||||
addComponent(1, 1, -1, industrialCasing, multiblock);
|
||||
addComponent(1, 1, 1, industrialCasing, multiblock);
|
||||
|
||||
addComponent(1, 2, 0, standardCasing, multiblock);
|
||||
addComponent(0, 2, 1, standardCasing, multiblock);
|
||||
addComponent(-1, 2, 0, standardCasing, multiblock);
|
||||
addComponent(0, 2, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 2, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 2, 1, standardCasing, multiblock);
|
||||
addComponent(1, 2, -1, standardCasing, multiblock);
|
||||
addComponent(1, 2, 1, standardCasing, multiblock);
|
||||
|
||||
addComponent(0, 3, 0, industrialCasing, multiblock);
|
||||
addComponent(1, 3, 0, industrialCasing, multiblock);
|
||||
addComponent(0, 3, 1, industrialCasing, multiblock);
|
||||
addComponent(-1, 3, 0, industrialCasing, multiblock);
|
||||
addComponent(0, 3, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, 3, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, 3, 1, industrialCasing, multiblock);
|
||||
addComponent(1, 3, -1, industrialCasing, multiblock);
|
||||
addComponent(1, 3, 1, industrialCasing, multiblock);
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x - Direction.byId(blockEntity.getFacingInt()).getOffsetX() * 2, y, z - Direction.byId(blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,26 +24,20 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
FluidReplicatorBlockEntity blockEntity;
|
||||
private final FluidReplicatorBlockEntity blockEntity;
|
||||
|
||||
public GuiFluidReplicator(int syncID, final PlayerEntity player, final FluidReplicatorBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
|
@ -64,7 +58,7 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
|||
drawSlot(matrixStack, 124, 55, layer);
|
||||
// JEI button
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +70,7 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
|||
|
||||
builder.drawTank(matrixStack, this, 99, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||
|
@ -87,35 +81,7 @@ public class GuiFluidReplicator extends GuiBase<BuiltScreenHandler> {
|
|||
}
|
||||
|
||||
// GuiScreen
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
final BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
|
||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(
|
||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 2,
|
||||
y,
|
||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 2), blockState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,39 +24,35 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.Color;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.packets.ServerboundPackets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
||||
FusionControlComputerBlockEntity blockEntity;
|
||||
|
||||
private final FusionControlComputerBlockEntity blockEntity;
|
||||
|
||||
public GuiFusionReactor(int syncID, final PlayerEntity player, final FusionControlComputerBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
@ -76,7 +72,7 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
|||
drawOutputSlot(matrixStack, 80, 47, layer);
|
||||
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
if (blockEntity.getCoilStatus() > 0) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
|
||||
|
@ -89,10 +85,10 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
|||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.LEFT, layer);
|
||||
if (blockEntity.getCoilStatus() > 0) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::hologramToggle);
|
||||
drawCentredText(matrixStack, blockEntity.getStateText(), 20, Color.BLUE.darker().getColor(), layer);
|
||||
if(blockEntity.state == 2){
|
||||
if (blockEntity.state == 2) {
|
||||
drawCentredText(matrixStack, new LiteralText(PowerSystem.getLocaliszedPowerFormatted((int) blockEntity.getPowerChange())).append("/t"), 30, Color.GREEN.darker().getColor(), layer);
|
||||
}
|
||||
} else {
|
||||
|
@ -101,60 +97,37 @@ public class GuiFusionReactor extends GuiBase<BuiltScreenHandler> {
|
|||
builder.drawHologramButton(matrixStack, this, 76, 56, mouseX, mouseY, layer);
|
||||
|
||||
Optional<Pair<Integer, Integer>> stackSize = getCoilStackCount();
|
||||
if(stackSize.isPresent()){
|
||||
if(stackSize.get().getLeft() > 0){
|
||||
if (stackSize.isPresent()) {
|
||||
if (stackSize.get().getLeft() > 0) {
|
||||
|
||||
drawCentredText(matrixStack,
|
||||
new LiteralText("Required Coils: ")
|
||||
.append(String.valueOf(stackSize.get().getLeft()))
|
||||
.append("x64 +")
|
||||
.append(String.valueOf(stackSize.get().getRight()))
|
||||
, 25, 0xFFFFFF, layer);
|
||||
.append(String.valueOf(stackSize.get().getLeft()))
|
||||
.append("x64 +")
|
||||
.append(String.valueOf(stackSize.get().getRight()))
|
||||
, 25, 0xFFFFFF, layer);
|
||||
} else {
|
||||
drawCentredText(matrixStack, new LiteralText("Required Coils: ").append(String.valueOf(stackSize.get().getRight())), 25, 0xFFFFFF, layer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
drawTextWithShadow(matrixStack, client.textRenderer, new LiteralText("Size: ").append(String.valueOf(blockEntity.size)), 83, 81, 0xFFFFFF);
|
||||
drawTextWithShadow(matrixStack, client.textRenderer,new LiteralText(String.valueOf(blockEntity.getPowerMultiplier())).append("x"), 10, 81, 0xFFFFFF);
|
||||
drawTextWithShadow(matrixStack, client.textRenderer, new LiteralText("Size: ").append(String.valueOf(blockEntity.size)), 83, 81, 0xFFFFFF);
|
||||
drawTextWithShadow(matrixStack, client.textRenderer, new LiteralText(String.valueOf(blockEntity.getPowerMultiplier())).append("x"), 10, 81, 0xFFFFFF);
|
||||
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) this.blockEntity.getEnergy(), (int) this.blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
public void hologramToggle(GuiButtonExtended button, double x, double y){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
updateMultiBlockRender();
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
public void hologramToggle(GuiButtonExtended button, double x, double y) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
private void sendSizeChange(int sizeDelta){
|
||||
private void sendSizeChange(int sizeDelta) {
|
||||
NetworkManager.sendToServer(ServerboundPackets.createPacketFusionControlSize(sizeDelta, blockEntity.getPos()));
|
||||
//Reset the multiblock as it will be wrong now.
|
||||
if(blockEntity.renderMultiblock != null){
|
||||
updateMultiBlockRender();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMultiBlockRender(){
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState();
|
||||
|
||||
List<BlockPos> coils = Torus.generate(new BlockPos(0, 0, 0), blockEntity.size);
|
||||
coils.forEach(pos -> addComponent(pos.getX(), pos.getY(), pos.getZ(), coil, multiblock));
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
||||
}
|
||||
|
||||
public Optional<Pair<Integer, Integer>> getCoilStackCount(){
|
||||
if(!Torus.TORUS_SIZE_MAP.containsKey(blockEntity.size)){
|
||||
public Optional<Pair<Integer, Integer>> getCoilStackCount() {
|
||||
if (!Torus.TORUS_SIZE_MAP.containsKey(blockEntity.size)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
int count = Torus.TORUS_SIZE_MAP.get(blockEntity.size);
|
||||
|
|
|
@ -25,44 +25,37 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.tier1.GreenhouseControllerBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
GreenhouseControllerBlockEntity blockEntity;
|
||||
|
||||
|
||||
private final GreenhouseControllerBlockEntity blockEntity;
|
||||
|
||||
public GuiGreenhouseController(int syncID, final PlayerEntity player, final GreenhouseControllerBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawBackground(MatrixStack matrixStack, final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, f, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
|
||||
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
|
||||
|
||||
int gridYPos = 22;
|
||||
drawSlot(matrixStack, 30, gridYPos, layer);
|
||||
drawSlot(matrixStack, 48, gridYPos, layer);
|
||||
|
@ -70,8 +63,8 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
|||
drawSlot(matrixStack, 48, gridYPos + 18, layer);
|
||||
drawSlot(matrixStack, 30, gridYPos + 36, layer);
|
||||
drawSlot(matrixStack, 48, gridYPos + 36, layer);
|
||||
|
||||
if (!blockEntity.getMultiBlock()) {
|
||||
|
||||
if (!blockEntity.isMultiblockValid()) {
|
||||
getMinecraft().getTextureManager().bindTexture(new Identifier("techreborn", "textures/item/part/digital_display.png"));
|
||||
drawTexture(matrixStack, x + 68, y + 22, 0, 0, 16, 16, 16, 16);
|
||||
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
||||
|
@ -85,18 +78,18 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
|||
matrixStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
|
||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
|
||||
addHologramButton(90, 24, 212, layer).clickHandler(this::onClick);
|
||||
builder.drawHologramButton(matrixStack, this, 90, 24, mouseX, mouseY, layer);
|
||||
|
||||
if (!blockEntity.getMultiBlock()) {
|
||||
|
||||
if (!blockEntity.isMultiblockValid()) {
|
||||
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
|
||||
List<Text> list = Arrays.stream(I18n.translate("techreborn.tooltip.greenhouse.upgrade_available")
|
||||
.split("\\r?\\n"))
|
||||
|
@ -108,46 +101,11 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
|
|||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double x, Double y) {
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState lamp = TRContent.Machine.LAMP_INCANDESCENT.block.getDefaultState().with(Properties.FACING, Direction.DOWN);
|
||||
BlockState crop = Blocks.CACTUS.getDefaultState();
|
||||
|
||||
this.addComponent(-3, 3, -3, lamp, multiblock);
|
||||
this.addComponent(-3, 3, 0, lamp, multiblock);
|
||||
this.addComponent(-3, 3, 3, lamp, multiblock);
|
||||
this.addComponent(0, 3, -3, lamp, multiblock);
|
||||
this.addComponent(0, 3, 0, lamp, multiblock);
|
||||
this.addComponent(0, 3, 3, lamp, multiblock);
|
||||
this.addComponent(3, 3, -3, lamp, multiblock);
|
||||
this.addComponent(3, 3, 0, lamp, multiblock);
|
||||
this.addComponent(3, 3, 3, lamp, multiblock);
|
||||
|
||||
for (int i = -4; i <= 4; i++) {
|
||||
for (int j = -4; j <= 4; j++) {
|
||||
this.addComponent(i, 0, j, crop, multiblock);
|
||||
}
|
||||
}
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(
|
||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 5,
|
||||
y,
|
||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 5),
|
||||
blockState
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,21 +25,17 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
ImplosionCompressorBlockEntity blockEntity;
|
||||
private final ImplosionCompressorBlockEntity blockEntity;
|
||||
|
||||
public GuiImplosionCompressor(int syncID, final PlayerEntity player, final ImplosionCompressorBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
|
@ -54,13 +50,13 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
|||
final GuiBase.Layer layer = Layer.BACKGROUND;
|
||||
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
|
||||
|
||||
drawSlot(matrixStack, 50, 27, layer);
|
||||
drawSlot(matrixStack, 50, 47, layer);
|
||||
drawSlot(matrixStack, 92, 36, layer);
|
||||
drawSlot(matrixStack, 110, 36, layer);
|
||||
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
|
||||
|
@ -73,7 +69,7 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
|||
final GuiBase.Layer layer = Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||
|
@ -84,30 +80,7 @@ public class GuiImplosionCompressor extends GuiBase<BuiltScreenHandler> {
|
|||
|
||||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == 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 + 1, z, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(), multiblock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,23 +24,17 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
IndustrialGrinderBlockEntity blockEntity;
|
||||
private final IndustrialGrinderBlockEntity blockEntity;
|
||||
|
||||
public GuiIndustrialGrinder(int syncID, final PlayerEntity player, final IndustrialGrinderBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
|
@ -51,7 +45,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
|||
protected void drawBackground(MatrixStack matrixStack, final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, f, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
|
||||
|
||||
// Battery slot
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
// Liquid input slot
|
||||
|
@ -67,7 +61,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
|||
drawSlot(matrixStack, 126, 72, layer);
|
||||
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +73,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
|||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||
|
@ -89,59 +83,7 @@ public class GuiIndustrialGrinder extends GuiBase<BuiltScreenHandler> {
|
|||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, double mouseX, double mouseY){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
|
||||
addComponent(0, -1, 0, standardCasing, multiblock);
|
||||
addComponent(1, -1, 0, standardCasing, multiblock);
|
||||
addComponent(0, -1, 1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, 0, standardCasing, multiblock);
|
||||
addComponent(0, -1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, 1, standardCasing, multiblock);
|
||||
addComponent(1, -1, -1, standardCasing, multiblock);
|
||||
addComponent(1, -1, 1, standardCasing, multiblock);
|
||||
|
||||
addComponent(0, 0, 0, Blocks.WATER.getDefaultState(), multiblock);
|
||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
||||
|
||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
||||
addComponent(1, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, 1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, 1, standardCasing, multiblock);
|
||||
addComponent(1, 1, -1, standardCasing, multiblock);
|
||||
addComponent(1, 1, 1, standardCasing, multiblock);
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
public void onClick(GuiButtonExtended button, double mouseX, double mouseY) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(
|
||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetX() * 2,
|
||||
y,
|
||||
z - Direction.byId(this.blockEntity.getFacingInt()).getOffsetZ() * 2),
|
||||
blockState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,40 +24,28 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
IndustrialSawmillBlockEntity blockEntity;
|
||||
private final IndustrialSawmillBlockEntity blockEntity;
|
||||
|
||||
public GuiIndustrialSawmill(int syncID, final PlayerEntity player, final IndustrialSawmillBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(MatrixStack matrixStack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, partialTicks, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
|
||||
|
||||
// Battery slot
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
// Liquid input slot
|
||||
|
@ -70,9 +58,9 @@ public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
|||
drawSlot(matrixStack, 126, 25, layer);
|
||||
drawSlot(matrixStack, 126, 43, layer);
|
||||
drawSlot(matrixStack, 126, 61, layer);
|
||||
|
||||
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
}
|
||||
|
@ -81,70 +69,20 @@ public class GuiIndustrialSawmill extends GuiBase<BuiltScreenHandler> {
|
|||
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
|
||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawTank(matrixStack, this, 53, 25, mouseX, mouseY, blockEntity.tank.getFluidInstance(), blockEntity.tank.getCapacity(), blockEntity.tank.isEmpty(), layer);
|
||||
if (blockEntity.getMutliBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
|
||||
builder.drawHologramButton(matrixStack, this, 76, 56, mouseX, mouseY, layer);
|
||||
}
|
||||
}
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
|
||||
addComponent(0, -1, 0, standardCasing, multiblock);
|
||||
addComponent(1, -1, 0, standardCasing, multiblock);
|
||||
addComponent(0, -1, 1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, 0, standardCasing, multiblock);
|
||||
addComponent(0, -1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, -1, 1, standardCasing, multiblock);
|
||||
addComponent(1, -1, -1, standardCasing, multiblock);
|
||||
addComponent(1, -1, 1, standardCasing, multiblock);
|
||||
|
||||
addComponent(0, 0, 0, Blocks.WATER.getDefaultState(), multiblock);
|
||||
addComponent(1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 0, reinforcedCasing, multiblock);
|
||||
addComponent(0, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(-1, 0, 1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, -1, reinforcedCasing, multiblock);
|
||||
addComponent(1, 0, 1, reinforcedCasing, multiblock);
|
||||
|
||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, 0, standardCasing, multiblock);
|
||||
addComponent(1, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, 1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, 0, standardCasing, multiblock);
|
||||
addComponent(0, 1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, -1, standardCasing, multiblock);
|
||||
addComponent(-1, 1, 1, standardCasing, multiblock);
|
||||
addComponent(1, 1, -1, standardCasing, multiblock);
|
||||
addComponent(1, 1, 1, standardCasing, multiblock);
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(
|
||||
x - Direction.byId(this.blockEntity.getFacingInt()).getOffsetY() * 2,
|
||||
y,
|
||||
z- Direction.byId(this.blockEntity.getFacingInt()).getOffsetY() * 2).offset(blockEntity.getFacing().getOpposite(), 2), blockState);
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,27 +24,23 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.builder.widget.GuiButtonExtended;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import techreborn.blockentity.machine.multiblock.VacuumFreezerBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
VacuumFreezerBlockEntity blockEntity;
|
||||
private final VacuumFreezerBlockEntity blockEntity;
|
||||
|
||||
public GuiVacuumFreezer(int syncID, final PlayerEntity player, final VacuumFreezerBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawBackground(MatrixStack matrixStack, final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, f, mouseX, mouseY);
|
||||
|
@ -59,7 +55,7 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
|||
drawOutputSlot(matrixStack, 101, 45, layer);
|
||||
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
builder.drawHologramButton(matrixStack, this, 6, 4, mouseX, mouseY, layer);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +66,7 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
|||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
if (blockEntity.getMultiBlock()) {
|
||||
if (blockEntity.isMultiblockValid()) {
|
||||
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(matrixStack, this, layer);
|
||||
|
@ -80,52 +76,7 @@ public class GuiVacuumFreezer extends GuiBase<BuiltScreenHandler> {
|
|||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
|
||||
if (hideGuiElements()) return;
|
||||
if (blockEntity.renderMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
BlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
BlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||
|
||||
addComponent(0, -1, 0, advancedCasing, multiblock);
|
||||
addComponent(1, -1, 0, advancedCasing, multiblock);
|
||||
addComponent(0, -1, 1, advancedCasing, multiblock);
|
||||
addComponent(-1, -1, 0, advancedCasing, multiblock);
|
||||
addComponent(0, -1, -1, advancedCasing, multiblock);
|
||||
addComponent(-1, -1, -1, advancedCasing, multiblock);
|
||||
addComponent(-1, -1, 1, advancedCasing, multiblock);
|
||||
addComponent(1, -1, -1, advancedCasing, multiblock);
|
||||
addComponent(1, -1, 1, advancedCasing, multiblock);
|
||||
|
||||
addComponent(1, -2, 0, industrialCasing, multiblock);
|
||||
addComponent(0, -2, 1, industrialCasing, multiblock);
|
||||
addComponent(-1, -2, 0, industrialCasing, multiblock);
|
||||
addComponent(0, -2, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, -2, -1, industrialCasing, multiblock);
|
||||
addComponent(-1, -2, 1, industrialCasing, multiblock);
|
||||
addComponent(1, -2, -1, industrialCasing, multiblock);
|
||||
addComponent(1, -2, 1, industrialCasing, multiblock);
|
||||
|
||||
addComponent(0, -3, 0, advancedCasing, multiblock);
|
||||
addComponent(1, -3, 0, advancedCasing, multiblock);
|
||||
addComponent(0, -3, 1, advancedCasing, multiblock);
|
||||
addComponent(-1, -3, 0, advancedCasing, multiblock);
|
||||
addComponent(0, -3, -1, advancedCasing, multiblock);
|
||||
addComponent(-1, -3, -1, advancedCasing, multiblock);
|
||||
addComponent(-1, -3, 1, advancedCasing, multiblock);
|
||||
addComponent(1, -3, -1, advancedCasing, multiblock);
|
||||
addComponent(1, -3, 1, advancedCasing, multiblock);
|
||||
|
||||
blockEntity.renderMultiblock = multiblock;
|
||||
}
|
||||
} else {
|
||||
blockEntity.renderMultiblock = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) {
|
||||
multiblock.addComponent(new BlockPos(x, y, z), blockState);
|
||||
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY) {
|
||||
blockEntity.renderMultiblock ^= !hideGuiElements();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue