diff --git a/assets/hbm/textures/blocks/red_cable.png b/assets/hbm/textures/blocks/red_cable.png index 5c6c56ce4..7ef1825fa 100644 Binary files a/assets/hbm/textures/blocks/red_cable.png and b/assets/hbm/textures/blocks/red_cable.png differ diff --git a/assets/hbm/textures/blocks/red_cable_icon.png b/assets/hbm/textures/blocks/red_cable_icon.png new file mode 100644 index 000000000..f21400da6 Binary files /dev/null and b/assets/hbm/textures/blocks/red_cable_icon.png differ diff --git a/com/hbm/blocks/BlockCable.java b/com/hbm/blocks/BlockCable.java index 30c3f023a..b3577adf4 100644 --- a/com/hbm/blocks/BlockCable.java +++ b/com/hbm/blocks/BlockCable.java @@ -3,6 +3,8 @@ package com.hbm.blocks; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockCable extends BlockContainer { @@ -13,6 +15,41 @@ public class BlockCable extends BlockContainer { this.setBlockBounds(11 * p / 2, 11 * p / 2, 11 * p / 2, 1 - 11 * p / 2, 1 - 11 * p / 2, 1 - 11 * p / 2); this.useNeighborBrightness = true; } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + TileEntityCable cable = (TileEntityCable)world.getTileEntity(x, y, z); + + if(cable != null) + { + float p = 1F/16F; + float minX = 11 * p / 2 - (cable.connections[5] != null ? (11 * p / 2) : 0); + float minY = 11 * p / 2 - (cable.connections[1] != null ? (11 * p / 2) : 0); + float minZ = 11 * p / 2 - (cable.connections[2] != null ? (11 * p / 2) : 0); + float maxX = 1 - 11 * p / 2 + (cable.connections[3] != null ? (11 * p / 2) : 0); + float maxY = 1 - 11 * p / 2 + (cable.connections[0] != null ? (11 * p / 2) : 0); + float maxZ = 1 - 11 * p / 2 + (cable.connections[4] != null ? (11 * p / 2) : 0); + + this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); + } + + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntityCable cable = (TileEntityCable)world.getTileEntity(x, y, z); + + if(cable != null) + { + float p = 1F/16F; + float minX = 11 * p / 2 - (cable.connections[5] != null ? (11 * p / 2) : 0); + float minY = 11 * p / 2 - (cable.connections[1] != null ? (11 * p / 2) : 0); + float minZ = 11 * p / 2 - (cable.connections[2] != null ? (11 * p / 2) : 0); + float maxX = 1 - 11 * p / 2 + (cable.connections[3] != null ? (11 * p / 2) : 0); + float maxY = 1 - 11 * p / 2 + (cable.connections[0] != null ? (11 * p / 2) : 0); + float maxZ = 1 - 11 * p / 2 + (cable.connections[4] != null ? (11 * p / 2) : 0); + + this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { diff --git a/com/hbm/blocks/ModBlocks.java b/com/hbm/blocks/ModBlocks.java index 2cf3e445e..b05697871 100644 --- a/com/hbm/blocks/ModBlocks.java +++ b/com/hbm/blocks/ModBlocks.java @@ -360,7 +360,7 @@ public class ModBlocks { machine_coal_on = new MachineCoal(true).setBlockName("machine_coal_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F); red_wire_coated = new WireCoated(Material.iron).setBlockName("red_wire_coated").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":red_wire_coated"); - red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.tabBlock); + red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.tabBlock).setBlockTextureName(RefStrings.MODID + ":red_cable_icon"); factory_titanium_hull = new BlockGeneric(Material.iron).setBlockName("factory_titanium_hull").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.tabBlock).setBlockTextureName(RefStrings.MODID + ":factory_titanium_hull"); factory_titanium_furnace = new FactoryHatch(Material.iron).setBlockName("factory_titanium_furnace").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.tabBlock).setBlockTextureName(RefStrings.MODID + ":factory_titanium_furnace"); diff --git a/com/hbm/blocks/TileEntityCable.java b/com/hbm/blocks/TileEntityCable.java index c35517146..de5c56669 100644 --- a/com/hbm/blocks/TileEntityCable.java +++ b/com/hbm/blocks/TileEntityCable.java @@ -1,7 +1,49 @@ package com.hbm.blocks; -import net.minecraft.tileentity.TileEntity; +import java.util.ArrayList; +import java.util.List; -public class TileEntityCable extends TileEntity { +import com.hbm.calc.PowerNet; +import com.hbm.interfaces.IConductor; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import scala.Int; + +public class TileEntityCable extends TileEntity implements IConductor { + + public ForgeDirection[] connections = new ForgeDirection[6]; + + //Won't work as intended, shit. + //public List 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); }