Failed attempt making wires, doesn't work but looks good.

This commit is contained in:
HbmMods 2016-03-03 19:47:35 +01:00
parent 539e1a4009
commit 4bf5cb66c4
15 changed files with 196 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

View File

@ -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_) {

View File

@ -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");

View File

@ -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<PowerNet> globalPowerNet = new ArrayList<PowerNet>();
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;
}
}

View File

@ -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[];

View File

@ -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[];

View File

@ -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[];

View File

@ -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[];

View File

@ -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[];

View File

@ -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[];

View File

@ -0,0 +1,7 @@
package com.hbm.calc;
public class PowerNet {
public int id;
public int requestedPower;
public int buffer;
}

View File

@ -0,0 +1,5 @@
package com.hbm.interfaces;
public interface IConductor {
//This interface just exists for cables to connect onto machines
}

View File

@ -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);
}
}

View File

@ -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);
}