Added model to release valve

Model is not fully done since i want to get the valve to set on diffrent
faces when the top is in use. Also want it to rotate a bit when powered
by redstone.

Also worked on connectionHelper and switch a few of the itemRenders to
an actual itemRenderHelper so they look nice in the inventory and in the
players hand.
This commit is contained in:
Rseifert 2013-01-07 15:19:00 -05:00
parent 064ef38db9
commit 8b1179699f
22 changed files with 489 additions and 68 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ public class BlockPipe extends BlockMachine
@Override
public int getRenderType()
{
return BlockRenderHelper.renderID;
return -1;
}
/**

View file

@ -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

View file

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

View file

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

View file

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

View file

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

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

View file

@ -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

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B