Fixed pipe packet and using bitmasks

This commit is contained in:
Calclavia 2014-01-11 22:49:21 +08:00
parent b41c1ce033
commit 77ae26235a
13 changed files with 198 additions and 191 deletions

View file

@ -1,4 +1,4 @@
package dark.lib.interfaces; package resonantinduction.api;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;

View file

@ -19,14 +19,12 @@ import resonantinduction.core.part.BlockMachinePart;
import resonantinduction.electrical.armbot.BlockArmbot; import resonantinduction.electrical.armbot.BlockArmbot;
import resonantinduction.electrical.armbot.TileArmbot; import resonantinduction.electrical.armbot.TileArmbot;
import resonantinduction.electrical.battery.BlockBattery; import resonantinduction.electrical.battery.BlockBattery;
import resonantinduction.electrical.battery.ItemBlockBattery;
import resonantinduction.electrical.battery.TileBattery; import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.furnace.BlockAdvancedFurnace; import resonantinduction.electrical.furnace.BlockAdvancedFurnace;
import resonantinduction.electrical.furnace.TileAdvancedFurnace; import resonantinduction.electrical.furnace.TileAdvancedFurnace;
import resonantinduction.electrical.generator.solar.BlockSolarPanel; import resonantinduction.electrical.generator.solar.BlockSolarPanel;
import resonantinduction.electrical.generator.solar.TileSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.levitator.BlockLevitator; import resonantinduction.electrical.levitator.BlockLevitator;
import resonantinduction.electrical.levitator.ItemBlockContractor;
import resonantinduction.electrical.levitator.TileLevitator; import resonantinduction.electrical.levitator.TileLevitator;
import resonantinduction.electrical.multimeter.ItemMultimeter; import resonantinduction.electrical.multimeter.ItemMultimeter;
import resonantinduction.electrical.purifier.BlockPurifier; import resonantinduction.electrical.purifier.BlockPurifier;

View file

@ -14,6 +14,8 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.IReadOut;
import resonantinduction.api.IReadOut.EnumTools;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import resonantinduction.core.prefab.tile.TileEntityEnergyMachine; import resonantinduction.core.prefab.tile.TileEntityEnergyMachine;
@ -31,8 +33,6 @@ import calclavia.lib.utility.FluidHelper;
import cofh.api.energy.IEnergyStorage; import cofh.api.energy.IEnergyStorage;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dark.lib.interfaces.IReadOut;
import dark.lib.interfaces.IReadOut.EnumTools;
public class ItemReadoutTools extends ItemBase public class ItemReadoutTools extends ItemBase
{ {

View file

@ -6,12 +6,12 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.IReadOut;
import resonantinduction.api.fluid.INetworkPipe; import resonantinduction.api.fluid.INetworkPipe;
import resonantinduction.core.tilenetwork.ITileConnector; import resonantinduction.core.tilenetwork.ITileConnector;
import resonantinduction.mechanical.fluid.network.NetworkPipes; import resonantinduction.mechanical.fluid.network.NetworkPipes;
import resonantinduction.mechanical.fluid.prefab.TileEntityFluidDevice; import resonantinduction.mechanical.fluid.prefab.TileEntityFluidDevice;
import calclavia.lib.utility.HelperMethods; import calclavia.lib.utility.HelperMethods;
import dark.lib.interfaces.IReadOut;
public class TileReleaseValve extends TileEntityFluidDevice implements ITileConnector, IReadOut public class TileReleaseValve extends TileEntityFluidDevice implements ITileConnector, IReadOut
{ {

View file

@ -16,60 +16,62 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ItemPipeRenderer implements IItemRenderer public class ItemPipeRenderer implements IItemRenderer
{ {
private ModelReleaseValve valve = new ModelReleaseValve(); private ModelReleaseValve valve = new ModelReleaseValve();
@Override @Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) public boolean handleRenderType(ItemStack item, ItemRenderType type)
{ {
return true; return true;
} }
@Override @Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{ {
return true; return true;
} }
@Override @Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glRotatef(180f, 0f, 0f, 1f); GL11.glRotatef(180f, 0f, 0f, 1f);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(item.getItemDamage())); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(item.getItemDamage()));
int meta = item.getItemDamage(); int meta = item.getItemDamage();
if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
{ if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
meta = FluidContainerMaterial.IRON.getMeta(); {
} meta = FluidContainerMaterial.IRON.getMeta();
if (type == ItemRenderType.ENTITY) }
{ if (type == ItemRenderType.ENTITY)
GL11.glTranslatef(-.5F, -1F, -.5F); {
RenderPipe.render(meta, new boolean[] { false, false, false, false, true, true }); GL11.glTranslatef(-.5F, -1F, -.5F);
} RenderPipe.render(meta, (byte) 0b000011);
else if (type == ItemRenderType.INVENTORY) }
{ else if (type == ItemRenderType.INVENTORY)
GL11.glTranslatef(0F, -1F, 0F); {
RenderPipe.render(meta, new boolean[] { false, false, false, false, true, true }); GL11.glTranslatef(0F, -1F, 0F);
} RenderPipe.render(meta, (byte) 0b000011);
else if (type == ItemRenderType.EQUIPPED) }
{ else if (type == ItemRenderType.EQUIPPED)
GL11.glTranslatef(-1F, -1.2F, 0.5F); {
RenderPipe.render(meta, new boolean[] { false, false, true, true, false, false }); GL11.glTranslatef(-1F, -1.2F, 0.5F);
} RenderPipe.render(meta, (byte) 0b001100);
else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) }
{ else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
GL11.glTranslatef(-2F, -1.5F, 0.2F); {
RenderPipe.render(meta, new boolean[] { false, false, true, true, false, false }); GL11.glTranslatef(-2F, -1.5F, 0.2F);
} RenderPipe.render(meta, (byte) 0b001100);
else }
{ else
RenderPipe.render(item.getItemDamage(), new boolean[] { false, false, true, true, false, false }); {
} RenderPipe.render(item.getItemDamage(), (byte) 0b001100);
if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID) }
{ if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Reference.DOMAIN, Reference.MODEL_DIRECTORY + "ReleaseValve.png")); {
valve.render(); FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Reference.DOMAIN, Reference.MODEL_DIRECTORY + "ReleaseValve.png"));
} valve.render();
GL11.glPopMatrix(); }
}
GL11.glPopMatrix();
}
} }

View file

@ -2,15 +2,19 @@ package resonantinduction.mechanical.fluid.pipe;
import java.util.HashMap; import java.util.HashMap;
import javax.rmi.CORBA.Tie;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.render.RenderFluidHelper; import resonantinduction.core.render.RenderFluidHelper;
import resonantinduction.mechanical.fluid.prefab.TileFluidNetworkTile;
import resonantinduction.old.client.model.ModelOpenTrough; import resonantinduction.old.client.model.ModelOpenTrough;
import resonantinduction.old.client.model.ModelPipe; import resonantinduction.old.client.model.ModelPipe;
@ -37,13 +41,16 @@ public class RenderPipe extends TileEntitySpecialRenderer
{ {
mat = FluidContainerMaterial.values()[te.getBlockMetadata()]; mat = FluidContainerMaterial.values()[te.getBlockMetadata()];
} }
if (te instanceof TilePipe) if (te instanceof TilePipe)
{ {
boolean[] sides = ((TilePipe) te).renderConnection; TilePipe tile = (TilePipe) te;
if (mat == FluidContainerMaterial.WOOD || mat == FluidContainerMaterial.STONE) if (mat == FluidContainerMaterial.WOOD || mat == FluidContainerMaterial.STONE)
{ {
FluidStack liquid = ((TilePipe) te).getTank().getFluid(); FluidStack liquid = tile.getTank().getFluid();
int cap = ((TilePipe) te).getTankInfo()[0].capacity; int cap = tile.getTankInfo()[0].capacity;
// FluidStack liquid = new FluidStack(FluidRegistry.WATER, cap); // FluidStack liquid = new FluidStack(FluidRegistry.WATER, cap);
if (liquid != null && liquid.amount > 100) if (liquid != null && liquid.amount > 100)
{ {
@ -65,82 +72,49 @@ public class RenderPipe extends TileEntitySpecialRenderer
GL11.glPopAttrib(); GL11.glPopAttrib();
GL11.glPopMatrix(); GL11.glPopMatrix();
if (sides[4])
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{ {
GL11.glPushMatrix(); if (tile.canRenderSide(direction))
GL11.glPushAttrib(GL11.GL_ENABLE_BIT); {
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING); GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef((float) d + 0F, (float) d1 + 0.1F, (float) d2 + 0.3F); switch (direction.ordinal())
GL11.glScalef(0.3F, 0.4F, 0.4F); {
case 4:
GL11.glTranslatef((float) d + 0F, (float) d1 + 0.1F, (float) d2 + 0.3F);
break;
case 5:
GL11.glTranslatef((float) d + 0.7F, (float) d1 + 0.1F, (float) d2 + 0.3F);
break;
case 2:
GL11.glTranslatef((float) d + 0.3F, (float) d1 + 0.1F, (float) d2 + 0F);
break;
case 3:
GL11.glTranslatef((float) d + 0.3F, (float) d1 + 0.1F, (float) d2 + 0.7F);
break;
}
GL11.glScalef(0.3F, 0.4F, 0.4F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]); GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib(); GL11.glPopAttrib();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
if (sides[5])
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef((float) d + 0.7F, (float) d1 + 0.1F, (float) d2 + 0.3F);
GL11.glScalef(0.3F, 0.4F, 0.4F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
if (sides[2])
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef((float) d + 0.3F, (float) d1 + 0.1F, (float) d2 + 0F);
GL11.glScalef(0.4F, 0.4F, 0.3F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
if (sides[3])
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef((float) d + 0.3F, (float) d1 + 0.1F, (float) d2 + 0.7F);
GL11.glScalef(0.4F, 0.4F, 0.3F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
} }
} }
} }
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
bindTexture(RenderPipe.getTexture(mat, 0)); bindTexture(RenderPipe.getTexture(mat, 0));
RenderPipe.render(mat, ((TilePipe) te).getSubID(), sides); render(mat, tile.getSubID(), tile.renderSides);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
else else
@ -148,7 +122,7 @@ public class RenderPipe extends TileEntitySpecialRenderer
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
RenderPipe.render(mat, 0, new boolean[6]); render(mat, 0, (byte) 0b0);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -179,25 +153,51 @@ public class RenderPipe extends TileEntitySpecialRenderer
return getTexture(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta)); return getTexture(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta));
} }
public static void render(FluidContainerMaterial mat, int pipeID, boolean[] side) public static void render(FluidContainerMaterial mat, int pipeID, byte side)
{ {
if (mat == FluidContainerMaterial.WOOD) if (mat == FluidContainerMaterial.WOOD)
{ {
MODEL_TROUGH_PIPE.render(side, false); // MODEL_TROUGH_PIPE.render(side, false);
} }
else if (mat == FluidContainerMaterial.STONE) else if (mat == FluidContainerMaterial.STONE)
{ {
MODEL_TROUGH_PIPE.render(side, true); // MODEL_TROUGH_PIPE.render(side, true);
} }
else else
{ {
MODEL_PIPE.render(side); System.out.println(Integer.toBinaryString(side));
if (TileFluidNetworkTile.canRenderSide(side,ForgeDirection.DOWN))
{
MODEL_PIPE.renderBottom();
}
if (TileFluidNetworkTile.canRenderSide(side,ForgeDirection.UP))
{
MODEL_PIPE.renderTop();
}
if (TileFluidNetworkTile.canRenderSide(side,ForgeDirection.NORTH))
{
MODEL_PIPE.renderBack();
}
if (TileFluidNetworkTile.canRenderSide(side,ForgeDirection.SOUTH))
{
MODEL_PIPE.renderFront();
}
if (TileFluidNetworkTile.canRenderSide(side, ForgeDirection.WEST))
{
MODEL_PIPE.renderLeft();
}
if (TileFluidNetworkTile.canRenderSide(side, ForgeDirection.EAST))
{
MODEL_PIPE.renderRight();
}
MODEL_PIPE.renderMiddle();
} }
} }
public static void render(int meta, boolean[] bs) public static void render(int meta, byte sides)
{ {
render(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta), bs); render(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta), sides);
} }
} }

View file

@ -64,34 +64,38 @@ public class TilePipe extends TileFluidNetworkTile implements IColorCoded, INetw
{ {
this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this);
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
this.renderConnection[side.ordinal()] = true; setRenderSide(side, true);
}// Wood and stone pipes can connect to each other but not other pipe types since }
// they are more like a trough than a pipe
else if ((pipeMat == FluidContainerMaterial.WOOD || pipeMat == FluidContainerMaterial.STONE) && (pipeMatOther == FluidContainerMaterial.WOOD || pipeMatOther == FluidContainerMaterial.STONE)) else if ((pipeMat == FluidContainerMaterial.WOOD || pipeMat == FluidContainerMaterial.STONE) && (pipeMatOther == FluidContainerMaterial.WOOD || pipeMatOther == FluidContainerMaterial.STONE))
{ {
// Wood and stone pipes can connect to each other but not other pipe types since
// they are more like a trough than a pipe
this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this);
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
this.renderConnection[side.ordinal()] = true; setRenderSide(side, true);
}// Any other pipe can connect to each other as long as the color matches except for }
// glass which only works with itself at the moment
else if (pipeMat != FluidContainerMaterial.WOOD && pipeMat != FluidContainerMaterial.STONE && pipeMatOther != FluidContainerMaterial.WOOD && pipeMatOther != FluidContainerMaterial.STONE && pipeMat != FluidContainerMaterial.GLASS && pipeMatOther != FluidContainerMaterial.GLASS) else if (pipeMat != FluidContainerMaterial.WOOD && pipeMat != FluidContainerMaterial.STONE && pipeMatOther != FluidContainerMaterial.WOOD && pipeMatOther != FluidContainerMaterial.STONE && pipeMat != FluidContainerMaterial.GLASS && pipeMatOther != FluidContainerMaterial.GLASS)
{ {
/*
* Any other pipe can connect to each other as long as the color matches except
* for glass which only works with itself at the moment
*/
this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((INetworkPipe) tileEntity).getTileNetwork(), this);
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
this.renderConnection[side.ordinal()] = true; setRenderSide(side, true);
} }
} }
} }
else if (tileEntity instanceof IFluidHandler) else if (tileEntity instanceof IFluidHandler)
{ {
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
this.renderConnection[side.ordinal()] = true; setRenderSide(side, true);
this.getTileNetwork().addTank(side.getOpposite(), (IFluidHandler) tileEntity); this.getTileNetwork().addTank(side.getOpposite(), (IFluidHandler) tileEntity);
} }
else if (tileEntity instanceof ITileConnector && ((ITileConnector) tileEntity).canTileConnect(Connection.FLUIDS, side.getOpposite())) else if (tileEntity instanceof ITileConnector && ((ITileConnector) tileEntity).canTileConnect(Connection.FLUIDS, side.getOpposite()))
{ {
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
this.renderConnection[side.ordinal()] = true; setRenderSide(side, true);
} }
} }

View file

@ -4,10 +4,10 @@ import java.util.Random;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.IReadOut;
import resonantinduction.core.tilenetwork.ITileConnector; import resonantinduction.core.tilenetwork.ITileConnector;
import resonantinduction.core.tilenetwork.prefab.NetworkTileEntities; import resonantinduction.core.tilenetwork.prefab.NetworkTileEntities;
import calclavia.lib.prefab.tile.TileAdvanced; import calclavia.lib.prefab.tile.TileAdvanced;
import dark.lib.interfaces.IReadOut;
public abstract class TileEntityFluidDevice extends TileAdvanced implements IReadOut, ITileConnector public abstract class TileEntityFluidDevice extends TileAdvanced implements IReadOut, ITileConnector
{ {

View file

@ -17,9 +17,6 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import org.bouncycastle.util.Arrays;
import resonantinduction.api.fluid.FluidMasterList; import resonantinduction.api.fluid.FluidMasterList;
import resonantinduction.api.fluid.INetworkFluidPart; import resonantinduction.api.fluid.INetworkFluidPart;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
@ -34,7 +31,6 @@ import calclavia.lib.network.PacketHandler;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -57,7 +53,7 @@ public abstract class TileFluidNetworkTile extends TileEntityFluidDevice impleme
public static final int PACKET_TANK = Mechanical.contentRegistry.getNextPacketID(); public static final int PACKET_TANK = Mechanical.contentRegistry.getNextPacketID();
/** Bitmask **/ /** Bitmask **/
private byte renderSides = 0b0; public byte renderSides = 0b0;
public TileFluidNetworkTile() public TileFluidNetworkTile()
{ {
@ -234,6 +230,11 @@ public abstract class TileFluidNetworkTile extends TileEntityFluidDevice impleme
} }
} }
public boolean canRenderSide(ForgeDirection direction)
{
return (renderSides & (1 << direction.ordinal())) != 0;
}
@Override @Override
public NetworkFluidTiles getTileNetwork() public NetworkFluidTiles getTileNetwork()
{ {
@ -396,30 +397,26 @@ public abstract class TileFluidNetworkTile extends TileEntityFluidDevice impleme
{ {
if (this.worldObj.isRemote) if (this.worldObj.isRemote)
{ {
switch (data.readInt()) int readInt = data.readInt();
if (readInt == PACKET_DESCRIPTION)
{ {
case PACKET_DESCRIPTION: this.subID = data.readInt();
{ this.renderSides = data.readByte();
this.subID = data.readInt(); this.tank = new FluidTank(data.readInt());
this.renderSides = data.readByte(); this.getTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
this.tank = new FluidTank(data.readInt()); this.internalTanksInfo[0] = this.getTank().getInfo();
this.getTank().readFromNBT(PacketHandler.readNBTTagCompound(data)); }
this.internalTanksInfo[0] = this.getTank().getInfo(); else if (readInt == PACKET_RENDER)
break; {
} this.subID = data.readInt();
case PACKET_RENDER: this.renderSides = data.readByte();
{ }
this.subID = data.readInt(); else if (readInt == PACKET_TANK)
this.renderSides = data.readByte(); {
break; this.tank = new FluidTank(data.readInt());
} this.getTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
case PACKET_TANK: this.internalTanksInfo[0] = this.getTank().getInfo();
{
this.tank = new FluidTank(data.readInt());
this.getTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
this.internalTanksInfo[0] = this.getTank().getInfo();
break;
}
} }
} }
} }
@ -461,13 +458,7 @@ public abstract class TileFluidNetworkTile extends TileEntityFluidDevice impleme
{ {
if (tool == EnumTools.PIPE_GUAGE) if (tool == EnumTools.PIPE_GUAGE)
{ {
String out = "Debug: " + this.getTileNetwork().toString(); return "Volume: " + this.getTileNetwork().getNetworkTank().getFluidAmount();
out += " ";
for (boolean b : this.renderConnection)
{
out += "|" + (b ? "T" : "F");
}
return out + " Vol: " + this.getTileNetwork().getNetworkTank().getFluidAmount();
} }
return null; return null;
} }
@ -489,4 +480,9 @@ public abstract class TileFluidNetworkTile extends TileEntityFluidDevice impleme
this.subID = id; this.subID = id;
} }
public static boolean canRenderSide(byte renderSides, ForgeDirection direction)
{
return (renderSides & (1 << direction.ordinal())) != 0;
}
} }

View file

@ -15,6 +15,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.IReadOut.EnumTools;
import resonantinduction.api.fluid.IDrain; import resonantinduction.api.fluid.IDrain;
import resonantinduction.api.fluid.INetworkPipe; import resonantinduction.api.fluid.INetworkPipe;
import resonantinduction.core.tilenetwork.ITileConnector; import resonantinduction.core.tilenetwork.ITileConnector;

View file

@ -10,6 +10,8 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.IReadOut;
import resonantinduction.api.IReadOut.EnumTools;
import resonantinduction.api.fluid.IDrain; import resonantinduction.api.fluid.IDrain;
import resonantinduction.core.prefab.tile.TileEntityEnergyMachine; import resonantinduction.core.prefab.tile.TileEntityEnergyMachine;
import resonantinduction.core.tilenetwork.ITileConnector; import resonantinduction.core.tilenetwork.ITileConnector;
@ -18,8 +20,6 @@ import calclavia.lib.utility.FluidHelper;
import com.builtbroken.common.Pair; import com.builtbroken.common.Pair;
import dark.lib.interfaces.IReadOut;
public class TilePump extends TileEntityEnergyMachine implements IReadOut, ITileConnector public class TilePump extends TileEntityEnergyMachine implements IReadOut, ITileConnector
{ {
private int currentWorldEdits, MAX_WORLD_EDITS_PER_PROCESS; private int currentWorldEdits, MAX_WORLD_EDITS_PER_PROCESS;

View file

@ -9,6 +9,7 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.core.render.RenderFluidHelper; import resonantinduction.core.render.RenderFluidHelper;
import resonantinduction.mechanical.fluid.prefab.TileFluidNetworkTile;
import resonantinduction.old.client.model.ModelTankSide; import resonantinduction.old.client.model.ModelTankSide;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -29,10 +30,11 @@ public class RenderTank extends TileEntitySpecialRenderer
public void renderTank(TileEntity tileEntity, double x, double y, double z, int meta, FluidStack liquid) public void renderTank(TileEntity tileEntity, double x, double y, double z, int meta, FluidStack liquid)
{ {
boolean[] render = new boolean[6]; byte renderSudes = 0;
if (tileEntity instanceof TileTank) if (tileEntity instanceof TileTank)
{ {
render = ((TileTank) tileEntity).renderConnection; renderSudes = ((TileTank) tileEntity).renderSides;
} }
if (liquid != null && liquid.amount > 100) if (liquid != null && liquid.amount > 100)
{ {
@ -57,16 +59,18 @@ public class RenderTank extends TileEntitySpecialRenderer
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
boolean bot = render[1]; boolean bot = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(1));
boolean top = render[0]; boolean top = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(0));
boolean north = render[2]; boolean north = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(2));
boolean south = render[3]; boolean south = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(3));
boolean east = render[5]; boolean east = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(5));
boolean west = render[4]; boolean west = TileFluidNetworkTile.canRenderSide(renderSudes, ForgeDirection.getOrientation(4));
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
ForgeDirection dir = ForgeDirection.getOrientation(i + 2); ForgeDirection dir = ForgeDirection.getOrientation(i + 2);
if (!render[dir.getOpposite().ordinal()])
if (!TileFluidNetworkTile.canRenderSide(renderSudes, dir.getOpposite()))
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -74,6 +78,7 @@ public class RenderTank extends TileEntitySpecialRenderer
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
boolean left = false; boolean left = false;
boolean right = false; boolean right = false;
switch (dir) switch (dir)
{ {
case NORTH: case NORTH:
@ -97,6 +102,7 @@ public class RenderTank extends TileEntitySpecialRenderer
right = south; right = south;
break; break;
} }
bindTexture(RenderTank.getTexture(tileEntity.getBlockType().blockID, tileEntity.getBlockMetadata())); bindTexture(RenderTank.getTexture(tileEntity.getBlockType().blockID, tileEntity.getBlockMetadata()));
MODEL.render(0.0625F, left, right, top, bot); MODEL.render(0.0625F, left, right, top, bot);
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -44,7 +44,7 @@ public class TileTank extends TileFluidNetworkTile
if (this.canTileConnect(Connection.NETWORK, side.getOpposite())) if (this.canTileConnect(Connection.NETWORK, side.getOpposite()))
{ {
this.getTileNetwork().mergeNetwork(((INetworkFluidPart) tileEntity).getTileNetwork(), (INetworkPart) tileEntity); this.getTileNetwork().mergeNetwork(((INetworkFluidPart) tileEntity).getTileNetwork(), (INetworkPart) tileEntity);
this.renderConnection[side.ordinal()] = true; this.setRenderSide(side, true);
connectedBlocks.add(tileEntity); connectedBlocks.add(tileEntity);
} }
} }