Added Steel Wire and insulated variant.

Textures are TERRIBLE though...
dev
Decebaldecebal 2015-06-26 21:02:06 +03:00
parent 110f7fe0ec
commit dc7974d821
15 changed files with 91 additions and 522 deletions

View File

@ -23,7 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import steamcraft.client.lib.RenderIDs;
import steamcraft.common.tiles.energy.TileCopperWire;
import steamcraft.common.tiles.energy.TileSteelWire;
/**
* @author Surseance
@ -37,7 +37,7 @@ public class BlockSteelWireRenderer implements ISimpleBlockRenderingHandler
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileCopperWire te = new TileCopperWire();
TileSteelWire te = new TileSteelWire();
System.arraycopy(ForgeDirection.VALID_DIRECTIONS, 0, te.connections, 0, ForgeDirection.VALID_DIRECTIONS.length);
@ -64,6 +64,6 @@ public class BlockSteelWireRenderer implements ISimpleBlockRenderingHandler
@Override
public int getRenderId()
{
return RenderIDs.blockCopperWireRI;
return RenderIDs.blockSteelWireRI;
}
}

View File

@ -30,12 +30,12 @@ import steamcraft.common.tiles.energy.TileCopperWire;
*/
public class TileCopperWireRenderer extends TileEntitySpecialRenderer
{
private static final ResourceLocation texture = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockCopperWire.png");
private static final ResourceLocation texture1 = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockInsulatedWire.png");
private static float pixel = LibInfo.pixel;
private static float tPixel = LibInfo.tPixel;
protected ResourceLocation texture = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockCopperWire.png");
protected ResourceLocation texture1 = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockInsulatedCopperWire.png");
@Override
public void renderTileEntityAt(TileEntity tile, double transX, double transY, double transZ, float f)
{
@ -47,9 +47,9 @@ public class TileCopperWireRenderer extends TileEntitySpecialRenderer
TileCopperWire wire = (TileCopperWire) tile;
if(tile.getBlockMetadata() == 0)
this.bindTexture(TileCopperWireRenderer.texture);
this.bindTexture(texture);
else
this.bindTexture(TileCopperWireRenderer.texture1);
this.bindTexture(texture1);
this.drawCore(wire);
for(ForgeDirection dir : wire.connections)
@ -61,7 +61,7 @@ public class TileCopperWireRenderer extends TileEntitySpecialRenderer
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glTranslated(-transX, -transY + -3F, -transZ);
GL11.glTranslated(-transX, -transY, -transZ);
GL11.glPopMatrix();
}

View File

@ -12,271 +12,18 @@
*/
package steamcraft.client.renderers.tile;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import steamcraft.common.lib.LibInfo;
import steamcraft.common.lib.ModInfo;
import steamcraft.common.tiles.energy.TileCopperWire;
/**
* @author Decebaldecebal
*
*/
public class TileSteelWireRenderer extends TileEntitySpecialRenderer
public class TileSteelWireRenderer extends TileCopperWireRenderer
{
private static final ResourceLocation texture = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockCopperWire.png");
private static final ResourceLocation texture1 = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockInsulatedWire.png");
private static float pixel = LibInfo.pixel;
private static float tPixel = LibInfo.tPixel;
@Override
public void renderTileEntityAt(TileEntity tile, double transX, double transY, double transZ, float f)
public TileSteelWireRenderer()
{
GL11.glPushMatrix();
GL11.glTranslated(transX, transY, transZ);
GL11.glDisable(GL11.GL_LIGHTING);
TileCopperWire wire = (TileCopperWire) tile;
if(tile.getBlockMetadata() == 0)
this.bindTexture(TileSteelWireRenderer.texture);
else
this.bindTexture(TileSteelWireRenderer.texture1);
this.drawCore(wire);
for(ForgeDirection dir : wire.connections)
if(dir != null)
if(wire.extract == dir)
this.drawAlternateConnection(dir, wire);
else
this.drawConnection(dir, wire);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glTranslated(-transX, -transY + -3F, -transZ);
GL11.glPopMatrix();
}
private void drawAlternateConnection(ForgeDirection dir, TileCopperWire wire)
{
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
{
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
if(dir == ForgeDirection.UP)
{
// ROTATE
}
else if(dir == ForgeDirection.DOWN)
GL11.glRotatef(180, 1, 0, 0);
else if(dir == ForgeDirection.SOUTH)
GL11.glRotatef(90, 1, 0, 0);
else if(dir == ForgeDirection.NORTH)
GL11.glRotatef(270, 1, 0, 0);
else if(dir == ForgeDirection.WEST)
GL11.glRotatef(90, 0, 0, 1);
else if(dir == ForgeDirection.EAST)
GL11.glRotatef(270, 0, 0, 1);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 1 - (12 * pixel), 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 12 * pixel, 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
// The actual new connection
tess.addVertexWithUV(1 - (10 * pixel), 1, 1 - (10 * pixel), 0 * tPixel, 14 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1, 10 * pixel, 8 * tPixel, 14 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 10 * pixel, 8 * tPixel, 7 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 1 - (10 * pixel), 0 * tPixel, 7 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 1 - (10 * pixel), 0 * tPixel, 7 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 10 * pixel, 8 * tPixel, 7 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 10 * pixel, 8 * tPixel, 14 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 1 - (10 * pixel), 0 * tPixel, 14 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1, 10 * pixel, 0 * tPixel, 8 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 10 * pixel, 0 * tPixel, 10 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 10 * pixel, 8 * tPixel, 10 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 10 * pixel, 8 * tPixel, 8 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 1 - (10 * pixel), 8 * tPixel, 8 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 1 - (10 * pixel), 8 * tPixel, 10 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 1 - (10 * pixel), 0 * tPixel, 10 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1, 1 - (10 * pixel), 0 * tPixel, 8 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 10 * pixel, 0 * tPixel, 8 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 10 * pixel, 0 * tPixel, 10 * tPixel);
tess.addVertexWithUV(10 * pixel, 1 - (4 * pixel), 1 - (10 * pixel), 8 * tPixel, 10 * tPixel);
tess.addVertexWithUV(10 * pixel, 1, 1 - (10 * pixel), 8 * tPixel, 8 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1, 1 - (10 * pixel), 8 * tPixel, 8 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 1 - (10 * pixel), 8 * tPixel, 10 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1 - (4 * pixel), 10 * pixel, 0 * tPixel, 10 * tPixel);
tess.addVertexWithUV(1 - (10 * pixel), 1, 10 * pixel, 0 * tPixel, 8 * tPixel);
}
tess.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
if(dir == ForgeDirection.UP)
{
// ROTATE
}
else if(dir == ForgeDirection.DOWN)
GL11.glRotatef(-180, 1, 0, 0);
else if(dir == ForgeDirection.SOUTH)
GL11.glRotatef(-90, 1, 0, 0);
else if(dir == ForgeDirection.NORTH)
GL11.glRotatef(-270, 1, 0, 0);
else if(dir == ForgeDirection.WEST)
GL11.glRotatef(-90, 0, 0, 1);
else if(dir == ForgeDirection.EAST)
GL11.glRotatef(-270, 0, 0, 1);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
}
private void drawConnection(ForgeDirection dir, TileCopperWire wire)
{
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
{
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
if(dir == ForgeDirection.UP)
{
// ROTATE
}
else if(dir == ForgeDirection.DOWN)
GL11.glRotatef(180, 1, 0, 0);
else if(dir == ForgeDirection.SOUTH)
GL11.glRotatef(90, 1, 0, 0);
else if(dir == ForgeDirection.NORTH)
GL11.glRotatef(270, 1, 0, 0);
else if(dir == ForgeDirection.WEST)
GL11.glRotatef(90, 0, 0, 1);
else if(dir == ForgeDirection.EAST)
GL11.glRotatef(270, 0, 0, 1);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 1 - (12 * pixel), 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 12 * pixel, 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 1 - (12 * pixel), 11 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1, 12 * pixel, 11 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
}
tess.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
if(dir == ForgeDirection.UP)
{
// ROTATE
}
else if(dir == ForgeDirection.DOWN)
GL11.glRotatef(-180, 1, 0, 0);
else if(dir == ForgeDirection.SOUTH)
GL11.glRotatef(-90, 1, 0, 0);
else if(dir == ForgeDirection.NORTH)
GL11.glRotatef(-270, 1, 0, 0);
else if(dir == ForgeDirection.WEST)
GL11.glRotatef(-90, 0, 0, 1);
else if(dir == ForgeDirection.EAST)
GL11.glRotatef(-270, 0, 0, 1);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
}
private void drawCore(TileCopperWire tile)
{
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
{
if(tile.connections[0] == null)
{
tess.addVertexWithUV(12 * pixel, 12 * pixel, 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 12 * pixel, 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 12 * pixel, 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 1 - (12 * pixel), 0 * tPixel, 6 * tPixel);
}
if(tile.connections[1] == null)
{
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 0 * tPixel, 6 * tPixel);
}
if(tile.connections[2] == null)
{
tess.addVertexWithUV(12 * pixel, 12 * pixel, 12 * pixel, 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 12 * pixel, 0 * tPixel, 6 * tPixel);
}
if(tile.connections[3] == null)
{
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 12 * pixel, 1 - (12 * pixel), 0 * tPixel, 6 * tPixel);
}
if(tile.connections[4] == null)
{
tess.addVertexWithUV(12 * pixel, 12 * pixel, 1 - (12 * pixel), 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 1 - (12 * pixel), 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 1 - (12 * pixel), 12 * pixel, 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(12 * pixel, 12 * pixel, 12 * pixel, 0 * tPixel, 6 * tPixel);
}
if(tile.connections[5] == null)
{
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 12 * pixel, 6 * tPixel, 6 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 12 * pixel, 6 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 1 - (12 * pixel), 1 - (12 * pixel), 0 * tPixel, 0 * tPixel);
tess.addVertexWithUV(1 - (12 * pixel), 12 * pixel, 1 - (12 * pixel), 0 * tPixel, 6 * tPixel);
}
}
tess.draw();
this.texture = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockSteelWire.png");
this.texture1 = new ResourceLocation(ModInfo.PREFIX + "textures/blocks/blockInsulatedSteelWire.png");
}
}

View File

@ -14,32 +14,24 @@ package steamcraft.common.blocks.machines;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import steamcraft.client.lib.RenderIDs;
import steamcraft.common.init.InitBlocks;
import steamcraft.common.lib.DamageSourceHandler;
import steamcraft.common.tiles.energy.TileSteelWire;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author warlordjones
* @author Decebaldecebal
*
*/
public class BlockSteelWire extends BaseContainerBlock
public class BlockSteelWire extends BlockCopperWire
{
static float pixel = 1 / 16f;
@ -57,112 +49,22 @@ public class BlockSteelWire extends BaseContainerBlock
return new TileSteelWire();
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return RenderIDs.blockSteelWireRI;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack is)
{
if(!world.isRemote)
{
TileSteelWire tile = (TileSteelWire) world.getTileEntity(x, y, z);
if(tile != null)
{
tile.network = null;
tile.updateConnections();
}
}
}
@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ)
{
if(world.getBlock(tileX, tileY, tileZ) != InitBlocks.blockCopperWire)
if(world.getBlock(tileX, tileY, tileZ) != InitBlocks.blockSteelWire)
{
TileSteelWire tile = (TileSteelWire) world.getTileEntity(x, y, z);
tile.updateConnections(); // only on server
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
{
if (!world.isRemote)
{
TileSteelWire tile = (TileSteelWire) world.getTileEntity(x, y, z);
if(tile != null)
tile.removeFromNetwork();
}
super.breakBlock(world, x, y, z, block, metadata);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
return this.getBoundingBox(world, x, y, z);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return this.getBoundingBox(world, x, y, z);
}
private AxisAlignedBB getBoundingBox(World world, int x, int y, int z)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileSteelWire wire = null;
if(tile instanceof TileSteelWire)
{
wire = (TileSteelWire) tile;
}
if(wire != null)
{
float minX = (6 * pixel) - (wire.connections[4] != null ? 6 * pixel : 0);
float maxX = (1 - (6 * pixel)) + (wire.connections[5] != null ? 6 * pixel : 0);
float minY = (6 * pixel) - (wire.connections[0] != null ? 6 * pixel : 0);
float maxY = (1 - (6 * pixel)) + (wire.connections[1] != null ? 6 * pixel : 0);
float minZ = (6 * pixel) - (wire.connections[2] != null ? 6 * pixel : 0);
float maxZ = (1 - (6 * pixel)) + (wire.connections[3] != null ? 6 * pixel : 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);
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
if(world.getBlockMetadata(x, y, z) == 0)
{
TileSteelWire wire = (TileSteelWire) world.getTileEntity(x, y, z);
if(wire.getEnergyStored(ForgeDirection.UNKNOWN) != 0)
entity.attackEntityFrom(DamageSourceHandler.electrocution, 0.5F);
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
@ -171,16 +73,4 @@ public class BlockSteelWire extends BaseContainerBlock
l.add(new ItemStack(InitBlocks.blockSteelWire, 1, 0));
l.add(new ItemStack(InitBlocks.blockSteelWire, 1, 1));
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player)
{
return new ItemStack(world.getBlock(x, y, z), 1, world.getBlockMetadata(x, y, z));
}
@Override
public int damageDropped(int meta)
{
return meta;
}
}

View File

@ -18,12 +18,10 @@ import steamcraft.common.packets.CopperPipePacket;
import steamcraft.common.packets.CopperPipePacket.CopperPipePacketHandler;
import steamcraft.common.packets.CopperTankPacket;
import steamcraft.common.packets.CopperTankPacket.CopperTankPacketHandler;
import steamcraft.common.packets.CopperWirePacket;
import steamcraft.common.packets.CopperWirePacket.CopperWirePacketHandler;
import steamcraft.common.packets.WirePacket;
import steamcraft.common.packets.WirePacket.WirePacketHandler;
import steamcraft.common.packets.OpenContainerFromClientPacket;
import steamcraft.common.packets.OpenContainerFromClientPacket.OpenContainerFromClientPacketHandler;
import steamcraft.common.packets.SteelWirePacket;
import steamcraft.common.packets.SteelWirePacket.SteelWirePacketHandler;
import steamcraft.common.packets.TimeBombPacket;
import steamcraft.common.packets.TimeBombPacket.TimeBombPacketHandler;
import steamcraft.common.packets.UpdateClientsideInventoryPacket;
@ -52,11 +50,8 @@ public class InitPackets
network.registerMessage(CopperPipePacketHandler.class, CopperPipePacket.class, packetId++, Side.CLIENT);
network.registerMessage(FluidNetworkPacketHandler.class, CopperPipeFluidPacket.class, packetId++, Side.CLIENT);
network.registerMessage(CopperTankPacketHandler.class, CopperTankPacket.class, packetId++, Side.CLIENT);
network.registerMessage(CopperWirePacketHandler.class, CopperWirePacket.class, packetId++, Side.CLIENT);
network.registerMessage(SteelWirePacketHandler.class, SteelWirePacket.class, packetId++, Side.CLIENT);
network.registerMessage(WirePacketHandler.class, WirePacket.class, packetId++, Side.CLIENT);
network.registerMessage(UpdateClientsideInventoryPacketHandler.class, UpdateClientsideInventoryPacket.class, packetId++, Side.CLIENT);
}
}

View File

@ -53,7 +53,7 @@ public class ItemSpanner extends UniversalWrench
pipe.changeExtracting();
}
else if(block == InitBlocks.blockCopperWire)
else if(block == InitBlocks.blockCopperWire || block == InitBlocks.blockSteelWire)
{
TileCopperWire wire = (TileCopperWire) world.getTileEntity(x, y, z);

View File

@ -1,106 +0,0 @@
/**
* This class was created by BrassGoggledCoders modding team.
* This class is available as part of the Steamcraft 2 Mod for Minecraft.
*
* Steamcraft 2 is open-source and is distributed under the MMPL v1.0 License.
* (http://www.mod-buildcraft.com/MMPL-1.0.txt)
*
* Steamcraft 2 is based on the original Steamcraft Mod created by Proloe.
* Steamcraft (c) Proloe 2011
* (http://www.minecraftforum.net/topic/251532-181-steamcraft-source-code-releasedmlv054wip/)
*
*/
package steamcraft.common.packets;
import io.netty.buffer.ByteBuf;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import steamcraft.common.tiles.energy.TileCopperWire;
import boilerplate.client.ClientHelper;
/**
* @author decebaldecebal
*
*/
public class CopperWirePacket implements IMessage
{
private int x, y, z;
ForgeDirection[] connections;
ForgeDirection extract;
public CopperWirePacket()
{
} // REQUIRED
public CopperWirePacket(int x, int y, int z, ForgeDirection[] connections, ForgeDirection extract)
{
this.x = x;
this.y = y;
this.z = z;
this.connections = connections;
this.extract = extract;
}
@Override
public void fromBytes(ByteBuf buf)
{
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.connections = new ForgeDirection[6];
for(int i = 0; i < 6; i++)
{
this.connections[i] = ForgeDirection.getOrientation(buf.readByte());
if(this.connections[i] == ForgeDirection.UNKNOWN)
this.connections[i] = null;
}
this.extract = ForgeDirection.getOrientation(buf.readByte());
if(this.extract == ForgeDirection.UNKNOWN)
this.extract = null;
}
@Override
public void toBytes(ByteBuf buf)
{
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
for(int i = 0; i < 6; i++)
buf.writeByte(CopperPipePacket.directionToByte(this.connections[i]));
buf.writeByte(CopperPipePacket.directionToByte(this.extract));
}
public static class CopperWirePacketHandler implements IMessageHandler<CopperWirePacket, IMessage>
{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(CopperWirePacket message, MessageContext ctx)
{
World world = ClientHelper.world();
if(world.getTileEntity(message.x, message.y, message.z) instanceof TileCopperWire)
{
TileCopperWire wire = (TileCopperWire) world.getTileEntity(message.x, message.y, message.z);
wire.connections = message.connections;
wire.extract = message.extract;
}
return null;
}
}
}

View File

@ -31,17 +31,17 @@ import boilerplate.client.ClientHelper;
* @author decebaldecebal
*
*/
public class SteelWirePacket implements IMessage
public class WirePacket implements IMessage
{
private int x, y, z;
ForgeDirection[] connections;
ForgeDirection extract;
public SteelWirePacket()
public WirePacket()
{
} // REQUIRED
public SteelWirePacket(int x, int y, int z, ForgeDirection[] connections, ForgeDirection extract)
public WirePacket(int x, int y, int z, ForgeDirection[] connections, ForgeDirection extract)
{
this.x = x;
this.y = y;
@ -84,11 +84,11 @@ public class SteelWirePacket implements IMessage
}
public static class SteelWirePacketHandler implements IMessageHandler<SteelWirePacket, IMessage>
public static class WirePacketHandler implements IMessageHandler<WirePacket, IMessage>
{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(SteelWirePacket message, MessageContext ctx)
public IMessage onMessage(WirePacket message, MessageContext ctx)
{
World world = ClientHelper.world();

View File

@ -24,7 +24,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import steamcraft.common.init.InitBlocks;
import steamcraft.common.init.InitPackets;
import steamcraft.common.packets.CopperWirePacket;
import steamcraft.common.packets.WirePacket;
import steamcraft.common.tiles.TileCopperPipe.Coords;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyConnection;
@ -38,14 +38,21 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
*
*/
public class TileCopperWire extends TileEntity implements IEnergyHandler
{
{
private static int copperWireCapacity = 5000;
private static int copperWireTransfer = 1000;
protected int wireCapacity = copperWireCapacity;
protected int wireTransfer = copperWireTransfer;
public EnergyNetwork network;
private boolean isMaster = false;
public ForgeDirection extract = null;
public ForgeDirection[] connections = new ForgeDirection[6];
private Coords masterCoords = null;
@Override
public void updateEntity()
{
@ -121,7 +128,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
if(this.isMaster)
{
this.network = EnergyNetwork.readFromNBT(tag);
this.network = EnergyNetwork.readFromNBT(tag, this.wireCapacity, this.wireTransfer);
this.setMaster(this);
}
}
@ -307,7 +314,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
System.out.print(this.xCoord + " " + this.yCoord + " " + this.zCoord);
System.out.println("This network null, creating a new one.");
this.network = new EnergyNetwork(1);
this.network = new EnergyNetwork(1, this.wireCapacity, this.wireTransfer);
this.setMaster(this);
}
@ -336,7 +343,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
{
if((this.network != null) && !this.worldObj.isRemote)
{
InitPackets.network.sendToAllAround(new CopperWirePacket(this.xCoord, this.yCoord, this.zCoord, this.connections, this.extract),
InitPackets.network.sendToAllAround(new WirePacket(this.xCoord, this.yCoord, this.zCoord, this.connections, this.extract),
new TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 100));
}
}
@ -469,7 +476,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
for(ForgeDirection dir : this.connections)
if(dir != null)
if(this.isCopperWire(dir))
if(this.isWire(dir))
{
TileCopperWire wire = (TileCopperWire) this.worldObj.getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY,
this.zCoord + dir.offsetZ);
@ -479,7 +486,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
wire.network.setSize(0);
wire.network = new EnergyNetwork(1);
wire.network = new EnergyNetwork(1, this.wireCapacity, this.wireTransfer);
wire.setMaster(wire);
if(this.network != null)
{
@ -521,19 +528,24 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
private boolean canConnect(ForgeDirection dir)
{
return this.isEnergyHandler(dir) || this.isCopperWire(dir);
return this.isEnergyHandler(dir) || this.isWire(dir);
}
private boolean isCopperWire(ForgeDirection dir)
protected boolean isWire(ForgeDirection dir)
{
return this.worldObj.getBlock(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ) == InitBlocks.blockCopperWire;
}
private boolean isEnergyHandler(ForgeDirection dir)
protected boolean isEnergyHandler(ForgeDirection dir)
{
return (this.worldObj.getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ) instanceof IEnergyConnection)
&& ((IEnergyConnection) this.worldObj.getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ))
.canConnectEnergy(dir.getOpposite()) && !this.isCopperWire(dir);
.canConnectEnergy(dir.getOpposite()) && !this.isWire(dir) && !this.isSteelWire(dir);
}
protected boolean isSteelWire(ForgeDirection dir)
{
return this.worldObj.getBlock(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ) == InitBlocks.blockSteelWire;
}
@Override
@ -547,7 +559,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
{
if((from != this.extract) && (this.network != null)) //should actively receive energy from where it is not actively pulling
{
int amount = Math.min(maxReceive, EnergyNetwork.maxTransferPerTile);
int amount = Math.min(maxReceive, wireTransfer);
return this.network.buffer.receiveEnergy(amount, simulate);
}
@ -560,7 +572,7 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
{
if((from != this.extract) && (this.network != null))
{
int amount = Math.min(maxExtract, EnergyNetwork.maxTransferPerTile);
int amount = Math.min(maxExtract, wireTransfer);
return this.network.buffer.extractEnergy(amount, simulate);
}
@ -588,9 +600,8 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
private static class EnergyNetwork
{
private static final short capacityPerWire = (short) 5000;
private static final short maxTransferPerTile = 1000;
private int capacityPerWire;
private int maxTransferPerTile;
private boolean updateNetworkForWires = false;
@ -601,11 +612,13 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
private ArrayList<Coords> inputs = new ArrayList<Coords>();
private ArrayList<Coords> outputs = new ArrayList<Coords>();
private EnergyNetwork(int size)
private EnergyNetwork(int size, int wireCapacity, int wireTransfer)
{
this.size = size;
this.buffer = new EnergyStorage(capacityPerWire * size, maxTransferPerTile);
this.capacityPerWire = wireCapacity;
this.maxTransferPerTile = wireTransfer;
this.buffer = new EnergyStorage(wireCapacity * size, maxTransferPerTile);
}
private void updateNetwork(TileCopperWire wire)
@ -707,11 +720,11 @@ public class TileCopperWire extends TileEntity implements IEnergyHandler
tag.setTag("network", temp);
}
private static EnergyNetwork readFromNBT(NBTTagCompound tag)
private static EnergyNetwork readFromNBT(NBTTagCompound tag, int wireCapacity, int wireTransfer)
{
NBTTagCompound temp = tag.getCompoundTag("network");
EnergyNetwork network = new EnergyNetwork(1);
EnergyNetwork network = new EnergyNetwork(1, wireCapacity, wireTransfer);
network.updateNetworkForWires = true;
network.tempEnergy = temp.getInteger("energyLevel");

View File

@ -12,11 +12,36 @@
*/
package steamcraft.common.tiles.energy;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyConnection;
/**
* @author decebaldecebal
*
*/
public class TileSteelWire extends TileCopperWire
{
private static int steelWireCapacity = 40000;
private static int steelWireTransfer = 10000;
public TileSteelWire()
{
super();
this.wireCapacity = steelWireCapacity;
this.wireTransfer = steelWireTransfer;
}
@Override
protected boolean isWire(ForgeDirection dir)
{
return this.isSteelWire(dir);
}
@Override
protected boolean isEnergyHandler(ForgeDirection dir)
{
return (this.worldObj.getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ) instanceof IEnergyConnection)
&& ((IEnergyConnection) this.worldObj.getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ))
.canConnectEnergy(dir.getOpposite()) && !this.isSteelWire(dir) && !super.isWire(dir);
}
}

View File

@ -143,6 +143,11 @@ tile.blockCopperWire.desc=Right-Click with Spanner to change to extracting (pull
tile.blockCopperWire.1.name=Insulated Copper Wire
tile.blockCopperWire.1.desc=Right-Click with Spanner to change to extracting (pulling out energy) mode.|Won't electrocute you.|Transfer: 1000 RF/t per connection
tile.blockSteelWire.0.name=Steel Wire
tile.blockSteelWire.desc=Right-Click with Spanner to change to extracting (pulling out energy) mode. Electrocutes you if you step on it while current is flowing.|Transfer: 10000 RF/t per connection
tile.blockSteelWire.1.name=Insulated Steel Wire
tile.blockSteelWire.1.desc=Right-Click with Spanner to change to extracting (pulling out energy) mode.|Won't electrocute you.|Transfer: 10000 RF/t per connection
tile.blockBloomery.name=Bloomery
tile.blockBloomery.desc=Smelts one iron ingot and 4 coal into steel. Iron ingots and coal go in the top slots and fuel goes in the bottom slot.
tile.blockSteamBoiler.name=Combustion Boiler

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B