diff --git a/minecraft/liquidmechanics/api/helpers/connectionHelper.java b/minecraft/liquidmechanics/api/helpers/connectionHelper.java index 01476847f..16a2d43e4 100644 --- a/minecraft/liquidmechanics/api/helpers/connectionHelper.java +++ b/minecraft/liquidmechanics/api/helpers/connectionHelper.java @@ -1,5 +1,6 @@ package liquidmechanics.api.helpers; +import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; @@ -10,45 +11,62 @@ import universalelectricity.core.vector.Vector3; public class connectionHelper { - /** - * Used to find all tileEntities sounding the location you will have to filter for selective - * tileEntities - * - * @param world - the world being searched threw - * @param x - * @param y - * @param z - * @return an array of up to 6 tileEntities - */ - public static TileEntity[] getSurroundings(World world, int x, int y, int z) - { - TileEntity[] list = new TileEntity[] { null, null, null, null, null, null }; - for (int i = 0; i < 6; i++) - { - ForgeDirection d = ForgeDirection.getOrientation(i); - TileEntity aEntity = world.getBlockTileEntity(x + d.offsetX, y + d.offsetY, z + d.offsetZ); - if (aEntity instanceof TileEntity) - { - list[i] = aEntity; - } - } - return list; - } + /** Used to find all tileEntities sounding the location you will have to + * filter for selective tileEntities + * + * @param world + * - the world being searched threw + * @param x + * @param y + * @param z + * @return an array of up to 6 tileEntities */ + public static TileEntity[] getSurroundingTileEntities(TileEntity ent) + { + return getSurroundingTileEntities(ent.worldObj, ent.xCoord, ent.yCoord, ent.zCoord); - /** - * Used to find which of 4 Corners this block is in a group of blocks - * 0 = not a corner - * 1-4 = a corner of some direction - */ - public static int corner(TileEntity entity) - { - TileEntity[] en = getSurroundings(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord); - if (en[4] != null && en[2] != null && en[5] == null && en[3] == null) { return 3; } - if (en[2] != null && en[5] != null && en[3] == null && en[4] == null) { return 4; } - if (en[5] != null && en[3] != null && en[4] == null && en[2] == null) { return 1; } - if (en[3] != null && en[4] != null && en[2] == null && en[5] == null) { return 2; } + } - return 0; + public static TileEntity[] getSurroundingTileEntities(World world, int x, int y, int z) + { + TileEntity[] list = new TileEntity[] { null, null, null, null, null, null }; + for (int i = 0; i < 6; i++) + { + ForgeDirection d = ForgeDirection.getOrientation(i); + TileEntity aEntity = world.getBlockTileEntity(x + d.offsetX, y + d.offsetY, z + d.offsetZ); + if (aEntity instanceof TileEntity) + { + list[i] = aEntity; + } + } + return list; + } + public static int[] getSurroundingBlocks(TileEntity ent) + { + return getSurroundingBlocks(ent.worldObj, ent.xCoord, ent.yCoord, ent.zCoord); + } + public static int[] getSurroundingBlocks(World world, int x, int y, int z) + { + int[] list = new int[6]; + for (int i = 0; i < 6; i++) + { + ForgeDirection d = ForgeDirection.getOrientation(i); + int id = world.getBlockId(x + d.offsetX, y + d.offsetY, z + d.offsetZ); + list[i] = id; + } + return list; + } - } + /** Used to find which of 4 Corners this block is in a group of blocks 0 = + * not a corner 1-4 = a corner of some direction */ + public static int corner(TileEntity entity) + { + TileEntity[] en = getSurroundingTileEntities(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord); + if (en[4] != null && en[2] != null && en[5] == null && en[3] == null) { return 3; } + if (en[2] != null && en[5] != null && en[3] == null && en[4] == null) { return 4; } + if (en[5] != null && en[3] != null && en[4] == null && en[2] == null) { return 1; } + if (en[3] != null && en[4] != null && en[2] == null && en[5] == null) { return 2; } + + return 0; + + } } diff --git a/minecraft/liquidmechanics/client/ClientProxy.java b/minecraft/liquidmechanics/client/ClientProxy.java index d4639d6cc..bc1686693 100644 --- a/minecraft/liquidmechanics/client/ClientProxy.java +++ b/minecraft/liquidmechanics/client/ClientProxy.java @@ -1,16 +1,19 @@ package liquidmechanics.client; import liquidmechanics.client.render.BlockRenderHelper; +import liquidmechanics.client.render.ItemRenderHelper; import liquidmechanics.client.render.RenderGearRod; import liquidmechanics.client.render.RenderGenerator; import liquidmechanics.client.render.RenderPipe; import liquidmechanics.client.render.RenderPump; +import liquidmechanics.client.render.RenderReleaseValve; import liquidmechanics.client.render.RenderTank; import liquidmechanics.common.CommonProxy; import liquidmechanics.common.LiquidMechanics; import liquidmechanics.common.tileentity.TileEntityGenerator; import liquidmechanics.common.tileentity.TileEntityPipe; import liquidmechanics.common.tileentity.TileEntityPump; +import liquidmechanics.common.tileentity.TileEntityReleaseValve; import liquidmechanics.common.tileentity.TileEntityRod; import liquidmechanics.common.tileentity.TileEntityTank; import net.minecraftforge.client.MinecraftForgeClient; @@ -34,6 +37,9 @@ public class ClientProxy extends CommonProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRod.class, new RenderGearRod()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGenerator.class, new RenderGenerator()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTank.class, new RenderTank()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityReleaseValve.class, new RenderReleaseValve()); + MinecraftForgeClient.registerItemRenderer(LiquidMechanics.blockPipe.blockID, new ItemRenderHelper()); + MinecraftForgeClient.registerItemRenderer(LiquidMechanics.blockReleaseValve.blockID, new ItemRenderHelper()); RenderingRegistry.registerBlockHandler(new BlockRenderHelper()); } diff --git a/minecraft/liquidmechanics/client/gui/GuiReleaseValve.java b/minecraft/liquidmechanics/client/gui/GuiReleaseValve.java index 3bd528487..61864d546 100644 --- a/minecraft/liquidmechanics/client/gui/GuiReleaseValve.java +++ b/minecraft/liquidmechanics/client/gui/GuiReleaseValve.java @@ -55,7 +55,7 @@ public class GuiReleaseValve extends GuiContainer protected void drawGuiContainerForegroundLayer(int par1, int par2) { GL11.glDisable(GL11.GL_LIGHTING); - this.fontRenderer.drawString(StatCollector.translateToLocal("container.repair"), 60, 6, 4210752); + this.fontRenderer.drawString("Release Valve", 60, 6, 4210752); diff --git a/minecraft/liquidmechanics/client/model/ModelReleaseValve.java b/minecraft/liquidmechanics/client/model/ModelReleaseValve.java new file mode 100644 index 000000000..c1646c880 --- /dev/null +++ b/minecraft/liquidmechanics/client/model/ModelReleaseValve.java @@ -0,0 +1,136 @@ +// Date: 1/7/2013 12:20:13 PM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package liquidmechanics.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraftforge.common.ForgeDirection; + +public class ModelReleaseValve extends ModelBase +{ + + // fields + ModelRenderer ValveStem; + ModelRenderer ValveWheelCenter; + ModelRenderer ValveRest; + ModelRenderer WheelBar3; + ModelRenderer WheelBar4; + ModelRenderer Wheel; + ModelRenderer Wheel2; + ModelRenderer Wheel3; + ModelRenderer Wheel4; + ModelRenderer WheelB; + ModelRenderer WheelB2; + ModelRenderer WheelB3; + ModelRenderer WheelB4; + ModelRenderer[] renders; + + public ModelReleaseValve() + { + textureWidth = 128; + textureHeight = 32; + + ValveStem = new ModelRenderer(this, 50, 21); + ValveStem.addBox(-1F, -6F, -1F, 2, 3, 2); + ValveStem.setRotationPoint(0F, 16F, 0F); + ValveStem.setTextureSize(128, 32); + ValveStem.mirror = true; + setRotation(ValveStem, 0F, 0F, 0F); + ValveWheelCenter = new ModelRenderer(this, 50, 17); + ValveWheelCenter.addBox(-0.5F, -7.5F, -0.5F, 1, 2, 1); + ValveWheelCenter.setRotationPoint(0F, 16F, 0F); + ValveWheelCenter.setTextureSize(128, 32); + ValveWheelCenter.mirror = true; + setRotation(ValveWheelCenter, 0F, 0F, 0F); + ValveRest = new ModelRenderer(this, 50, 27); + ValveRest.addBox(-1.5F, -4F, -1.5F, 3, 1, 3); + ValveRest.setRotationPoint(0F, 16F, 0F); + ValveRest.setTextureSize(128, 32); + ValveRest.mirror = true; + setRotation(ValveRest, 0F, 0F, 0F); + WheelBar3 = new ModelRenderer(this, 85, 15); + WheelBar3.addBox(-3F, -7F, -0.5F, 6, 1, 1); + WheelBar3.setRotationPoint(0F, 16F, 0F); + WheelBar3.setTextureSize(128, 32); + WheelBar3.mirror = true; + setRotation(WheelBar3, 0F, 0.7853982F, 0F); + WheelBar4 = new ModelRenderer(this, 85, 18); + WheelBar4.addBox(-3F, -7F, -0.5F, 6, 1, 1); + WheelBar4.setRotationPoint(0F, 16F, 0F); + WheelBar4.setTextureSize(128, 32); + WheelBar4.mirror = true; + setRotation(WheelBar4, 0F, -0.7853982F, 0F); + Wheel = new ModelRenderer(this, 50, 13); + Wheel.addBox(-1.5F, -7.5F, -3.5F, 3, 1, 1); + Wheel.setRotationPoint(0F, 16F, 0F); + Wheel.setTextureSize(128, 32); + Wheel.mirror = true; + setRotation(Wheel, 0F, -0.7853982F, 0F); + Wheel2 = new ModelRenderer(this, 50, 13); + Wheel2.addBox(-1.5F, -7.5F, -3.5F, 3, 1, 1); + Wheel2.setRotationPoint(0F, 16F, 0F); + Wheel2.setTextureSize(128, 32); + Wheel2.mirror = true; + setRotation(Wheel2, 0F, 2.356194F, 0F); + Wheel3 = new ModelRenderer(this, 50, 13); + Wheel3.addBox(-1.5F, -7.5F, -3.5F, 3, 1, 1); + Wheel3.setRotationPoint(0F, 16F, 0F); + Wheel3.setTextureSize(128, 32); + Wheel3.mirror = true; + setRotation(Wheel3, 0F, -2.356194F, 0F); + Wheel4 = new ModelRenderer(this, 50, 13); + Wheel4.addBox(-1.5F, -7.5F, -3.5F, 3, 1, 1); + Wheel4.setRotationPoint(0F, 16F, 0F); + Wheel4.setTextureSize(128, 32); + Wheel4.mirror = true; + setRotation(Wheel4, 0F, 0.7853982F, 0F); + WheelB = new ModelRenderer(this, 50, 13); + WheelB.addBox(-1.5F, -7.5F, 2.5F, 3, 1, 1); + WheelB.setRotationPoint(0F, 16F, 0F); + WheelB.setTextureSize(128, 32); + WheelB.mirror = true; + setRotation(WheelB, 0F, -3.141593F, 0F); + WheelB2 = new ModelRenderer(this, 50, 13); + WheelB2.addBox(-1.5F, -7.5F, 2.5F, 3, 1, 1); + WheelB2.setRotationPoint(0F, 16F, 0F); + WheelB2.setTextureSize(128, 32); + WheelB2.mirror = true; + setRotation(WheelB2, 0F, 0F, 0F); + WheelB3 = new ModelRenderer(this, 50, 13); + WheelB3.addBox(-1.5F, -7.5F, 2.5F, 3, 1, 1); + WheelB3.setRotationPoint(0F, 16F, 0F); + WheelB3.setTextureSize(128, 32); + WheelB3.mirror = true; + setRotation(WheelB3, 0F, 1.570796F, 0F); + WheelB4 = new ModelRenderer(this, 50, 13); + WheelB4.addBox(-1.5F, -7.5F, 2.5F, 3, 1, 1); + WheelB4.setRotationPoint(0F, 16F, 0F); + WheelB4.setTextureSize(128, 32); + WheelB4.mirror = true; + setRotation(WheelB4, 0F, -1.570796F, 0F); + renders = new ModelRenderer[] { ValveStem, ValveWheelCenter, ValveRest, WheelBar3, WheelBar4, Wheel, Wheel2, Wheel3, Wheel4, WheelB, WheelB2, WheelB3, WheelB4 }; + + } + + public void render() + { + ModelRenderer[] renderSet = renders; + for(int i = 0; i < renders.length;i++) + { + renderSet[i].render(0.0625F); + } + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/minecraft/liquidmechanics/client/render/BlockRenderHelper.java b/minecraft/liquidmechanics/client/render/BlockRenderHelper.java index effaf34c8..3abd0fdc6 100644 --- a/minecraft/liquidmechanics/client/render/BlockRenderHelper.java +++ b/minecraft/liquidmechanics/client/render/BlockRenderHelper.java @@ -1,14 +1,18 @@ package liquidmechanics.client.render; +import liquidmechanics.api.helpers.connectionHelper; import liquidmechanics.client.model.ModelGearRod; import liquidmechanics.client.model.ModelGenerator; import liquidmechanics.client.model.ModelLargePipe; import liquidmechanics.client.model.ModelLiquidTank; import liquidmechanics.client.model.ModelPump; +import liquidmechanics.client.model.ModelReleaseValve; import liquidmechanics.common.LiquidMechanics; +import liquidmechanics.common.tileentity.TileEntityReleaseValve; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -25,6 +29,7 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler private ModelGenerator modelGen = new ModelGenerator(); private ModelLargePipe SixPipe = new ModelLargePipe(); private ModelLiquidTank tank = new ModelLiquidTank(); + private ModelReleaseValve valve = new ModelReleaseValve(); @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) @@ -41,17 +46,14 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler modelPump.renderC3(0.0725F); GL11.glPopMatrix(); } - if (block.blockID == LiquidMechanics.blockPipe.blockID) - { - this.renderPipeItem(renderer, metadata); - } if (block.blockID == LiquidMechanics.blockTank.blockID) { GL11.glPushMatrix(); GL11.glTranslatef((float) 0.0F, (float) 1.1F, (float) 0.0F); - GL11.glRotatef(180f, 0f, 0f, 1f); + GL11.glRotatef(180f, 0f, 0f, 1f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderTank.getTankTexture(metadata))); tank.renderMain(0.0625F); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderTank.getGuageTexture(metadata,4))); tank.renderMeter(null, 0.0625F); GL11.glPopMatrix(); } diff --git a/minecraft/liquidmechanics/client/render/ItemRenderHelper.java b/minecraft/liquidmechanics/client/render/ItemRenderHelper.java new file mode 100644 index 000000000..652c49425 --- /dev/null +++ b/minecraft/liquidmechanics/client/render/ItemRenderHelper.java @@ -0,0 +1,112 @@ +package liquidmechanics.client.render; + +import liquidmechanics.client.model.ModelGearRod; +import liquidmechanics.client.model.ModelGenerator; +import liquidmechanics.client.model.ModelLargePipe; +import liquidmechanics.client.model.ModelLiquidTank; +import liquidmechanics.client.model.ModelPump; +import liquidmechanics.client.model.ModelReleaseValve; +import liquidmechanics.common.LiquidMechanics; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.common.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +/** special tanks to Mekanism github */ +public class ItemRenderHelper implements IItemRenderer +{ + private ModelPump modelPump = new ModelPump(); + private ModelGearRod modelRod = new ModelGearRod(); + private ModelGenerator modelGen = new ModelGenerator(); + private ModelLargePipe SixPipe = new ModelLargePipe(); + private ModelLiquidTank tank = new ModelLiquidTank(); + private ModelReleaseValve valve = new ModelReleaseValve(); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) + { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) + { + if (item.itemID == LiquidMechanics.blockPipe.blockID) + { + this.renderPipeItem((RenderBlocks) data[0], item.getItemDamage(), type == ItemRenderType.EQUIPPED); + } + if (item.itemID == LiquidMechanics.blockReleaseValve.blockID) + { + this.renderReleaseValve((RenderBlocks) data[0], item.getItemDamage(), type == ItemRenderType.EQUIPPED); + } + + } + + public void renderPipeItem(RenderBlocks renderer, int meta, boolean equ) + { + + GL11.glPushMatrix(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderPipe.getPipeTexture(meta))); + + if (!equ) + { + GL11.glTranslatef(0.5F, -0.5F, 0.5F); + SixPipe.renderRight(); + SixPipe.renderLeft(); + SixPipe.renderMiddle(); + } + else + { + GL11.glTranslatef(0.5F, -0.5F, 0.5F); + SixPipe.renderFront(); + SixPipe.renderBack(); + SixPipe.renderMiddle(); + } + + GL11.glPopMatrix(); + } + + public void renderReleaseValve(RenderBlocks renderer, int meta, boolean equ) + { + GL11.glPushMatrix(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(RenderPipe.getPipeTexture(15))); + if (!equ) + { + GL11.glTranslatef(0.5F, -0.5F, 0.5F); + SixPipe.renderRight(); + SixPipe.renderLeft(); + SixPipe.renderMiddle(); + } + else + { + GL11.glTranslatef(0.5F, -0.5F, 0.5F); + SixPipe.renderFront(); + SixPipe.renderBack(); + SixPipe.renderMiddle(); + } + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(LiquidMechanics.RESOURCE_PATH + "ReleaseValve.png")); + GL11.glRotatef(180f, 0f, 0f, 1f); + if (!equ) + { + GL11.glTranslatef(0, -2.0F, 0); + } + else + { + GL11.glTranslatef(0, -2.0F, 0); + } + valve.render(); + GL11.glPopMatrix(); + } + +} diff --git a/minecraft/liquidmechanics/client/render/RenderGearRod.java b/minecraft/liquidmechanics/client/render/RenderGearRod.java index ca7abb8e3..e3e57006f 100644 --- a/minecraft/liquidmechanics/client/render/RenderGearRod.java +++ b/minecraft/liquidmechanics/client/render/RenderGearRod.java @@ -45,7 +45,6 @@ public class RenderGearRod extends TileEntitySpecialRenderer case 1: GL11.glRotatef(-90f, 1f, 0f, 0f); break; - case 2: GL11.glRotatef(0f, 0f, 1f, 0f); break; diff --git a/minecraft/liquidmechanics/client/render/RenderReleaseValve.java b/minecraft/liquidmechanics/client/render/RenderReleaseValve.java new file mode 100644 index 000000000..2eb46e703 --- /dev/null +++ b/minecraft/liquidmechanics/client/render/RenderReleaseValve.java @@ -0,0 +1,68 @@ +package liquidmechanics.client.render; + +import liquidmechanics.api.helpers.ColorCode; +import liquidmechanics.api.helpers.connectionHelper; +import liquidmechanics.client.model.ModelLargePipe; +import liquidmechanics.client.model.ModelReleaseValve; +import liquidmechanics.common.LiquidMechanics; +import liquidmechanics.common.tileentity.TileEntityReleaseValve; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +public class RenderReleaseValve extends TileEntitySpecialRenderer +{ + private ModelLargePipe SixPipe; + private ModelReleaseValve valve; + private TileEntity[] ents = new TileEntity[6]; + + public RenderReleaseValve() + { + SixPipe = new ModelLargePipe(); + valve = new ModelReleaseValve(); + } + + public void renderAModelAt(TileEntity te, double d, double d1, double d2, float f) + { + // Texture file + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + ForgeDirection dir = ForgeDirection.UNKNOWN; + if (te instanceof TileEntityReleaseValve) + { + ents = ((TileEntityReleaseValve) te).connected; + } + bindTextureByName(this.getPipeTexture(15)); + if (ents[0] != null) + SixPipe.renderBottom(); + if (ents[1] != null) + SixPipe.renderTop(); + if (ents[3] != null) + SixPipe.renderFront(); + if (ents[2] != null) + SixPipe.renderBack(); + if (ents[5] != null) + SixPipe.renderRight(); + if (ents[4] != null) + SixPipe.renderLeft(); + SixPipe.renderMiddle(); + bindTextureByName(LiquidMechanics.RESOURCE_PATH + "ReleaseValve.png"); + if(ents[1] == null)valve.render(); + GL11.glPopMatrix(); + + } + + public static String getPipeTexture(int meta) + { + return LiquidMechanics.RESOURCE_PATH + "pipes/" + ColorCode.get(meta).getName() + "Pipe.png"; + } + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) + { + this.renderAModelAt(tileEntity, var2, var4, var6, var8); + } +} \ No newline at end of file diff --git a/minecraft/liquidmechanics/client/render/RenderRotation.java b/minecraft/liquidmechanics/client/render/RenderRotation.java new file mode 100644 index 000000000..499fa41cb --- /dev/null +++ b/minecraft/liquidmechanics/client/render/RenderRotation.java @@ -0,0 +1,21 @@ +package liquidmechanics.client.render; + +import org.lwjgl.opengl.GL11; + +import net.minecraftforge.common.ForgeDirection; + +public class RenderRotation +{ + float angle; + float x; + float y; + float z; + public RenderRotation(float angle, float x, float y, float z) + { + this.angle = angle; + this.x = x; + this.y = y; + this.z = z; + + } +} diff --git a/minecraft/liquidmechanics/common/LiquidMechanics.java b/minecraft/liquidmechanics/common/LiquidMechanics.java index fa2f8c979..2065c648d 100644 --- a/minecraft/liquidmechanics/common/LiquidMechanics.java +++ b/minecraft/liquidmechanics/common/LiquidMechanics.java @@ -17,6 +17,7 @@ import liquidmechanics.common.item.ItemLiquidMachine; import liquidmechanics.common.item.ItemParts; import liquidmechanics.common.item.ItemParts.Parts; import liquidmechanics.common.item.ItemPipe; +import liquidmechanics.common.item.ItemReleaseValve; import liquidmechanics.common.item.ItemTank; import liquidmechanics.common.tileentity.TileEntityGenerator; import liquidmechanics.common.tileentity.TileEntityPipe; @@ -133,7 +134,7 @@ public class LiquidMechanics extends DummyModContainer // block registry GameRegistry.registerBlock(blockPipe, ItemPipe.class, "lmPipe"); - GameRegistry.registerBlock(blockReleaseValve, "eValve"); + GameRegistry.registerBlock(blockReleaseValve,ItemReleaseValve.class, "eValve"); GameRegistry.registerBlock(blockRod, "mechRod"); GameRegistry.registerBlock(blockGenerator, "lmGen"); GameRegistry.registerBlock(blockMachine, ItemLiquidMachine.class, "lmMachines"); diff --git a/minecraft/liquidmechanics/common/MetaGroup.java b/minecraft/liquidmechanics/common/MetaGroup.java index 78f05a295..d6327aaf5 100644 --- a/minecraft/liquidmechanics/common/MetaGroup.java +++ b/minecraft/liquidmechanics/common/MetaGroup.java @@ -1,5 +1,7 @@ package liquidmechanics.common; +import net.minecraftforge.common.ForgeDirection; + public class MetaGroup { public static int getFacingMeta(int metaData) @@ -41,5 +43,5 @@ public class MetaGroup { return grouping * 4; } - + } \ No newline at end of file diff --git a/minecraft/liquidmechanics/common/block/BlockPipe.java b/minecraft/liquidmechanics/common/block/BlockPipe.java index 122e0dc1c..cd4843968 100644 --- a/minecraft/liquidmechanics/common/block/BlockPipe.java +++ b/minecraft/liquidmechanics/common/block/BlockPipe.java @@ -40,7 +40,7 @@ public class BlockPipe extends BlockMachine @Override public int getRenderType() { - return BlockRenderHelper.renderID; + return -1; } /** diff --git a/minecraft/liquidmechanics/common/block/BlockReleaseValve.java b/minecraft/liquidmechanics/common/block/BlockReleaseValve.java index 76195297c..28af35e87 100644 --- a/minecraft/liquidmechanics/common/block/BlockReleaseValve.java +++ b/minecraft/liquidmechanics/common/block/BlockReleaseValve.java @@ -2,6 +2,7 @@ package liquidmechanics.common.block; import java.util.Random; +import liquidmechanics.client.render.BlockRenderHelper; import liquidmechanics.common.LiquidMechanics; import liquidmechanics.common.TabLiquidMechanics; import liquidmechanics.common.tileentity.TileEntityReleaseValve; @@ -59,13 +60,13 @@ public class BlockReleaseValve extends BlockMachine @Override public boolean renderAsNormalBlock() { - return true; + return false; } @Override public int getRenderType() { - return 0; + return -1; } @Override diff --git a/minecraft/liquidmechanics/common/item/ItemReleaseValve.java b/minecraft/liquidmechanics/common/item/ItemReleaseValve.java new file mode 100644 index 000000000..6ed638f00 --- /dev/null +++ b/minecraft/liquidmechanics/common/item/ItemReleaseValve.java @@ -0,0 +1,34 @@ +package liquidmechanics.common.item; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemReleaseValve extends ItemBlock +{ + + public ItemReleaseValve(int id) + { + super(id); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @Override + public int getMetadata(int damage) + { + return damage; + } + + @Override + public String getItemNameIS(ItemStack par1ItemStack) + { + return Block.blocksList[this.getBlockID()].getBlockName() + "." + (par1ItemStack.getItemDamage()); + } + + @Override + public String getItemName() + { + return Block.blocksList[this.getBlockID()].getBlockName() + ".0"; + } +} diff --git a/minecraft/liquidmechanics/common/tileentity/TileEntityGenerator.java b/minecraft/liquidmechanics/common/tileentity/TileEntityGenerator.java index 01aef30b0..932a27bbe 100644 --- a/minecraft/liquidmechanics/common/tileentity/TileEntityGenerator.java +++ b/minecraft/liquidmechanics/common/tileentity/TileEntityGenerator.java @@ -76,7 +76,7 @@ public class TileEntityGenerator extends TileEntityElectricityProducer implement this.genAmmount = Math.abs(force / this.getVoltage()); // wire count update int wireCount = 0; - TileEntity[] ents = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord); + TileEntity[] ents = connectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord); this.wires = new IConductor[6]; for (int i = 0; i < ents.length; i++) { diff --git a/minecraft/liquidmechanics/common/tileentity/TileEntityPipe.java b/minecraft/liquidmechanics/common/tileentity/TileEntityPipe.java index 7846d8d28..f6bc6a307 100644 --- a/minecraft/liquidmechanics/common/tileentity/TileEntityPipe.java +++ b/minecraft/liquidmechanics/common/tileentity/TileEntityPipe.java @@ -40,7 +40,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO public TileEntity[] connectedBlocks = new TileEntity[6]; - public LiquidTank stored = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * 2); + private LiquidTank stored = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * 2); @Override public void updateEntity() @@ -67,7 +67,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO { if (((TileEntityPipe) connectedBlocks[i]).presure < this.presure) { - stored.drain(((TileEntityPipe) connectedBlocks[i]).stored.fill(stack, true), true); + stored.drain(((TileEntityPipe) connectedBlocks[i]).fill(dir, stack, true), true); } } @@ -247,7 +247,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO */ public void validataConnections() { - this.connectedBlocks = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord); + this.connectedBlocks = connectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord); for (int i = 0; i < 6; i++) { ForgeDirection dir = ForgeDirection.getOrientation(i); diff --git a/minecraft/liquidmechanics/common/tileentity/TileEntityReleaseValve.java b/minecraft/liquidmechanics/common/tileentity/TileEntityReleaseValve.java index a4045d8db..dd0ff5d11 100644 --- a/minecraft/liquidmechanics/common/tileentity/TileEntityReleaseValve.java +++ b/minecraft/liquidmechanics/common/tileentity/TileEntityReleaseValve.java @@ -7,6 +7,7 @@ import java.util.List; import cpw.mods.fml.common.FMLLog; +import liquidmechanics.api.IColorCoded; import liquidmechanics.api.IPressure; import liquidmechanics.api.IReadOut; import liquidmechanics.api.helpers.LiquidData; @@ -46,7 +47,21 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe public void updateEntity() { super.updateEntity(); - + connected = connectionHelper.getSurroundingTileEntities(this); + for(int i =0; i < 6;i++) + { + if(connected[i] instanceof ITankContainer) + { + if(connected[i] instanceof IColorCoded && !this.canConnect(((IColorCoded) connected[i]).getColor())) + { + connected[i] = null; + } + }else + { + + connected[i] = null; + } + } if (!this.worldObj.isRemote && ticks++ >= 40) { ticks = 0; @@ -60,12 +75,13 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe if (tank.getLiquid() != null && tank.getLiquid().amount > 0) { - FMLLog.warning("Tank: " + LiquidHandler.getName(tank.getLiquid()) + " Vol: " + tank.getLiquid().amount); + //FMLLog.warning("Tank: " + LiquidHandler.getName(tank.getLiquid()) + " Vol: " + tank.getLiquid().amount); TileEntityPipe pipe = this.findValidPipe(tank.getLiquid()); if (pipe != null) { - FMLLog.warning("Pipe: " + pipe.getColor() + " Vol: " + (pipe.stored.getLiquid() != null ? pipe.stored.getLiquid().amount : 0000)); - int drain = pipe.stored.fill(tank.getLiquid(), true); + ILiquidTank tankP = pipe.getTanks(ForgeDirection.UNKNOWN)[0]; + //FMLLog.warning("Pipe: " + pipe.getColor() + " Vol: " + (tankP.getLiquid() != null ? tankP.getLiquid().amount : 0000)); + int drain = pipe.fill(ForgeDirection.UNKNOWN, tank.getLiquid(), true); tank.drain(drain, true); } } @@ -82,7 +98,8 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe // find normal color selective pipe first for (TileEntityPipe pipe : output) { - if (LiquidHandler.isEqual(pipe.getColor().getLiquidData().getStack(),stack) && (pipe.stored.getLiquid() == null || pipe.stored.getLiquid().amount < pipe.stored.getCapacity())) + ILiquidTank tank = pipe.getTanks(ForgeDirection.UNKNOWN)[0]; + if (LiquidHandler.isEqual(pipe.getColor().getLiquidData().getStack(),stack) && (tank.getLiquid() == null || tank.getLiquid().amount < tank.getCapacity())) { // return pipe; @@ -137,7 +154,7 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe public void validateNBuildList() { // cleanup - this.connected = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord); + this.connected = connectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord); this.input.clear(); this.output.clear(); // read surroundings @@ -148,11 +165,12 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe if (ent instanceof TileEntityPipe) { TileEntityPipe pipe = (TileEntityPipe) ent; + ILiquidTank tank = pipe.getTanks(ForgeDirection.UNKNOWN)[0]; if (this.isRestricted() && this.canConnect(pipe.getColor())) { connected[i] = null; } - else if (pipe.stored.getLiquid() != null && pipe.stored.getLiquid().amount >= pipe.stored.getCapacity()) + else if (tank.getLiquid() != null && tank.getLiquid().amount >= tank.getCapacity()) { connected[i] = null; } diff --git a/minecraft/liquidmechanics/common/tileentity/TileEntityTank.java b/minecraft/liquidmechanics/common/tileentity/TileEntityTank.java index e3241704f..e8ef99a7f 100644 --- a/minecraft/liquidmechanics/common/tileentity/TileEntityTank.java +++ b/minecraft/liquidmechanics/common/tileentity/TileEntityTank.java @@ -45,19 +45,22 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead public void updateEntity() { - LiquidStack liquid = tank.getLiquid(); + this.color = ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); - if (++count >= 40 && liquid != null) + if (++count >= 40) { count = 0; - this.cc = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord); + this.cc = connectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord); if (!worldObj.isRemote) { this.tradeDown(); this.tradeArround(); this.fillPipe(); - int volume = liquid.amount; - + + int volume = 0; + LiquidStack liquid = tank.getLiquid(); + if(liquid != null){volume = liquid.amount;} + if (volume != pVolume) { LiquidStack stack = new LiquidStack(0, 0, 0); @@ -235,7 +238,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead { if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) { return; } - TileEntity[] ents = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord); + TileEntity[] ents = connectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord); int commonVol = this.tank.getLiquid().amount; int tanks = 1; diff --git a/minecraft/liquidmechanics/resource/ReleaseValve.png b/minecraft/liquidmechanics/resource/ReleaseValve.png new file mode 100644 index 000000000..532f83233 Binary files /dev/null and b/minecraft/liquidmechanics/resource/ReleaseValve.png differ diff --git a/minecraft/liquidmechanics/resource/lang/en_US.properties b/minecraft/liquidmechanics/resource/lang/en_US.properties index cf11ad8d0..410d953c4 100644 --- a/minecraft/liquidmechanics/resource/lang/en_US.properties +++ b/minecraft/liquidmechanics/resource/lang/en_US.properties @@ -5,7 +5,7 @@ tile.Generator.name=Generator tile.lmMachines.0.name=Pump tile.MechanicRod.name=Geared Rod -tile.eValve.name=Release Valve +tile.eValve.0.name=Release Valve tile.lmTank.name = Tank tile.lmPipe.0.name =Oil Pipe diff --git a/resources/models/EValve.tcn b/resources/models/EValve.tcn index c48f2f6ea..146aa984a 100644 Binary files a/resources/models/EValve.tcn and b/resources/models/EValve.tcn differ diff --git a/resources/models/ReleaseValve.png b/resources/models/ReleaseValve.png new file mode 100644 index 000000000..532f83233 Binary files /dev/null and b/resources/models/ReleaseValve.png differ