From 8958f163d2dcf52e3850f8c9ec425657380f195f Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 16 May 2022 16:53:10 +0200 Subject: [PATCH] a little bit of assemfac --- src/main/java/com/hbm/handler/GUIHandler.java | 1 + .../com/hbm/inventory/gui/GUIAssemfac.java | 50 ++++++++ .../machine/TileEntityMachineAssemfac.java | 109 +++++++++++++++++- 3 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/hbm/inventory/gui/GUIAssemfac.java diff --git a/src/main/java/com/hbm/handler/GUIHandler.java b/src/main/java/com/hbm/handler/GUIHandler.java index 47860bd27..18c0c9b53 100644 --- a/src/main/java/com/hbm/handler/GUIHandler.java +++ b/src/main/java/com/hbm/handler/GUIHandler.java @@ -877,6 +877,7 @@ public class GUIHandler implements IGuiHandler { if(entity instanceof TileEntityMachineLiquefactor) { return new GUILiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity); } if(entity instanceof TileEntityMachineSolidifier) { return new GUISolidifier(player.inventory, (TileEntityMachineSolidifier) entity); } if(entity instanceof TileEntityMachineRadiolysis) { return new GUIRadiolysis(player.inventory, (TileEntityMachineRadiolysis) entity); } + if(entity instanceof TileEntityMachineAssemfac) { return new GUIAssemfac(player.inventory, (TileEntityMachineAssemfac) entity); } if(entity instanceof TileEntityMachineChemfac) { return new GUIChemfac(player.inventory, (TileEntityMachineChemfac) entity); } if(entity instanceof TileEntityElectrolyser) { return new GUIElectrolyser(player.inventory, (TileEntityElectrolyser) entity); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIAssemfac.java b/src/main/java/com/hbm/inventory/gui/GUIAssemfac.java new file mode 100644 index 000000000..880df1bd1 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIAssemfac.java @@ -0,0 +1,50 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerAssemfac; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityMachineAssemfac; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; + +public class GUIAssemfac extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_assemfac.png"); + private TileEntityMachineAssemfac assemfac; + + public GUIAssemfac(InventoryPlayer invPlayer, TileEntityMachineAssemfac tedf) { + super(new ContainerAssemfac(invPlayer, tedf)); + assemfac = tedf; + + this.xSize = 256; + this.ySize = 256; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { } + + @Override + protected void drawGuiContainerBackgroundLayer(float interp, int mX, int mY) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + if(Keyboard.isKeyDown(Keyboard.KEY_LMENU)) + for(int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) { + Slot s = this.inventorySlots.getSlot(i); + + this.fontRendererObj.drawStringWithShadow(i + "", guiLeft + s.xDisplayPosition + 2, guiTop + s.yDisplayPosition, 0xffffff); + this.fontRendererObj.drawStringWithShadow(s.getSlotIndex() + "", guiLeft + s.xDisplayPosition + 2, guiTop + s.yDisplayPosition + 8, 0xff8080); + } + } +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemfac.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemfac.java index 14b532385..3dc7f7122 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemfac.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemfac.java @@ -2,14 +2,21 @@ package com.hbm.tileentity.machine; import java.util.Random; +import com.hbm.blocks.BlockDummyable; import com.hbm.tileentity.TileEntityMachineBase; -public class TileEntityMachineAssemfac extends TileEntityMachineBase { +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase { public AssemblerArm[] arms; public TileEntityMachineAssemfac() { - super(10 * 8 + 4 + 1); //8 assembler groups with 10 slots, 4 upgrade slots, 1 battery slot + super(14 * 8 + 4 + 1); //8 assembler groups with 14 slots, 4 upgrade slots, 1 battery slot arms = new AssemblerArm[6]; for(int i = 0; i < arms.length; i++) { arms[i] = new AssemblerArm(i % 3 == 1 ? 1 : 0); //the second of every group of three becomes a welder @@ -176,4 +183,102 @@ public class TileEntityMachineAssemfac extends TileEntityMachineBase { RETRACT_STRIKER } } + + AxisAlignedBB bb = null; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + + if(bb == null) { + bb = AxisAlignedBB.getBoundingBox( + xCoord - 5, + yCoord, + zCoord - 5, + xCoord + 5, + yCoord + 4, + zCoord + 5 + ); + } + + return bb; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } + + @Override + public void setPower(long power) { + // TODO Auto-generated method stub + + } + + @Override + public long getPower() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long getMaxPower() { + return 10_000_000; + } + + @Override + public int getRecipeCount() { + return 8; + } + + @Override + public int getTemplateIndex(int index) { + return 17 + index * 14; + } + + @Override + public int[] getSlotIndicesFromIndex(int index) { + return new int[] { 5 + index * 14, 16 + index * 14, 18 + index * 14}; + } + + ChunkCoordinates[] inpos; + ChunkCoordinates[] outpos; + + @Override + public ChunkCoordinates[] getInputPositions() { + + if(inpos != null) + return inpos; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + inpos = new ChunkCoordinates[] { + new ChunkCoordinates(xCoord + dir.offsetX * 4 - rot.offsetX * 1, yCoord, zCoord + dir.offsetZ * 4 - rot.offsetZ * 1), + new ChunkCoordinates(xCoord - dir.offsetX * 5 + rot.offsetX * 2, yCoord, zCoord - dir.offsetZ * 5 + rot.offsetZ * 2), + new ChunkCoordinates(xCoord - dir.offsetX * 2 - rot.offsetX * 4, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 4), + new ChunkCoordinates(xCoord + dir.offsetX * 1 + rot.offsetX * 5, yCoord, zCoord + dir.offsetZ * 1 + rot.offsetZ * 5) + }; + + return inpos; + } + + @Override + public ChunkCoordinates[] getOutputPositions() { + + if(outpos != null) + return outpos; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + outpos = new ChunkCoordinates[] { + new ChunkCoordinates(xCoord + dir.offsetX * 4 + rot.offsetX * 2, yCoord, zCoord + dir.offsetZ * 4 + rot.offsetZ * 2), + new ChunkCoordinates(xCoord - dir.offsetX * 5 - rot.offsetX * 1, yCoord, zCoord - dir.offsetZ * 5 - rot.offsetZ * 1), + new ChunkCoordinates(xCoord + dir.offsetX * 1 - rot.offsetX * 4, yCoord, zCoord + dir.offsetZ * 1 - rot.offsetZ * 4), + new ChunkCoordinates(xCoord - dir.offsetX * 2 + rot.offsetX * 5, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ * 5) + }; + + return outpos; + } }