From 4bf5cb66c4fcf43aeed690fb3c50b2607d9b9035 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Thu, 3 Mar 2016 19:47:35 +0100 Subject: [PATCH] Failed attempt making wires, doesn't work but looks good. --- assets/hbm/textures/blocks/red_cable.png | Bin 409 -> 335 bytes assets/hbm/textures/blocks/red_cable_icon.png | Bin 0 -> 268 bytes com/hbm/blocks/BlockCable.java | 37 +++++++ com/hbm/blocks/ModBlocks.java | 2 +- com/hbm/blocks/TileEntityCable.java | 46 ++++++++- com/hbm/blocks/TileEntityLaunchPad.java | 3 +- com/hbm/blocks/TileEntityMachineBattery.java | 3 +- com/hbm/blocks/TileEntityMachineCoal.java | 3 +- .../blocks/TileEntityMachineDeuterium.java | 3 +- .../TileEntityMachineElectricFurnace.java | 3 +- .../blocks/TileEntityMachineGenerator.java | 3 +- com/hbm/calc/PowerNet.java | 7 ++ com/hbm/interfaces/IConductor.java | 5 + com/hbm/render/RenderCable.java | 93 +++++++++++++++++- com/hbm/world/Silo.java | 4 +- 15 files changed, 196 insertions(+), 16 deletions(-) create mode 100644 assets/hbm/textures/blocks/red_cable_icon.png create mode 100644 com/hbm/calc/PowerNet.java create mode 100644 com/hbm/interfaces/IConductor.java diff --git a/assets/hbm/textures/blocks/red_cable.png b/assets/hbm/textures/blocks/red_cable.png index 5c6c56ce4090a37517c0a6f77fd6ea11b3b6f73e..7ef1825fae3c8de69d60483b9036bd91f4e2565c 100644 GIT binary patch delta 252 zcmbQqe4c57%0xp6u7eB=dnjA#h9u~9bW($X` z)=P3>sb|}D;}*-+Rn;%;{N$9yKRI!K7M43Q{o>5PwYkyyr;AMX{(HqAeP~0&?|Xmt znC;IyyL#29UF+O^FIQYI{ToqtAVzF=wcOeGgTe~DWM4f&O>zP delta 325 zcmX@lG?RIP3KwH>kh>GZx^prwCn`#F9cEzQJIr`Ie?`hfH??|3E>9Q7kO=p^lYG67 zI0&@9X3Lw~yI|cjfuE}T6%==_%ws7vEuUFECD=5CT4b!L57=+eg)zaEJRH9lO_SN$w0?{DS_xqXfEum9$(nR7(k zNIY>PCwK3z%voQ158wQ3W?#cp|ChOp%k2E;JFgdM$Z&UDe0Nm+_P6DV)ea|Fywn1W t8Ygj1@mY|0#LT=By}Z;C1rt33 zJr2g1CypIL$!q$j9W?mP_WrN#<)W>Qnyi-3wW99s zUcWf;)tY globalPowerNet = new ArrayList(); + + public TileEntityCable() { + + } + + public void updateEntity() { + this.updateConnections(); + } + + public void updateConnections() { + TileEntity e0 = this.worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); + if(e0 instanceof IConductor) connections[0] = ForgeDirection.UP; + else connections[0] = null; + TileEntity e1 = this.worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); + if(e1 instanceof IConductor) connections[1] = ForgeDirection.DOWN; + else connections[1] = null; + TileEntity e2 = this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1); + if(e2 instanceof IConductor) connections[2] = ForgeDirection.NORTH; + else connections[2] = null; + TileEntity e3 = this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord); + if(e3 instanceof IConductor) connections[3] = ForgeDirection.EAST; + else connections[3] = null; + TileEntity e4 = this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); + if(e4 instanceof IConductor) connections[4] = ForgeDirection.SOUTH; + else connections[4] = null; + TileEntity e5 = this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord); + if(e5 instanceof IConductor) connections[5] = ForgeDirection.WEST; + else connections[5] = null; + } } diff --git a/com/hbm/blocks/TileEntityLaunchPad.java b/com/hbm/blocks/TileEntityLaunchPad.java index bc82d1de3..ea7d3ee2f 100644 --- a/com/hbm/blocks/TileEntityLaunchPad.java +++ b/com/hbm/blocks/TileEntityLaunchPad.java @@ -1,5 +1,6 @@ package com.hbm.blocks; +import com.hbm.interfaces.IConductor; import com.hbm.items.ModItems; import net.minecraft.entity.player.EntityPlayer; @@ -12,7 +13,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -public class TileEntityLaunchPad extends TileEntity implements ISidedInventory { +public class TileEntityLaunchPad extends TileEntity implements ISidedInventory, IConductor { public ItemStack slots[]; diff --git a/com/hbm/blocks/TileEntityMachineBattery.java b/com/hbm/blocks/TileEntityMachineBattery.java index d26ffc49a..14b781c97 100644 --- a/com/hbm/blocks/TileEntityMachineBattery.java +++ b/com/hbm/blocks/TileEntityMachineBattery.java @@ -1,5 +1,6 @@ package com.hbm.blocks; +import com.hbm.interfaces.IConductor; import com.hbm.items.ModItems; import net.minecraft.entity.player.EntityPlayer; @@ -10,7 +11,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -public class TileEntityMachineBattery extends TileEntity implements ISidedInventory { +public class TileEntityMachineBattery extends TileEntity implements ISidedInventory, IConductor { private ItemStack slots[]; diff --git a/com/hbm/blocks/TileEntityMachineCoal.java b/com/hbm/blocks/TileEntityMachineCoal.java index 6b8d2d16f..2c1300614 100644 --- a/com/hbm/blocks/TileEntityMachineCoal.java +++ b/com/hbm/blocks/TileEntityMachineCoal.java @@ -10,9 +10,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import com.hbm.interfaces.IConductor; import com.hbm.items.ModItems; -public class TileEntityMachineCoal extends TileEntity implements ISidedInventory { +public class TileEntityMachineCoal extends TileEntity implements ISidedInventory, IConductor { private ItemStack slots[]; diff --git a/com/hbm/blocks/TileEntityMachineDeuterium.java b/com/hbm/blocks/TileEntityMachineDeuterium.java index f7993e3f2..5c3db714c 100644 --- a/com/hbm/blocks/TileEntityMachineDeuterium.java +++ b/com/hbm/blocks/TileEntityMachineDeuterium.java @@ -1,5 +1,6 @@ package com.hbm.blocks; +import com.hbm.interfaces.IConductor; import com.hbm.items.ModItems; import net.minecraft.entity.player.EntityPlayer; @@ -10,7 +11,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -public class TileEntityMachineDeuterium extends TileEntity implements ISidedInventory { +public class TileEntityMachineDeuterium extends TileEntity implements ISidedInventory, IConductor { private ItemStack slots[]; diff --git a/com/hbm/blocks/TileEntityMachineElectricFurnace.java b/com/hbm/blocks/TileEntityMachineElectricFurnace.java index 06e9b3700..cc3ca3fbe 100644 --- a/com/hbm/blocks/TileEntityMachineElectricFurnace.java +++ b/com/hbm/blocks/TileEntityMachineElectricFurnace.java @@ -1,5 +1,6 @@ package com.hbm.blocks; +import com.hbm.interfaces.IConductor; import com.hbm.items.ModItems; import net.minecraft.entity.player.EntityPlayer; @@ -11,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -public class TileEntityMachineElectricFurnace extends TileEntity implements ISidedInventory { +public class TileEntityMachineElectricFurnace extends TileEntity implements ISidedInventory, IConductor { private ItemStack slots[]; diff --git a/com/hbm/blocks/TileEntityMachineGenerator.java b/com/hbm/blocks/TileEntityMachineGenerator.java index 6ff0896f5..10aeb5331 100644 --- a/com/hbm/blocks/TileEntityMachineGenerator.java +++ b/com/hbm/blocks/TileEntityMachineGenerator.java @@ -3,6 +3,7 @@ package com.hbm.blocks; import java.util.Random; import com.hbm.explosion.ExplosionNukeGeneric; +import com.hbm.interfaces.IConductor; import com.hbm.items.ItemFuelRod; import com.hbm.items.ModItems; @@ -15,7 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -public class TileEntityMachineGenerator extends TileEntity implements ISidedInventory { +public class TileEntityMachineGenerator extends TileEntity implements ISidedInventory, IConductor { private ItemStack slots[]; diff --git a/com/hbm/calc/PowerNet.java b/com/hbm/calc/PowerNet.java new file mode 100644 index 000000000..3959ed2a1 --- /dev/null +++ b/com/hbm/calc/PowerNet.java @@ -0,0 +1,7 @@ +package com.hbm.calc; + +public class PowerNet { + public int id; + public int requestedPower; + public int buffer; +} diff --git a/com/hbm/interfaces/IConductor.java b/com/hbm/interfaces/IConductor.java new file mode 100644 index 000000000..5fd452844 --- /dev/null +++ b/com/hbm/interfaces/IConductor.java @@ -0,0 +1,5 @@ +package com.hbm.interfaces; + +public interface IConductor { + //This interface just exists for cables to connect onto machines +} diff --git a/com/hbm/render/RenderCable.java b/com/hbm/render/RenderCable.java index 6f33b15df..c5f91a956 100644 --- a/com/hbm/render/RenderCable.java +++ b/com/hbm/render/RenderCable.java @@ -2,6 +2,7 @@ package com.hbm.render; import org.lwjgl.opengl.GL11; +import com.hbm.blocks.TileEntityCable; import com.hbm.lib.RefStrings; import net.minecraft.client.renderer.Tessellator; @@ -22,7 +23,14 @@ public class RenderCable extends TileEntitySpecialRenderer { GL11.glDisable(GL11.GL_LIGHTING); this.bindTexture(texture); drawCore(tileentity); - drawConnection(ForgeDirection.UP); + TileEntityCable cable = (TileEntityCable) tileentity; + for(int i = 0; i < cable.connections.length; i++) + { + if(cable.connections[i] != null) + { + drawConnection(cable.connections[i]); + } + } GL11.glTranslated(-offsetX, -offsetY, -offsetZ); GL11.glEnable(GL11.GL_LIGHTING); @@ -61,17 +69,92 @@ public class RenderCable extends TileEntitySpecialRenderer { tesseract.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * textureP, 0 * textureP); tesseract.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * textureP, 5 * textureP); tesseract.draw(); + + // Mühsam muss ich hier im BSH meine genialen Mods schreiben, obwohl ich die Zeit eigentlich doch besser nutzen könnte. + // Da mir das aber Spaß macht, wird auch in Zukunft gutes Zeug von mir geben (und damit meine ich NICHT Drogen, etc.) + // Danke. + + //I didn't write this, but I'm gonna leave it there. } public void drawConnection(ForgeDirection direction) { + Tessellator tesseract = Tessellator.instance; + tesseract.startDrawingQuads(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + if(direction.equals(ForgeDirection.UP)) + { + + } + if(direction.equals(ForgeDirection.DOWN)) + { + GL11.glRotatef(180, 1, 0, 0); + } + if(direction.equals(ForgeDirection.NORTH)) + { + GL11.glRotatef(270, 1, 0, 0); + } + if(direction.equals(ForgeDirection.SOUTH)) + { + GL11.glRotatef(90, 1, 0, 0); + } + if(direction.equals(ForgeDirection.EAST)) + { + GL11.glRotatef(270, 0, 0, 1); + } + if(direction.equals(ForgeDirection.WEST)) + { + GL11.glRotatef(90, 0, 0, 1); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * textureP, 5 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * textureP, 5 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * textureP, 0 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * textureP, 0 * textureP); + + tesseract.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * textureP, 5 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * textureP, 5 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * textureP, 0 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * textureP, 0 * textureP); + + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * textureP, 5 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * textureP, 5 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * textureP, 0 * textureP); + tesseract.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * textureP, 0 * textureP); + + tesseract.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * textureP, 5 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * textureP, 5 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * textureP, 0 * textureP); + tesseract.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * textureP, 0 * textureP); + tesseract.draw(); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); if(direction.equals(ForgeDirection.UP)) { - - } - Tessellator tesseract = Tessellator.instance; - tesseract.draw(); + } + if(direction.equals(ForgeDirection.DOWN)) + { + GL11.glRotatef(-180, 1, 0, 0); + } + if(direction.equals(ForgeDirection.NORTH)) + { + GL11.glRotatef(-270, 1, 0, 0); + } + if(direction.equals(ForgeDirection.SOUTH)) + { + GL11.glRotatef(-90, 1, 0, 0); + } + if(direction.equals(ForgeDirection.EAST)) + { + GL11.glRotatef(-270, 0, 0, 1); + } + if(direction.equals(ForgeDirection.WEST)) + { + GL11.glRotatef(-90, 0, 0, 1); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); } } diff --git a/com/hbm/world/Silo.java b/com/hbm/world/Silo.java index bb63d303e..253816278 100644 --- a/com/hbm/world/Silo.java +++ b/com/hbm/world/Silo.java @@ -1637,8 +1637,8 @@ public class Silo extends WorldGenerator world.setBlock(x + 11, y + -9, z + 4, Block1, 0, 3); world.setBlock(x + 7, y + -9, z + 5, Block1, 0, 3); world.setBlock(x + 8, y + -9, z + 5, Blocks.chest, 2, 3); - world.setBlockMetadataWithNotify(x + 8, y + -9, z + 2, 3, 3); - if(world.getBlock(x + 8, y + -9, z + 2) == Blocks.chest) + world.setBlockMetadataWithNotify(x + 8, y + -9, z + 5, 3, 3); + if(world.getBlock(x + 8, y + -9, z + 5) == Blocks.chest) { WeightedRandomChestContent.generateChestContents(rand, HbmChestContents.getLoot(1), (TileEntityChest)world.getTileEntity(x + 8, y + -9, z + 5), rand.nextInt(2)+ 8); }