Pipes are now multipart

This commit is contained in:
Calclavia 2014-01-19 17:01:35 +08:00
parent c90d509d5e
commit 32404e6742
18 changed files with 1089 additions and 316 deletions

View file

@ -0,0 +1,83 @@
if (te instanceof TilePipe)
{
TilePipe tile = (TilePipe) te;
if (material == FluidContainerMaterial.WOOD || material == FluidContainerMaterial.STONE)
{
FluidStack liquid = tile.getInternalTank().getFluid();
int cap = tile.getInternalTank().getCapacity();
// FluidStack liquid = new FluidStack(FluidRegistry.WATER, cap);
if (liquid != null && liquid.amount > 100)
{
float per = Math.max(1, (float) liquid.amount / (float) (cap));
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, te.worldObj, false);
bindTexture(RenderFluidHelper.getFluidSheet(liquid));
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.3F);
GL11.glScalef(0.4F, 0.4F, 0.4F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
if (tile.canRenderSide(direction) && direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
{
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);
switch (direction.ordinal())
{
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.glPopAttrib();
GL11.glPopMatrix();
}
}
}
}
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
bindTexture(RenderPipe.getTexture(material, 0));
render(material, tile.getSubID(), tile.renderSides);
GL11.glPopMatrix();
}
else
{
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
render(material, 0, (byte) 0b0);
GL11.glPopMatrix();
}

View file

@ -1,6 +1,14 @@
package resonantinduction.core.prefab.part;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.multipart.IRedstonePart;
import codechicken.multipart.TMultiPart;
public abstract class PartAdvanced extends TMultiPart
@ -34,4 +42,44 @@ public abstract class PartAdvanced extends TMultiPart
{
return world();
}
protected abstract ItemStack getItem();
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
return drops;
}
@Override
public ItemStack pickItem(MovingObjectPosition hit)
{
return getItem();
}
protected boolean checkRedstone(int side)
{
if (this.world().isBlockIndirectlyGettingPowered(x(), y(), z()))
{
return true;
}
else
{
for (TMultiPart tp : tile().jPartList())
{
if (tp instanceof IRedstonePart)
{
IRedstonePart rp = (IRedstonePart) tp;
if ((Math.max(rp.strongPowerLevel(side), rp.weakPowerLevel(side)) << 4) > 0)
{
return true;
}
}
}
}
return false;
}
}

View file

@ -0,0 +1,237 @@
package resonantinduction.core.prefab.part;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import resonantinduction.core.Utility;
import resonantinduction.electrical.wire.EnumWireMaterial;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
/**
* @author Calclavia
*
*/
public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
{
public static final int DEFAULT_COLOR = 15;
public int color = DEFAULT_COLOR;
public M material;
public boolean isInsulated = false;
/**
* Material Methods
*/
public M getMaterial()
{
return material;
}
public void setMaterial(M material)
{
this.material = material;
}
public abstract void setMaterial(int i);
public int getMaterialID()
{
return material.ordinal();
}
/**
* Insulation Methods
*/
public void setInsulated(boolean insulated)
{
this.isInsulated = insulated;
this.color = DEFAULT_COLOR;
if (!this.world().isRemote)
{
tile().notifyPartChange(this);
this.sendInsulationUpdate();
}
}
public void setInsulated(int dyeColour)
{
this.isInsulated = true;
this.color = dyeColour;
if (!this.world().isRemote)
{
tile().notifyPartChange(this);
this.sendInsulationUpdate();
this.sendColorUpdate();
}
}
public boolean isInsulated()
{
return this.isInsulated;
}
public void sendInsulationUpdate()
{
tile().getWriteStream(this).writeByte(1).writeBoolean(this.isInsulated);
}
/**
* Wire Coloring Methods
*/
public int getColor()
{
return this.isInsulated ? this.color : -1;
}
public void setColor(int dye)
{
if (this.isInsulated)
{
this.color = dye;
if (!this.world().isRemote)
{
tile().notifyPartChange(this);
this.sendColorUpdate();
}
}
}
public void sendColorUpdate()
{
tile().getWriteStream(this).writeByte(2).writeInt(this.color);
}
/**
* Changes the wire's color.
*/
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack itemStack)
{
if (itemStack != null)
{
int dyeColor = Utility.isDye(itemStack);
if (dyeColor != -1 && this.isInsulated())
{
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
this.setColor(dyeColor);
return true;
}
else if (itemStack.itemID == Block.cloth.blockID)
{
if (this.isInsulated())
{
if (!world().isRemote && player.capabilities.isCreativeMode)
{
tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color))));
}
this.setInsulated(false);
return true;
}
else
{
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
this.setInsulated(BlockColored.getDyeFromBlock(itemStack.getItemDamage()));
return true;
}
}
else if (itemStack.getItem() instanceof ItemShears && isInsulated())
{
if (!world().isRemote && !player.capabilities.isCreativeMode)
{
tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color))));
}
this.setInsulated(false);
return true;
}
}
return false;
}
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
if (this.isInsulated)
{
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)));
}
return drops;
}
@Override
public void readDesc(MCDataInput packet)
{
this.setMaterial(packet.readByte());
this.color = packet.readByte();
this.isInsulated = packet.readBoolean();
}
@Override
public void writeDesc(MCDataOutput packet)
{
packet.writeByte((byte) this.getMaterialID());
packet.writeByte((byte) this.color);
packet.writeBoolean(this.isInsulated);
}
public void read(MCDataInput packet, int packetID)
{
switch (packetID)
{
case 1:
this.isInsulated = packet.readBoolean();
this.tile().markRender();
break;
case 2:
this.color = packet.readInt();
this.tile().markRender();
break;
}
}
@Override
public void save(NBTTagCompound nbt)
{
super.save(nbt);
nbt.setInteger("typeID", getMaterialID());
nbt.setBoolean("isInsulated", isInsulated);
nbt.setInteger("dyeID", color);
}
@Override
public void load(NBTTagCompound nbt)
{
super.load(nbt);
setMaterial(nbt.getInteger("typeID"));
this.isInsulated = nbt.getBoolean("isInsulated");
this.color = nbt.getInteger("dyeID");
}
}

View file

@ -0,0 +1,479 @@
package resonantinduction.core.prefab.part;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import resonantinduction.mechanical.fluid.pipe.PartPipe;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.net.IConnector;
import universalelectricity.api.net.INetwork;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Translation;
import codechicken.microblock.IHollowConnect;
import codechicken.multipart.IconHitEffects;
import codechicken.multipart.JIconHitEffects;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.NormalOcclusionTest;
import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import codechicken.multipart.TileMultipart;
public abstract class PartFramedConnection<M extends Enum, C extends IConnector<N>, N extends INetwork> extends PartColorableMaterial<M> implements IConnector<N>, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
{
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
public static IndexedCuboid6[] insulatedSides = new IndexedCuboid6[7];
static
{
sides[0] = new IndexedCuboid6(0, new Cuboid6(0.36, 0.000, 0.36, 0.64, 0.36, 0.64));
sides[1] = new IndexedCuboid6(1, new Cuboid6(0.36, 0.64, 0.36, 0.64, 1.000, 0.64));
sides[2] = new IndexedCuboid6(2, new Cuboid6(0.36, 0.36, 0.000, 0.64, 0.64, 0.36));
sides[3] = new IndexedCuboid6(3, new Cuboid6(0.36, 0.36, 0.64, 0.64, 0.64, 1.000));
sides[4] = new IndexedCuboid6(4, new Cuboid6(0.000, 0.36, 0.36, 0.36, 0.64, 0.64));
sides[5] = new IndexedCuboid6(5, new Cuboid6(0.64, 0.36, 0.36, 1.000, 0.64, 0.64));
sides[6] = new IndexedCuboid6(6, new Cuboid6(0.36, 0.36, 0.36, 0.64, 0.64, 0.64));
insulatedSides[0] = new IndexedCuboid6(0, new Cuboid6(0.3, 0.0, 0.3, 0.7, 0.3, 0.7));
insulatedSides[1] = new IndexedCuboid6(1, new Cuboid6(0.3, 0.7, 0.3, 0.7, 1.0, 0.7));
insulatedSides[2] = new IndexedCuboid6(2, new Cuboid6(0.3, 0.3, 0.0, 0.7, 0.7, 0.3));
insulatedSides[3] = new IndexedCuboid6(3, new Cuboid6(0.3, 0.3, 0.7, 0.7, 0.7, 1.0));
insulatedSides[4] = new IndexedCuboid6(4, new Cuboid6(0.0, 0.3, 0.3, 0.3, 0.7, 0.7));
insulatedSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7));
insulatedSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7));
}
protected Object[] connections = new Object[6];
protected N network;
/**
* Bitmask connections
*/
public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00;
/** Client Side */
private ForgeDirection testingSide;
protected Icon breakIcon;
public void preparePlacement(int meta)
{
this.setMaterial(meta);
}
@Override
public boolean occlusionTest(TMultiPart other)
{
return NormalOcclusionTest.apply(this, other);
}
@Override
public Iterable<IndexedCuboid6> getSubParts()
{
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
IndexedCuboid6[] currentSides = isInsulated() ? insulatedSides : sides;
if (tile() != null)
{
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
int ord = side.ordinal();
if (connectionMapContainsSide(getAllCurrentConnections(), side) || side == testingSide)
subParts.add(currentSides[ord]);
}
}
subParts.add(currentSides[6]);
return subParts;
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
if (!world().isRemote)
{
// TODO: Remove; for debugging.
for (int i = 0; i < connections.length; i++)
System.out.println("TEST" + connections[i]);
}
return super.activate(player, part, item);
}
/**
* Rendering and block bounds.
*/
@Override
public Iterable<Cuboid6> getCollisionBoxes()
{
Set<Cuboid6> collisionBoxes = new HashSet<Cuboid6>();
collisionBoxes.addAll((Collection<? extends Cuboid6>) getSubParts());
return collisionBoxes;
}
@Override
public float getStrength(MovingObjectPosition hit, EntityPlayer player)
{
return 10F;
}
@Override
public void drawBreaking(RenderBlocks renderBlocks)
{
CCRenderState.reset();
RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null);
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes()
{
return getCollisionBoxes();
}
@Override
public int getSlotMask()
{
return PartMap.CENTER.mask;
}
@Override
public int getHollowSize()
{
return isInsulated ? 8 : 6;
}
@Override
public Cuboid6 getBounds()
{
return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625);
}
@Override
public Icon getBreakingIcon(Object subPart, int side)
{
return breakIcon;
}
@Override
public Icon getBrokenIcon(int side)
{
return breakIcon;
}
@Override
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer)
{
IconHitEffects.addHitEffects(this, hit, effectRenderer);
}
@Override
public void addDestroyEffects(EffectRenderer effectRenderer)
{
IconHitEffects.addDestroyEffects(this, effectRenderer, false);
}
public boolean isBlockedOnSide(ForgeDirection side)
{
TMultiPart blocker = tile().partMap(side.ordinal());
testingSide = side;
boolean expandable = NormalOcclusionTest.apply(this, blocker);
testingSide = null;
return !expandable;
}
public byte getAllCurrentConnections()
{
return (byte) (currentWireConnections | currentAcceptorConnections);
}
public static boolean connectionMapContainsSide(byte connections, ForgeDirection side)
{
byte tester = (byte) (1 << side.ordinal());
return ((connections & tester) > 0);
}
@Override
public void bind(TileMultipart t)
{
if (tile() != null && this.getNetwork() != null)
{
getNetwork().getConnectors().remove(tile());
super.bind(t);
getNetwork().getConnectors().add(getConnector(tile()));
}
else
{
super.bind(t);
}
}
/**
* CONNECTION LOGIC CODE
*/
protected abstract boolean canConnectTo(TileEntity tile);
protected abstract C getConnector(TileEntity tile);
public boolean canConnectBothSides(TileEntity tile, ForgeDirection side)
{
boolean notPrevented = !isConnectionPrevented(tile, side);
if (getConnector(tile) != null)
{
notPrevented &= getConnector(tile).canConnect(side.getOpposite());
}
return notPrevented;
}
/**
* Override if there are ways of preventing a connection
*
* @param tile The TileEntity on the given side
* @param side The side we're checking
* @return Whether we're preventing connections on given side or to given tileEntity
*/
public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side)
{
return (!this.canConnectTo(tile)) || (isBlockedOnSide(side));
}
public byte getPossibleWireConnections()
{
byte connections = 0x00;
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if (getConnector(tileEntity) != null && canConnectBothSides(tileEntity, side))
{
connections |= 1 << side.ordinal();
}
}
return connections;
}
public byte getPossibleAcceptorConnections()
{
byte connections = 0x00;
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if (CompatibilityModule.canConnect(tileEntity, side.getOpposite()) && canConnectBothSides(tileEntity, side))
{
connections |= 1 << side.ordinal();
}
}
return connections;
}
public void refresh()
{
if (!world().isRemote)
{
byte possibleWireConnections = getPossibleWireConnections();
byte possibleAcceptorConnections = getPossibleAcceptorConnections();
if (possibleWireConnections != this.currentWireConnections)
{
byte or = (byte) (possibleWireConnections | this.currentWireConnections);
// Connections have been removed
if (or != possibleWireConnections)
{
this.getNetwork().removeConnector(this);
this.getNetwork().split(getConnector(tile()));
setNetwork(null);
}
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
if (connectionMapContainsSide(possibleWireConnections, side))
{
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side);
if (getConnector(tileEntity) != null)
{
this.getNetwork().merge(getConnector(tileEntity).getNetwork());
}
}
}
this.currentWireConnections = possibleWireConnections;
}
this.currentAcceptorConnections = possibleAcceptorConnections;
this.getNetwork().reconstruct();
this.sendConnectionUpdate();
}
tile().markRender();
}
/**
* Should include connections that are in the current connection maps even if those connections
* aren't allowed any more. This is so that networks split correctly.
*/
@Override
public TileEntity[] getConnections()
{
TileEntity[] connections = new TileEntity[6];
for (byte i = 0; i < 6; i++)
{
ForgeDirection side = ForgeDirection.getOrientation(i);
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if (isCurrentlyConnected(side))
{
connections[i] = tileEntity;
}
}
return connections;
}
public boolean isCurrentlyConnected(ForgeDirection side)
{
return connectionMapContainsSide(getAllCurrentConnections(), side);
}
/**
* Shouldn't need to be overridden. Override connectionPrevented instead
*/
@Override
public boolean canConnect(ForgeDirection direction)
{
if (world().isBlockIndirectlyGettingPowered(x(), y(), z()))
{
return false;
}
Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction);
TileEntity connectTile = connectPos.getTileEntity(world());
return !isConnectionPrevented(connectTile, direction);
}
@Override
public void onAdded()
{
super.onAdded();
refresh();
}
@Override
public void onMoved()
{
this.refresh();
}
@Override
public void onChunkLoad()
{
super.onChunkLoad();
refresh();
}
@Override
public void onNeighborChanged()
{
super.onNeighborChanged();
refresh();
}
@Override
public void onPartChanged(TMultiPart part)
{
refresh();
}
public void copyFrom(PartFramedConnection<M, C, N> other)
{
this.isInsulated = other.isInsulated;
this.color = other.color;
this.connections = other.connections;
this.material = other.material;
this.currentWireConnections = other.currentWireConnections;
this.currentAcceptorConnections = other.currentAcceptorConnections;
this.setNetwork(other.getNetwork());
}
/**
* Packet Methods
*/
public void sendConnectionUpdate()
{
tile().getWriteStream(this).writeByte(0).writeByte(this.currentWireConnections).writeByte(this.currentAcceptorConnections);
}
@Override
public void readDesc(MCDataInput packet)
{
super.readDesc(packet);
this.currentWireConnections = packet.readByte();
this.currentAcceptorConnections = packet.readByte();
}
@Override
public void writeDesc(MCDataOutput packet)
{
super.writeDesc(packet);
packet.writeByte(this.currentWireConnections);
packet.writeByte(this.currentAcceptorConnections);
}
@Override
public void read(MCDataInput packet)
{
read(packet, packet.readUByte());
}
@Override
public void read(MCDataInput packet, int packetID)
{
if (packetID == 0)
{
this.currentWireConnections = packet.readByte();
this.currentAcceptorConnections = packet.readByte();
tile().markRender();
}
else
{
super.read(packet, packetID);
}
}
/**
* Network Methods
*/
@Override
public void setNetwork(N network)
{
this.network = network;
}
}

View file

@ -22,9 +22,8 @@ public class ClientProxy extends CommonProxy
public void init()
{
MinecraftForgeClient.registerItemRenderer(Mechanical.blockTank.blockID, new ItemTankRenderer());
MinecraftForgeClient.registerItemRenderer(Mechanical.blockPipe.blockID, new ItemPipeRenderer());
MinecraftForgeClient.registerItemRenderer(Mechanical.itemPipe.itemID, new ItemPipeRenderer());
MinecraftForgeClient.registerItemRenderer(Mechanical.blockReleaseValve.blockID, new ItemPipeRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TilePipe.class, new RenderPipe());
ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, RenderTank.INSTANCE);
}
}

View file

@ -3,15 +3,13 @@ package resonantinduction.mechanical;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import resonantinduction.mechanical.belt.BlockConveyorBelt;
import resonantinduction.mechanical.belt.TileConveyorBelt;
import resonantinduction.mechanical.fluid.pipe.BlockPipe;
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
import resonantinduction.mechanical.fluid.pipe.TilePipe;
import resonantinduction.mechanical.fluid.pipe.ItemPipe;
import resonantinduction.mechanical.fluid.pump.BlockGrate;
import resonantinduction.mechanical.fluid.pump.BlockPump;
import resonantinduction.mechanical.fluid.pump.TileGrate;
@ -30,7 +28,6 @@ import resonantinduction.mechanical.logistic.TileManipulator;
import resonantinduction.mechanical.logistic.TileRejector;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.recipe.UniversalRecipe;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@ -40,14 +37,13 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Resonant Induction Archaic Module
*
* @author DarkCow, Calclavia
*/
@Mod(modid = Mechanical.ID, name = Mechanical.NAME, version = Reference.VERSION, dependencies = "required-after:" + ResonantInduction.ID)
@Mod(modid = Mechanical.ID, name = Mechanical.NAME, version = Reference.VERSION, dependencies = "before:ThermalExpansion;required-after:" + ResonantInduction.ID)
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Mechanical
{
@ -78,11 +74,11 @@ public class Mechanical
// Fluids
public static Block blockTank;
public static Block blockPipe;
public static Block blockReleaseValve;
public static Block blockGrate;
public static Block blockPump;
public static Item itemPipe;
public static Item itemPipeGuage;
@EventHandler
@ -98,12 +94,12 @@ public class Mechanical
blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class);
blockTank = contentRegistry.createBlock(BlockTank.class, ItemBlockFluidContainer.class, TileTank.class);
blockPipe = contentRegistry.createBlock(BlockPipe.class, ItemBlockFluidContainer.class, TilePipe.class);
blockGrate = contentRegistry.createTile(BlockGrate.class, TileGrate.class);
blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class);
blockReleaseValve = contentRegistry.createTile(BlockReleaseValve.class, TileReleaseValve.class);
itemPipeGuage = contentRegistry.createItem(ItemPipeGauge.class);
itemPipe = contentRegistry.createItem(ItemPipe.class);
OreDictionary.registerOre("gear", itemGear);

View file

@ -1,5 +1,6 @@
package resonantinduction.mechanical;
import resonantinduction.mechanical.fluid.pipe.PartPipe;
import resonantinduction.mechanical.gear.PartGear;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
@ -10,11 +11,12 @@ public class MultipartMechanical implements IPartFactory
{
public static MultipartMechanical INSTANCE;
public static final String[] PART_TYPES = { "resonant_induction_gear" };
public static final String[] PART_TYPES = { "resonant_induction_gear", "resonant_induction_pipe" };
public MultipartMechanical()
{
MultiPartRegistry.registerParts(this, PART_TYPES);
MultipartGenerator.registerPassThroughInterface("resonantinduction.api.fluid.IFluidConnector");
MultipartGenerator.registerTrait("resonantinduction.mechanical.network.IMechanical", "resonantinduction.mechanical.trait.TraitMechanical");
MultipartGenerator.registerTrait("resonantinduction.mechanical.network.IMechanicalConnector", "resonantinduction.mechanical.trait.TraitMechanicalConnector");
}
@ -26,6 +28,8 @@ public class MultipartMechanical implements IPartFactory
{
case "resonant_induction_gear":
return new PartGear();
case "resonant_induction_pipe":
return new PartPipe();
}
return null;

View file

@ -1,4 +1,4 @@
package resonantinduction.mechanical.fluid.pipe;
package resonantinduction.mechanical.fluid.network;
import java.util.EnumSet;
import java.util.HashMap;
@ -10,7 +10,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IFluidConnector;
import resonantinduction.api.fluid.IFluidPipe;
import resonantinduction.mechanical.fluid.network.FluidNetwork;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.utility.FluidUtility;

View file

@ -1,148 +0,0 @@
package resonantinduction.mechanical.fluid.pipe;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidTank;
import resonantinduction.core.render.RIBlockRenderingHandler;
import resonantinduction.mechanical.fluid.prefab.BlockFluidNetwork;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.ColorCode;
import calclavia.lib.render.ColorCode.IColorCoded;
import calclavia.lib.utility.FluidUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPipe extends BlockFluidNetwork
{
public static int waterFlowRate = 3000;
public BlockPipe()
{
super("fluidPipe");
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
this.setHardness(1f);
this.setResistance(3f);
}
@Override
public void fillWithRain(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == FluidContainerMaterial.WOOD.ordinal() || meta == FluidContainerMaterial.STONE.ordinal())
{
// TODO fill pipe since it will have an open top and can gather rain
}
}
@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity instanceof TilePipe)
{
ret.add(new ItemStack(this, 1, FluidContainerMaterial.getDropItemMeta(world, x, y, z)));
}
return ret;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return RIBlockRenderingHandler.ID;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TilePipe();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(this, 1, FluidContainerMaterial.getDropItemMeta(world, x, y, z));
}
@Override
public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
{
return false;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == FluidContainerMaterial.HELL.ordinal())
{
return 5;
}
return super.getLightValue(world, x, y, z);
}
@Override
public boolean isLadder(World world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (FluidContainerMaterial data : FluidContainerMaterial.values())
{
par3List.add(data.getStack());
}
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity instanceof TilePipe)
{
FluidTank tank = ((TilePipe) entity).getInternalTank();
if (tank != null && tank.getFluid() != null)
{
FluidUtility.fillBlock(world, new Vector3(x, y, z), tank.getFluid(), true);
}
}
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
if (world.getBlockTileEntity(x, y, z) instanceof IColorCoded)
{
return ((IColorCoded) world.getBlockTileEntity(x, y, z)).setColor(ColorCode.get(colour));
}
return false;
}
}

View file

@ -21,7 +21,7 @@ import calclavia.lib.render.ColorCode;
*
* @author DarkGuardsman
*/
public enum FluidContainerMaterial
public enum EnumPipeMaterial
{
/** Simple water only pipe. Should render open toped when it can */
WOOD("wood", false, true, false, -1, 200),
@ -65,14 +65,14 @@ public enum FluidContainerMaterial
*/
public static int spacing = 1000;
private FluidContainerMaterial()
private EnumPipeMaterial()
{
this.canSupportGas = true;
this.canSupportFluids = true;
canSupportMoltenFluids = true;
}
private FluidContainerMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings)
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings)
{
this.matName = name;
this.canSupportGas = gas;
@ -80,28 +80,28 @@ public enum FluidContainerMaterial
this.canSupportMoltenFluids = molten;
}
private FluidContainerMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings)
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings)
{
this(name, gas, fluid, molten, strings);
this.maxPressure = pressure;
this.maxVolume = volume;
}
public static FluidContainerMaterial get(World world, int x, int y, int z)
public static EnumPipeMaterial get(World world, int x, int y, int z)
{
return get(world.getBlockMetadata(x, y, z));
}
public static FluidContainerMaterial get(int i)
public static EnumPipeMaterial get(int i)
{
if (i < FluidContainerMaterial.values().length)
if (i < EnumPipeMaterial.values().length)
{
return FluidContainerMaterial.values()[i];
return EnumPipeMaterial.values()[i];
}
return null;
}
public static FluidContainerMaterial get(ItemStack stack)
public static EnumPipeMaterial get(ItemStack stack)
{
if (stack != null)
{
@ -110,34 +110,14 @@ public enum FluidContainerMaterial
return null;
}
public static FluidContainerMaterial getFromItemMeta(int meta)
public static EnumPipeMaterial getFromItemMeta(int meta)
{
meta = meta / spacing;
if (meta < FluidContainerMaterial.values().length)
if (meta < EnumPipeMaterial.values().length)
{
return FluidContainerMaterial.values()[meta];
return EnumPipeMaterial.values()[meta];
}
return FluidContainerMaterial.WOOD;
}
public ItemStack getStack()
{
return getStack(1);
}
public ItemStack getStack(ColorCode color)
{
return getStack(1, color);
}
public ItemStack getStack(int s)
{
return new ItemStack(Mechanical.blockPipe, s, (this.ordinal() * spacing));
}
public ItemStack getStack(int s, ColorCode color)
{
return new ItemStack(Mechanical.blockPipe, s, (this.ordinal() * spacing) + color.ordinal() + 1);
return EnumPipeMaterial.WOOD;
}
public int getMeta(int typeID)

View file

@ -115,7 +115,7 @@ public class ItemBlockFluidContainer extends ItemBlock
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / FluidContainerMaterial.spacing)))
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / EnumPipeMaterial.spacing)))
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidNetwork)

View file

@ -0,0 +1,26 @@
package resonantinduction.mechanical.fluid.pipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.ItemMultipartBase;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
public class ItemPipe extends ItemMultipartBase
{
public ItemPipe()
{
super("pipe", Settings.getNextItemID());
}
@Override
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
{
PartPipe part = (PartPipe) MultiPartRegistry.createPart("resonant_induction_pipe", false);
return part;
}
}

View file

@ -39,7 +39,7 @@ public class ItemPipeRenderer implements IItemRenderer
if (Mechanical.blockReleaseValve != null && item.itemID == Mechanical.blockReleaseValve.blockID)
{
meta = FluidContainerMaterial.IRON.getMeta();
meta = EnumPipeMaterial.IRON.getMeta();
}
if (type == ItemRenderType.ENTITY)
{

View file

@ -0,0 +1,154 @@
package resonantinduction.mechanical.fluid.pipe;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IFluidConnector;
import resonantinduction.api.fluid.IFluidNetwork;
import resonantinduction.core.prefab.part.PartFramedConnection;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.fluid.network.PipeNetwork;
import codechicken.microblock.IHollowConnect;
import codechicken.multipart.JIconHitEffects;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.TSlottedPart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidConnector, IFluidNetwork> implements IFluidConnector, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
{
/** Client Side Connection Check */
private ForgeDirection testingSide;
public Object[] connections = new Object[6];
/** Network used to link all parts together */
protected IFluidNetwork network;
protected FluidTank tank = new FluidTank(1 * FluidContainerRegistry.BUCKET_VOLUME);
/**
* Bitmask connections
*/
public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00;
public PartPipe()
{
super();
material = EnumPipeMaterial.COPPER;
}
public PartPipe(int typeID)
{
material = EnumPipeMaterial.values()[typeID];
}
@Override
public String getType()
{
return "resonant_induction_pipe";
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
{
RenderPipe.INSTANCE.render(this, pos.x, pos.y, pos.z, frame);
}
@Override
public void setMaterial(int i)
{
setMaterial(EnumPipeMaterial.values()[i]);
}
@Override
protected ItemStack getItem()
{
return new ItemStack(Mechanical.itemPipe);
}
/**
* Fluid network methods.
*/
@Override
public IFluidNetwork getNetwork()
{
if (this.network == null)
{
this.network = new PipeNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
return this.getNetwork().fill(this, from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
return this.getNetwork().drain(this, from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return this.getNetwork().drain(this, from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
return this.getNetwork().getTankInfo();
}
@Override
public void onFluidChanged()
{
}
@Override
public FluidTank getInternalTank()
{
if (this.tank == null)
{
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
}
return this.tank;
}
@Override
protected boolean canConnectTo(TileEntity tile)
{
return tile instanceof IFluidHandler;
}
@Override
protected IFluidConnector getConnector(TileEntity tile)
{
return tile instanceof IFluidConnector ? (IFluidConnector) tile : null;
}
}

View file

@ -2,131 +2,46 @@ package resonantinduction.mechanical.fluid.pipe;
import java.util.HashMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference;
import resonantinduction.core.render.RenderFluidHelper;
import resonantinduction.mechanical.fluid.prefab.TileFluidNetwork;
import com.builtbroken.common.Pair;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderPipe extends TileEntitySpecialRenderer
public class RenderPipe
{
public static final RenderPipe INSTANCE = new RenderPipe();
public static ModelPipe MODEL_PIPE = new ModelPipe();
public static ModelOpenTrough MODEL_TROUGH_PIPE = new ModelOpenTrough();
private static HashMap<Pair<FluidContainerMaterial, Integer>, ResourceLocation> TEXTURES = new HashMap<Pair<FluidContainerMaterial, Integer>, ResourceLocation>();
private static HashMap<Pair<EnumPipeMaterial, Integer>, ResourceLocation> TEXTURES = new HashMap<Pair<EnumPipeMaterial, Integer>, ResourceLocation>();
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "pipe/iron.png");
@Override
public void renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f)
public void render(PartPipe part, double x, double y, double z, float f)
{
FluidContainerMaterial mat = FluidContainerMaterial.IRON;
if (te.getBlockMetadata() < FluidContainerMaterial.values().length)
{
mat = FluidContainerMaterial.values()[te.getBlockMetadata()];
}
if (te instanceof TilePipe)
{
TilePipe tile = (TilePipe) te;
if (mat == FluidContainerMaterial.WOOD || mat == FluidContainerMaterial.STONE)
{
FluidStack liquid = tile.getInternalTank().getFluid();
int cap = tile.getInternalTank().getCapacity();
// FluidStack liquid = new FluidStack(FluidRegistry.WATER, cap);
if (liquid != null && liquid.amount > 100)
{
float per = Math.max(1, (float) liquid.amount / (float) (cap));
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, te.worldObj, false);
bindTexture(RenderFluidHelper.getFluidSheet(liquid));
EnumPipeMaterial material = part.getMaterial();
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.3F);
GL11.glScalef(0.4F, 0.4F, 0.4F);
GL11.glCallList(displayList[(int) (per * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
if (tile.canRenderSide(direction) && direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
{
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);
switch (direction.ordinal())
{
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.glPopAttrib();
GL11.glPopMatrix();
}
}
}
}
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
bindTexture(RenderPipe.getTexture(mat, 0));
render(mat, tile.getSubID(), tile.renderSides);
GL11.glPopMatrix();
}
else
{
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
render(mat, 0, (byte) 0b0);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(getTexture(material, 0));
render(material, part.getMaterialID(), part.getAllCurrentConnections());
GL11.glPopMatrix();
}
}
public static ResourceLocation getTexture(FluidContainerMaterial mat, int pipeID)
public static ResourceLocation getTexture(EnumPipeMaterial mat, int pipeID)
{
if (mat != null)
{
Pair<FluidContainerMaterial, Integer> index = new Pair<FluidContainerMaterial, Integer>(mat, pipeID);
Pair<EnumPipeMaterial, Integer> index = new Pair<EnumPipeMaterial, Integer>(mat, pipeID);
if (!TEXTURES.containsKey(index))
{
@ -144,16 +59,16 @@ public class RenderPipe extends TileEntitySpecialRenderer
public static ResourceLocation getTexture(int meta)
{
return getTexture(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta));
return getTexture(EnumPipeMaterial.getFromItemMeta(meta), EnumPipeMaterial.getType(meta));
}
public static void render(FluidContainerMaterial mat, int pipeID, byte side)
public static void render(EnumPipeMaterial mat, int pipeID, byte side)
{
if (mat == FluidContainerMaterial.WOOD)
if (mat == EnumPipeMaterial.WOOD)
{
MODEL_TROUGH_PIPE.render(side, false);
}
else if (mat == FluidContainerMaterial.STONE)
else if (mat == EnumPipeMaterial.STONE)
{
MODEL_TROUGH_PIPE.render(side, true);
}
@ -190,7 +105,7 @@ public class RenderPipe extends TileEntitySpecialRenderer
public static void render(int meta, byte sides)
{
render(FluidContainerMaterial.getFromItemMeta(meta), FluidContainerMaterial.getType(meta), sides);
render(EnumPipeMaterial.getFromItemMeta(meta), EnumPipeMaterial.getType(meta), sides);
}
}

View file

@ -6,6 +6,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IFluidNetwork;
import resonantinduction.api.fluid.IFluidPipe;
import resonantinduction.mechanical.fluid.network.PipeNetwork;
import resonantinduction.mechanical.fluid.prefab.TileFluidNetwork;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.ColorCode;
@ -37,10 +38,10 @@ public class TilePipe extends TileFluidNetwork implements IColorCoded, IFluidPip
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{
int meta = new Vector3(this).getBlockMetadata(this.worldObj);
if (meta < FluidContainerMaterial.values().length)
if (meta < EnumPipeMaterial.values().length)
{
FluidContainerMaterial pipeMat = FluidContainerMaterial.values()[meta];
if (pipeMat == FluidContainerMaterial.WOOD || pipeMat == FluidContainerMaterial.STONE)
EnumPipeMaterial pipeMat = EnumPipeMaterial.values()[meta];
if (pipeMat == EnumPipeMaterial.WOOD || pipeMat == EnumPipeMaterial.STONE)
{
if (side == ForgeDirection.UP)
{
@ -51,10 +52,10 @@ public class TilePipe extends TileFluidNetwork implements IColorCoded, IFluidPip
if (tileEntity instanceof TilePipe)
{
int metaOther = new Vector3(tileEntity).getBlockMetadata(this.worldObj);
if (meta < FluidContainerMaterial.values().length && metaOther < FluidContainerMaterial.values().length)
if (meta < EnumPipeMaterial.values().length && metaOther < EnumPipeMaterial.values().length)
{
FluidContainerMaterial pipeMat = FluidContainerMaterial.values()[meta];
FluidContainerMaterial pipeMatOther = FluidContainerMaterial.values()[metaOther];
EnumPipeMaterial pipeMat = EnumPipeMaterial.values()[meta];
EnumPipeMaterial pipeMatOther = EnumPipeMaterial.values()[metaOther];
// Same pipe types can connect
if (pipeMat == pipeMatOther)
{
@ -62,7 +63,7 @@ public class TilePipe extends TileFluidNetwork implements IColorCoded, IFluidPip
connectedBlocks[side.ordinal()] = tileEntity;
setRenderSide(side, true);
}
else if ((pipeMat == FluidContainerMaterial.WOOD || pipeMat == FluidContainerMaterial.STONE) && (pipeMatOther == FluidContainerMaterial.WOOD || pipeMatOther == FluidContainerMaterial.STONE))
else if ((pipeMat == EnumPipeMaterial.WOOD || pipeMat == EnumPipeMaterial.STONE) && (pipeMatOther == EnumPipeMaterial.WOOD || pipeMatOther == EnumPipeMaterial.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
@ -70,7 +71,7 @@ public class TilePipe extends TileFluidNetwork implements IColorCoded, IFluidPip
connectedBlocks[side.ordinal()] = tileEntity;
setRenderSide(side, true);
}
else if (pipeMat != FluidContainerMaterial.WOOD && pipeMat != FluidContainerMaterial.STONE && pipeMatOther != FluidContainerMaterial.WOOD && pipeMatOther != FluidContainerMaterial.STONE && pipeMat != FluidContainerMaterial.GLASS && pipeMatOther != FluidContainerMaterial.GLASS)
else if (pipeMat != EnumPipeMaterial.WOOD && pipeMat != EnumPipeMaterial.STONE && pipeMatOther != EnumPipeMaterial.WOOD && pipeMatOther != EnumPipeMaterial.STONE && pipeMat != EnumPipeMaterial.GLASS && pipeMatOther != EnumPipeMaterial.GLASS)
{
/*
* Any other pipe can connect to each other as long as the color matches except
@ -113,7 +114,7 @@ public class TilePipe extends TileFluidNetwork implements IColorCoded, IFluidPip
@Override
public void sendTankUpdate()
{
if (this.getBlockMetadata() == FluidContainerMaterial.WOOD.ordinal() || this.getBlockMetadata() == FluidContainerMaterial.STONE.ordinal())
if (this.getBlockMetadata() == EnumPipeMaterial.WOOD.ordinal() || this.getBlockMetadata() == EnumPipeMaterial.STONE.ordinal())
{
super.sendTankUpdate();
}

View file

@ -15,7 +15,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IDrain;
import resonantinduction.api.fluid.IFluidPipe;
import resonantinduction.core.tilenetwork.ITileConnector;
import resonantinduction.mechanical.fluid.pipe.PipeNetwork;
import resonantinduction.mechanical.fluid.network.PipeNetwork;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;

View file

@ -11,7 +11,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonantinduction.core.render.RIBlockRenderingHandler;
import resonantinduction.mechanical.fluid.pipe.FluidContainerMaterial;
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
import resonantinduction.mechanical.fluid.pipe.TilePipe;
import resonantinduction.mechanical.fluid.prefab.BlockFluidNetwork;
@ -89,7 +89,7 @@ public class BlockTank extends BlockFluidNetwork
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(this, 1, FluidContainerMaterial.getDropItemMeta(world, x, y, z));
return new ItemStack(this, 1, EnumPipeMaterial.getDropItemMeta(world, x, y, z));
}
@Override
@ -99,7 +99,7 @@ public class BlockTank extends BlockFluidNetwork
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity instanceof TilePipe)
{
ret.add(new ItemStack(this, 1, FluidContainerMaterial.getDropItemMeta(world, x, y, z)));
ret.add(new ItemStack(this, 1, EnumPipeMaterial.getDropItemMeta(world, x, y, z)));
}
return ret;
}
@ -108,9 +108,9 @@ public class BlockTank extends BlockFluidNetwork
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (FluidContainerMaterial data : FluidContainerMaterial.values())
for (EnumPipeMaterial data : EnumPipeMaterial.values())
{
par3List.add(new ItemStack(this, 1, data.ordinal() * FluidContainerMaterial.spacing));
par3List.add(new ItemStack(this, 1, data.ordinal() * EnumPipeMaterial.spacing));
break;
}
}