starting to look better

Still have a ton of work too just update all method and remove errors.
Though it is starting to look better and better by the min.
This commit is contained in:
DarkGuardsman 2013-07-09 14:25:58 -04:00
parent d5fc3aaf85
commit e096748451
22 changed files with 151 additions and 713 deletions

View file

@ -19,8 +19,8 @@ public class FluidPressurePack implements Cloneable
return new FluidPressurePack(this.liquidStack, this.pressure);
}
public boolean isEqual(FluidPressurePack electricityPack)
public boolean isEqual(FluidPressurePack packet)
{
return this.liquidStack.isLiquidEqual(electricityPack.liquidStack) && this.pressure == electricityPack.pressure;
return this.liquidStack.isFluidEqual(packet.liquidStack) && this.pressure == packet.pressure;
}
}

View file

@ -26,7 +26,7 @@ public class HydraulicNetworkHelper
if (network != null && network instanceof NetworkFluidTiles)
{
network.removeEntity(tileEntity);
network.removeTile(tileEntity);
for (IFluidHandler tank : ((NetworkFluidTiles) network).connectedTanks)
{
if (tank instanceof IDrain)

View file

@ -6,11 +6,11 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.IFluidHandler;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
import dark.core.api.ColorCode;
@ -24,10 +24,10 @@ import dark.helpers.ConnectionHelper;
public class NetworkFluidTiles extends NetworkTileEntities
{
/* MACHINES THAT ARE FLUID BASED AND CONNECTED BUT NOT PART OF THE NETWORK ** */
public final List<ITankContainer> connectedTanks = new ArrayList<ITankContainer>();
public final List<IFluidHandler> connectedTanks = new ArrayList<IFluidHandler>();
/* COMBINED TEMP STORAGE FOR ALL PIPES IN THE NETWORK */
public LiquidTank sharedTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
public FluidTank sharedTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
public ColorCode color = ColorCode.NONE;
protected boolean loadedLiquids = false;
@ -44,20 +44,20 @@ public class NetworkFluidTiles extends NetworkTileEntities
return new NetworkFluidTiles(this.color);
}
public LiquidTank combinedStorage()
public FluidTank combinedStorage()
{
if (this.sharedTank == null)
{
this.sharedTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
this.sharedTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
this.balanceColletiveTank(true);
}
return this.sharedTank;
}
/** Stores Fluid in this network's collective tank */
public int storeFluidInSystem(LiquidStack stack, boolean doFill)
public int storeFluidInSystem(FluidStack stack, boolean doFill)
{
if (stack == null || this.combinedStorage().containsValidLiquid() && (this.combinedStorage().getLiquid() != null && !this.combinedStorage().getLiquid().isLiquidEqual(stack)))
if (stack == null || this.combinedStorage() != null && (this.combinedStorage().getFluid() != null && !this.combinedStorage().getFluid().isFluidEqual(stack)))
{
return 0;
}
@ -65,7 +65,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
{
this.balanceColletiveTank(true);
}
if (this.combinedStorage().getLiquid() == null || this.combinedStorage().getLiquid().amount < this.combinedStorage().getCapacity())
if (this.combinedStorage().getFluid() == null || this.combinedStorage().getFluid().amount < this.combinedStorage().getCapacity())
{
int filled = this.combinedStorage().fill(stack, doFill);
if (doFill)
@ -78,16 +78,16 @@ public class NetworkFluidTiles extends NetworkTileEntities
}
/** Drains the network's collective tank */
public LiquidStack drainFluidFromSystem(int maxDrain, boolean doDrain)
public FluidStack drainFluidFromSystem(int maxDrain, boolean doDrain)
{
if (!loadedLiquids)
{
this.balanceColletiveTank(true);
}
LiquidStack stack = this.combinedStorage().getLiquid();
FluidStack stack = this.combinedStorage().getFluid();
if (stack != null)
{
stack = this.combinedStorage().getLiquid().copy();
stack = this.combinedStorage().getFluid().copy();
if (maxDrain < stack.amount)
{
stack = FluidHelper.getStack(stack, maxDrain);
@ -107,7 +107,8 @@ public class NetworkFluidTiles extends NetworkTileEntities
* @param sumParts - loads the volume from the parts before leveling out the volumes */
public void balanceColletiveTank(boolean sumParts)
{
int volume = 0, itemID = 0, itemMeta = 0;
Fluid fluid = null;
int volume = 0;
if (sumParts)
{
@ -116,26 +117,24 @@ public class NetworkFluidTiles extends NetworkTileEntities
if (par instanceof INetworkFluidPart)
{
INetworkFluidPart part = ((INetworkFluidPart) par);
if (part.getTank() != null && part.getTank().getLiquid() != null)
if (part.getTank() != null && part.getTank().getFluid() != null)
{
if (itemID == 0)
if (fluid == null)
{
itemID = part.getTank().getLiquid().itemID;
itemMeta = part.getTank().getLiquid().itemMeta;
fluid = part.getTank().getFluid().getFluid();
}
volume += part.getTank().getLiquid().amount;
volume += part.getTank().getFluid().amount;
}
}
}
this.combinedStorage().setLiquid(new LiquidStack(itemID, volume, itemMeta));
this.combinedStorage().setFluid(new FluidStack(fluid, volume));
this.loadedLiquids = true;
}
if (this.combinedStorage().getLiquid() != null && this.networkMember.size() > 0)
if (this.combinedStorage().getFluid() != null && this.networkMember.size() > 0)
{
volume = this.combinedStorage().getLiquid().amount / this.networkMember.size();
itemID = this.combinedStorage().getLiquid().itemID;
itemMeta = this.combinedStorage().getLiquid().itemMeta;
volume = this.combinedStorage().getFluid().amount / this.networkMember.size();
fluid = this.combinedStorage().getFluid().getFluid();
for (INetworkPart par : this.networkMember)
{
@ -143,25 +142,24 @@ public class NetworkFluidTiles extends NetworkTileEntities
{
INetworkFluidPart part = ((INetworkFluidPart) par);
part.setTankContent(null);
part.setTankContent(new LiquidStack(itemID, volume, itemMeta));
part.setTankContent(new FluidStack(fluid, volume));
}
}
}
}
@Override
public void removeEntity(TileEntity ent)
public boolean removeTile(TileEntity ent)
{
super.removeEntity(ent);
this.connectedTanks.remove(ent);
return super.removeTile(ent) || this.connectedTanks.remove(ent);
}
@Override
public boolean addTile(TileEntity ent, boolean member)
{
if (!(super.addTile(ent, member)) && ent instanceof ITankContainer && !connectedTanks.contains(ent))
if (!(super.addTile(ent, member)) && ent instanceof IFluidHandler && !connectedTanks.contains(ent))
{
connectedTanks.add((ITankContainer) ent);
connectedTanks.add((IFluidHandler) ent);
return true;
}
return false;
@ -178,7 +176,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
return super.isPartOfNetwork(ent) || this.connectedTanks.contains(ent);
}
public void causingMixing(INetworkPart Fluid, LiquidStack stack, LiquidStack stack2)
public void causingMixing(INetworkPart Fluid, FluidStack stack, FluidStack stack2)
{
// TODO cause mixing of liquids based on types and volume. Also apply damage to pipes/parts
// as needed
@ -262,20 +260,20 @@ public class NetworkFluidTiles extends NetworkTileEntities
this.balanceColletiveTank(true);
network.balanceColletiveTank(true);
LiquidStack stack = new LiquidStack(0, 0, 0);
FluidStack stack = new FluidStack(0, 0);
if (this.combinedStorage().getLiquid() != null && network.combinedStorage().getLiquid() != null && this.combinedStorage().getLiquid().isLiquidEqual(network.combinedStorage().getLiquid()))
if (this.combinedStorage().getFluid() != null && network.combinedStorage().getFluid() != null && this.combinedStorage().getFluid().isFluidEqual(network.combinedStorage().getFluid()))
{
stack = this.combinedStorage().getLiquid();
stack.amount += network.combinedStorage().getLiquid().amount;
stack = this.combinedStorage().getFluid();
stack.amount += network.combinedStorage().getFluid().amount;
}
else if (this.combinedStorage().getLiquid() == null && network.combinedStorage().getLiquid() != null)
else if (this.combinedStorage().getFluid() == null && network.combinedStorage().getFluid() != null)
{
stack = network.combinedStorage().getLiquid();
stack = network.combinedStorage().getFluid();
}
else if (this.combinedStorage().getLiquid() != null && network.combinedStorage().getLiquid() == null)
else if (this.combinedStorage().getFluid() != null && network.combinedStorage().getFluid() == null)
{
stack = this.combinedStorage().getLiquid();
stack = this.combinedStorage().getFluid();
}
return true;
}
@ -335,9 +333,13 @@ public class NetworkFluidTiles extends NetworkTileEntities
public String getNetworkFluid()
{
int cap = combinedStorage().getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME;
int vol = combinedStorage().getLiquid() != null ? (combinedStorage().getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME) : 0;
String name = LiquidDictionary.findLiquidName(this.combinedStorage().getLiquid()) != null ? LiquidDictionary.findLiquidName(this.combinedStorage().getLiquid()) : "Unkown";
return String.format("%d/%d %S Stored", vol, cap, name);
if (combinedStorage() != null && combinedStorage().getFluid() != null && combinedStorage().getFluid().getFluid() != null)
{
int cap = combinedStorage().getCapacity() / FluidContainerRegistry.BUCKET_VOLUME;
int vol = combinedStorage().getFluid() != null ? (combinedStorage().getFluid().amount / FluidContainerRegistry.BUCKET_VOLUME) : 0;
String name = combinedStorage().getFluid().getFluid().getLocalizedName();
return String.format("%d/%d %S Stored", vol, cap, name);
}
return ("As far as you can tell it is empty");
}
}

View file

@ -175,9 +175,9 @@ public class NetworkPipes extends NetworkFluidTiles
}
@Override
public void removeEntity(TileEntity ent)
public void removeTile(TileEntity ent)
{
super.removeEntity(ent);
super.removeTile(ent);
this.pressureLoads.remove(ent);
this.pressureProducers.remove(ent);
}

View file

@ -1,6 +1,7 @@
package dark.fluid.api;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
@ -25,7 +26,7 @@ public interface IDrain extends IFluidHandler
*
* @param pump - requesting pump
* @param stack - liquid this pump wants for this request */
public void requestLiquid(TileEntity pump, FluidStack stack);
public void requestLiquid(TileEntity pump, Fluid fluid, int amount);
/** Request that this drain no longer supply the pump with a volume. By default a request will be
* removed from the request map after being filled. However, this can be used too stop a request

View file

@ -1,37 +1,29 @@
package dark.fluid.api;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.fluids.Fluid;
/**
* A machine that acts as one with the liquid network using the networks pressure for some function
/** A machine that acts as one with the liquid network using the networks pressure for some function
* that doesn't change the over all network pressure. So pipes, gauges, tubes, buffers, decor
* blocks.
*/
* blocks. */
public interface INetworkPipe extends INetworkFluidPart
{
/**
* Gets the parts max pressure limit it can handle
/** Gets the parts max pressure limit it can handle
*
* Note this is not recommended max limit by rather actual breaking point of the part
*/
* Note this is not recommended max limit by rather actual breaking point of the part */
public double getMaxPressure(ForgeDirection side);
/**
* Max flow rate of liquid flow this part from the side for the liquid type that his part will
/** Max flow rate of liquid flow this part from the side for the liquid type that his part will
* allow
*
* @return limit in bucket parts(1/1000 of a bucket)
*/
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side);
* @return limit in bucket parts(1/1000 of a bucket) */
public int getMaxFlowRate(Fluid stack, ForgeDirection side);
/**
* Called when the pressure on the machine goes beyond max limits. Suggest doing random chance
/** Called when the pressure on the machine goes beyond max limits. Suggest doing random chance
* of damage or break too simulate real chances of pipe going beyond designed limits
*
* @param damageAllowed - can this tileEntity cause grief damage
* @return true if the device over pressured and destroyed itself
*/
* @return true if the device over pressured and destroyed itself */
public boolean onOverPressure(Boolean damageAllowed);
}

View file

@ -8,11 +8,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockReleaseValve extends BlockAdvanced
public class BlockReleaseValve extends BlockMachine
{
public BlockReleaseValve(int par1)
{

View file

@ -1,27 +1,20 @@
package dark.fluid.common.machines;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import dark.core.hydraulic.helpers.FluidHelper;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.TabFluidMech;
import dark.helpers.MetaGroup;
import dark.library.machine.BlockMachine;
public class BlockSink extends BlockAdvanced
public class BlockSink extends BlockMachine
{
public BlockSink(int par1)
{
@ -38,95 +31,6 @@ public class BlockSink extends BlockAdvanced
return new TileEntitySink();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float hitX, float hitY, float hitZ)
{
if (entityplayer.isSneaking())
{
return false;
}
ItemStack current = entityplayer.inventory.getCurrentItem();
if (current != null)
{
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(current);
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEntitySink)
{
TileEntitySink tank = (TileEntitySink) tileEntity;
// Handle filled containers
if (liquid != null)
{
if (current.isItemEqual(new ItemStack(Item.potion)))
{
liquid = new LiquidStack(liquid.itemID, (LiquidContainerRegistry.BUCKET_VOLUME / 4), liquid.itemMeta);
}
int filled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (filled != 0 && !entityplayer.capabilities.isCreativeMode)
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
}
return true;
// Handle empty containers
}
else
{
if (current.getItem() instanceof ItemArmor && ((ItemArmor) current.getItem()).getArmorMaterial() == EnumArmorMaterial.CLOTH)
{
ItemArmor var13 = (ItemArmor) current.getItem();
var13.removeColor(current);
return true;
}
LiquidStack stack = tank.getStoredLiquid();
if (stack != null)
{
ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current);
liquid = LiquidContainerRegistry.getLiquidForFilledItem(liquidItem);
if (liquid != null)
{
if (!entityplayer.capabilities.isCreativeMode)
{
if (current.stackSize > 1)
{
if (!entityplayer.inventory.addItemStackToInventory(liquidItem))
return false;
else
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
}
}
else
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem);
}
}
int ammount = liquid.amount;
if (current.isItemEqual(new ItemStack(Item.glassBottle)))
{
ammount = (LiquidContainerRegistry.BUCKET_VOLUME / 4);
}
tank.drain(null, ammount, true);
return true;
}
}
}
}
}
return false;
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
@ -149,7 +53,7 @@ public class BlockSink extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving, ItemStack itemStack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack itemStack)
{
int meta = world.getBlockMetadata(x, y, z);
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

View file

@ -11,16 +11,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.core.api.INetworkPart;
import dark.core.hydraulic.helpers.FluidHelper;
import dark.core.hydraulic.helpers.FluidRestrictionHandler;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockTank extends BlockAdvanced
public class BlockTank extends BlockMachine
{
public BlockTank(int id)

View file

@ -1,12 +1,11 @@
package dark.fluid.common.pump;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -16,13 +15,13 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.core.network.fluid.HydraulicNetworkHelper;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockConstructionPump extends BlockAdvanced
public class BlockConstructionPump extends BlockMachine
{
Icon inputIcon;
Icon outputIcon;
@ -96,7 +95,7 @@ public class BlockConstructionPump extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving p, ItemStack itemStack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p, ItemStack itemStack)
{
}
@ -118,13 +117,13 @@ public class BlockConstructionPump extends BlockAdvanced
{
int meta = world.getBlockMetadata(x, y, z);
int angle = MathHelper.floor_double((entityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity instanceof TileEntityConstructionPump)
{
HydraulicNetworkHelper.invalidate(entity);
}
if (meta == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 0, 3);

View file

@ -2,7 +2,7 @@ package dark.fluid.common.pump;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -11,11 +11,11 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockDrain extends BlockAdvanced
public class BlockDrain extends BlockMachine
{
private Icon blockIcon;
private Icon drainIcon;
@ -73,7 +73,7 @@ public class BlockDrain extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving p, ItemStack itemStack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p, ItemStack itemStack)
{
int angle = MathHelper.floor_double((p.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, angle, 3);

View file

@ -1,24 +1,23 @@
package dark.fluid.common.pump;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
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.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.helpers.MetaGroup;
import dark.library.machine.BlockMachine;
public class BlockPumpMachine extends BlockAdvanced
public class BlockPumpMachine extends BlockMachine
{
public BlockPumpMachine(int id)
@ -73,7 +72,7 @@ public class BlockPumpMachine extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving p, ItemStack itemStack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p, ItemStack itemStack)
{
int meta = world.getBlockMetadata(x, y, z);
int angle = MathHelper.floor_double((p.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

View file

@ -2,12 +2,12 @@ package dark.fluid.common.pump;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.core.electricity.ElectricityPack;
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 universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import dark.core.api.ITileConnector;
@ -17,16 +17,20 @@ import dark.fluid.api.INetworkPipe;
import dark.helpers.MetaGroup;
import dark.library.machine.TileEntityRunnableMachine;
public class TileEntityConstructionPump extends TileEntityRunnableMachine implements ITankContainer, ITileConnector
public class TileEntityConstructionPump extends TileEntityRunnableMachine implements IFluidHandler, ITileConnector
{
/* ENERGY PER TICK TO TRY TO PUMP */
public static final double WATTS_PER_TICK = 100;
/* LIQUID FLOW CONNECTION SIDES */
/* Fake Internal Tank */
private LiquidTank fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
/** Internal tank for interaction but not real storage */
private FluidTank fakeTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
private int liquidRequest = 5;
public int rotation = 0;
public TileEntityConstructionPump()
{
super(100);
// TODO Auto-generated constructor stub
}
@Override
public void initiate()
{
@ -58,11 +62,8 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
super.updateEntity();
if (!worldObj.isRemote)
{
if (this.ticks % 10 == 0 && this.wattsReceived >= this.WATTS_PER_TICK) // TODO add
// electric
// Drain
if (this.ticks % 10 == 0 && this.canRun())
{
this.wattsReceived -= this.WATTS_PER_TICK;
this.rotation += 1;
if (rotation >= 7)
{
@ -74,13 +75,13 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), getFacing(false));
if (inputTile instanceof INetworkPipe && ((INetworkPipe) inputTile).getTileNetwork() instanceof NetworkFluidTiles)
{
if (outputTile instanceof ITankContainer)
if (outputTile instanceof IFluidHandler)
{
for (ITankContainer tank : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connectedTanks)
for (IFluidHandler tank : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connectedTanks)
{
if (tank instanceof TileEntityDrain)
{
((TileEntityDrain) tank).requestLiquid(this, new LiquidStack(-1, liquidRequest * LiquidContainerRegistry.BUCKET_VOLUME));
((TileEntityDrain) tank).requestLiquid(this, null, liquidRequest * FluidContainerRegistry.BUCKET_VOLUME);
called = true;
}
@ -92,12 +93,6 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
}
}
@Override
public double getRequest(ForgeDirection direction)
{
return WATTS_PER_TICK;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
@ -105,67 +100,59 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
}
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
if (from != getFacing(true))
{
return 0;
}
return this.fill(0, resource, doFill);
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
if (tankIndex != 0 || resource == null)
{
return 0;
}
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), getFacing(false));
if (entity instanceof ITankContainer)
if (entity instanceof IFluidHandler)
{
return ((ITankContainer) entity).fill(getFacing(false).getOpposite(), resource, doFill);
return ((IFluidHandler) entity).fill(getFacing(false).getOpposite(), resource, doFill);
}
return 0;
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
// TODO maybe have it make a request for liquid if something tries to drain it
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
if (direction == this.getFacing(false))
// TODO Auto-generated method stub
return null;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection direction)
{
if (direction == this.getFacing(false) && this.fakeTank != null)
{
return new ILiquidTank[] { fakeTank };
return new FluidTankInfo[] { new FluidTankInfo(fakeTank.getFluid(), fakeTank.getCapacity()) };
}
return null;
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
public boolean canFill(ForgeDirection from, Fluid fluid)
{
if (direction == this.getFacing(false))
{
return fakeTank;
}
return null;
return from != getFacing(true);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
return false;
}
@Override
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
{
return entity instanceof ITankContainer && (dir == this.getFacing(false) || dir == this.getFacing(true));
return entity instanceof IFluidHandler && (dir == this.getFacing(false) || dir == this.getFacing(true));
}
@Override
@ -174,4 +161,5 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
super.invalidate();
HydraulicNetworkHelper.invalidate(this);
}
}

View file

@ -1,6 +1,5 @@
package dark.fluid.common.pump;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -13,28 +12,24 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquid;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import dark.core.api.IToolReadOut.EnumTools;
import dark.core.hydraulic.helpers.FluidHelper;
import dark.fluid.api.IDrain;
import dark.fluid.api.INetworkPipe;
import dark.fluid.common.prefab.TileEntityFluidDevice;
public class TileEntityDrain extends TileEntityFluidDevice implements ITankContainer, IDrain
public class TileEntityDrain extends TileEntityFluidDevice implements IFluidHandler, IDrain
{
/* MAX BLOCKS DRAINED PER 1/2 SECOND */
public static int MAX_WORLD_EDITS_PER_PROCESS = 30;
private int currentWorldEdits = 0;
/* LIST OF PUMPS AND THERE REQUESTS FOR THIS DRAIN */
private HashMap<TileEntity, LiquidStack> requestMap = new HashMap<TileEntity, LiquidStack>();
private HashMap<TileEntity, FluidStack> requestMap = new HashMap<TileEntity, FluidStack>();
private List<Vector3> targetSources = new ArrayList<Vector3>();
private List<Vector3> updateQue = new ArrayList<Vector3>();
@ -165,9 +160,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
}
}
/**
* Finds more liquid blocks using a path finder to be drained
*/
/** Finds more liquid blocks using a path finder to be drained */
public void getNextFluidBlock()
{
@ -352,7 +345,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
final Vector3 faceVec = new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ);
getLiquidFinder().init(faceVec, true);
//System.out.println("Drain:FillArea: Targets -> " + getLiquidFinder().results.size());
/* SORT RESULTS TO PUT THE LOWEST AND CLOSEST AT THE TOP */
try
{

View file

@ -8,6 +8,7 @@ package dark.mech.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.tileentity.TileEntity;
public class ModelGearRod extends ModelBase
{
@ -104,10 +105,10 @@ public class ModelGearRod extends ModelBase
setRotation(Rod2, 0F, 0F, 0.7853982F);
}
public void render(float f5, int r)
public void render(float f5, TileEntity tileEntity)
{
Rod.rotateAngleZ = 45 * r;
//Rod.rotateAngleZ = 45 * tileEntity;
Rod2.rotateAngleZ = Rod.rotateAngleZ + 45;
Rod.render(f5);

View file

@ -9,7 +9,6 @@ package dark.mech.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.tileentity.TileEntity;
import dark.mech.common.machines.TileEntityGenerator;
public class ModelGenerator extends ModelBase
{
@ -168,8 +167,6 @@ public class ModelGenerator extends ModelBase
FrontBracer.render(f5);
// Moving parts
float pos = 0;
if (ent instanceof TileEntityGenerator)
pos = 45 * ((TileEntityGenerator) ent).getAnimationPos();
// change
FrontDisc.rotateAngleZ = (float) Math.toRadians(pos);

View file

@ -7,9 +7,6 @@ import org.lwjgl.opengl.GL11;
import dark.fluid.common.FluidMech;
import dark.mech.client.model.ModelGearRod;
import dark.mech.common.machines.TileEntityRod;
public class RenderGearRod extends TileEntitySpecialRenderer
{
@ -20,9 +17,9 @@ public class RenderGearRod extends TileEntitySpecialRenderer
model = new ModelGearRod();
}
public void renderAModelAt(TileEntityRod tileEntity, double d, double d1, double d2, float f)
public void renderAModelAt(TileEntity tileEntity, double d, double d1, double d2, float f)
{
bindTextureByName(FluidMech.MODEL_TEXTURE_DIRECTORY + "mechanical/GearRod.png");
//bindTextureByName(FluidMech.MODEL_TEXTURE_DIRECTORY + "mechanical/GearRod.png");
GL11.glPushMatrix();
int meta = tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
@ -60,7 +57,7 @@ public class RenderGearRod extends TileEntitySpecialRenderer
GL11.glRotatef(270f, 0f, 1f, 0f);
break;
}
model.render(0.0625F, tileEntity.pos);
model.render(0.0625F, tileEntity);
GL11.glPopMatrix();
}
@ -68,7 +65,7 @@ public class RenderGearRod extends TileEntitySpecialRenderer
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
{
this.renderAModelAt((TileEntityRod) tileEntity, var2, var4, var6, var8);
this.renderAModelAt(tileEntity, var2, var4, var6, var8);
}
}

View file

@ -23,7 +23,7 @@ public class RenderGenerator extends TileEntitySpecialRenderer
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3)
{
bindTextureByName(FluidMech.MODEL_TEXTURE_DIRECTORY + "mechanical/Generator.png");
//bindTextureByName(FluidMech.MODEL_TEXTURE_DIRECTORY + "mechanical/Generator.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.45F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);

View file

@ -3,19 +3,19 @@ package dark.mech.common.machines;
import java.util.ArrayList;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
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.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockGenerator extends BlockAdvanced
public class BlockGenerator extends BlockMachine
{
public BlockGenerator(int id)
@ -41,7 +41,7 @@ public class BlockGenerator extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving, ItemStack stack)
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
{
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, blockID, angle);
@ -81,12 +81,6 @@ public class BlockGenerator extends BlockAdvanced
return BlockRenderHelper.renderID;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityGenerator();
}
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, int side)
{

View file

@ -1,7 +1,7 @@
package dark.mech.common.machines;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -9,12 +9,12 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.block.BlockAdvanced;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.common.FluidMech;
import dark.fluid.common.TabFluidMech;
import dark.library.machine.BlockMachine;
public class BlockRod extends BlockAdvanced
public class BlockRod extends BlockMachine
{
public BlockRod(int par1)
@ -33,7 +33,7 @@ public class BlockRod extends BlockAdvanced
}
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, ItemStack stack)
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase player, ItemStack stack)
{
int angle = MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int meta = 0;
@ -77,12 +77,6 @@ public class BlockRod extends BlockAdvanced
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityRod();
}
@Override
public boolean isOpaqueCube()
{

View file

@ -1,295 +0,0 @@
package dark.mech.common.machines;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.electricity.ElectricityNetwork;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.IElectricityNetwork;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.tile.TileEntityElectrical;
import com.google.common.io.ByteArrayDataInput;
import dark.core.api.IToolReadOut;
import dark.core.api.IToolReadOut.EnumTools;
import dark.fluid.api.mech.IForce;
import dark.helpers.ConnectionHelper;
import dark.helpers.MetaGroup;
public class TileEntityGenerator extends TileEntityElectrical implements IPacketReceiver, IForce, IToolReadOut, IRedstoneReceptor
{
public boolean isPowered = false;
ForgeDirection facing = ForgeDirection.DOWN;
public int force = 0;// current total force
public int aForce = 0;// force this unit can apply
public int pos = 0;// current pos of rotation max of 8
public int disableTicks = 0;// time disabled
public int tCount = 0;
double WATTS_PER_TICK = 500;
double joulesReceived = 0;
double genAmmount = 0;// watt output of machine
IConductor[] wires = { null, null, null, null, null, null };
@Override
public void updateEntity()
{
this.genAmmount = Math.abs(force / this.getVoltage());
// wire count update
int wireCount = 0;
TileEntity[] ents = ConnectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord);
this.wires = new IConductor[6];
for (int i = 0; i < ents.length; i++)
{
if (ents[i] instanceof IConductor)
{
this.wires[i] = (IConductor) ents[i];
wireCount++;
}
}// end wire count
if (tCount-- <= 0)
{
tCount = 10;
if (this.force > 0 || this.isPowered)
{
this.pos++;
if (force < 0)
pos -= 2;
if (pos >= 8)
pos = 0;
}
}
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
TileEntity ent = worldObj.getBlockTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ);
if (!this.worldObj.isRemote)
{
if (!this.isPowered)
{
for (int i = 2; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (dir != facing && dir != facing.getOpposite())
{
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), dir);
IElectricityNetwork network = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, dir);
if (network != null)
{
if (network.getRequest().getWatts() > 0)
{
network.startProducing(this, (this.genAmmount), this.getVoltage());
}
else
{
network.stopProducing(this);
}
}
}
}
}
else
{
for (int i = 2; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (dir != facing && dir != facing.getOpposite())
{
TileEntity inputTile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), dir);
IElectricityNetwork network = ElectricityNetworkHelper.getNetworkFromTileEntity(inputTile, dir);
if (network != null)
{
if (this.joulesReceived < this.WATTS_PER_TICK)
{
network.startRequesting(this, WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
this.joulesReceived = Math.max(Math.min(this.joulesReceived + network.consumeElectricity(this).getWatts(), WATTS_PER_TICK), 0);
}
else
{
network.stopRequesting(this);
}
}
}
}
if (this.joulesReceived >= this.WATTS_PER_TICK - 50)
{
joulesReceived -= this.WATTS_PER_TICK;
TileEntity rod = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), facing);
if (rod instanceof IForce && ((IForce) rod).canInputSide(facing))
{
((IForce) rod).applyForce(10000);
}
else if (rod instanceof IForce && ((IForce) rod).canOutputSide(facing))
{
((IForce) rod).applyForce(-10000);
}
}
}
}
super.updateEntity();
}
public void outputEnergy(ElectricityNetwork network, IConductor connectedElectricUnit, TileEntity outputTile)
{
if (network != null)
{
if (network.getRequest().getWatts() > 0)
{
connectedElectricUnit = (IConductor) outputTile;
}
else
{
connectedElectricUnit = null;
}
}
else
{
connectedElectricUnit = null;
}
if (connectedElectricUnit != null)
{
if (this.genAmmount > 0)
{
connectedElectricUnit.getNetwork().startProducing(this, (this.genAmmount / this.getVoltage()) / 20, this.getVoltage());
}
else
{
connectedElectricUnit.getNetwork().stopProducing(this);
}
}
}
// ------------------------------
// Data handling
// ------------------------------
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
{
// TODO Auto-generated method stub
}
// ------------------------------
// Mechanics
// ------------------------------
@Override
public int getForceSide(ForgeDirection side)
{
if (side == facing.getOpposite())
{
return aForce;
}
return 0;
}
@Override
public boolean canOutputSide(ForgeDirection side)
{
if (side == facing)
{
return true;
}
return false;
}
@Override
public boolean canInputSide(ForgeDirection side)
{
if (side == facing || side == facing.getOpposite())
{
return true;
}
return false;
}
@Override
public int applyForce(int force)
{
this.force = force;
return force;
}
@Override
public int getAnimationPos()
{
return pos;
}
// ------------------------------
// Electric
// ------------------------------
@Override
public void onDisable(int duration)
{
this.disableTicks = duration;
}
@Override
public boolean isDisabled()
{
if (disableTicks-- <= 0)
{
return false;
}
return true;
}
@Override
public double getVoltage()
{
return 120;
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
{
if (this.isPowered)
return "Outputing Force " + this.joulesReceived + "J " + "pos " + this.pos;
return this.force + "N Input " + this.genAmmount + "W output " + "pos " + this.pos;
}
// ------------------------------
// redSand
// ------------------------------
@Override
public void onPowerOn()
{
this.isPowered = true;
}
@Override
public void onPowerOff()
{
this.isPowered = false;
}
@Override
public boolean canConnect(ForgeDirection dir)
{
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
ForgeDirection facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
return dir != facing && dir != facing.getOpposite();
}
}

View file

@ -1,126 +0,0 @@
package dark.mech.common.machines;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import com.google.common.io.ByteArrayDataInput;
import dark.core.api.IToolReadOut;
import dark.core.api.IToolReadOut.EnumTools;
import dark.fluid.api.mech.IForce;
import dark.fluid.common.FluidMech;
public class TileEntityRod extends TileEntity implements IPacketReceiver, IForce, IToolReadOut
{
public int pos = 0;
private int currentForce = 0;// current force given to rod
private int pasteForce = 0;// last update force count
public int appliedForce = 0;// force this rod can apply to other things
private int tickCount = 0;
private int posCount = 0;// animation position 0-8
private ForgeDirection facing = ForgeDirection.UNKNOWN;
@Override
public void updateEntity()
{
super.updateEntity();
if (tickCount++ >= 10)
{
tickCount = 0;
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
facing = ForgeDirection.getOrientation(meta);
if (this.currentForce > 0)
{
this.pos++;
if (pos >= 8)
pos = 0;
}
if (!worldObj.isRemote)
{
TileEntity ent = worldObj.getBlockTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ);
appliedForce = Math.max(currentForce - 20, 0);
if (ent instanceof IForce && (((IForce) ent).canInputSide(facing)))
{
((IForce) ent).applyForce(appliedForce);
}
if (this.currentForce != this.pasteForce)
{
Packet packet = PacketManager.getPacket(FluidMech.CHANNEL, this, new Object[] { currentForce });
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 40);
}
this.pasteForce = this.currentForce;
}
}
}
@Override
public int getForceSide(ForgeDirection side)
{
return appliedForce;
}
@Override
public boolean canOutputSide(ForgeDirection side)
{
if (side == facing || side == facing.getOpposite())
{
return true;
}
return false;
}
@Override
public boolean canInputSide(ForgeDirection side)
{
if (side == facing || side == facing.getOpposite())
{
return true;
}
return false;
}
@Override
public int applyForce(int force)
{
this.currentForce = force;
return force;
}
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
{
try
{
this.currentForce = data.readInt();
}
catch (Exception e)
{
e.printStackTrace();
System.out.print("MechRodDataFailure \n");
}
}
@Override
public int getAnimationPos()
{
return this.pos;
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
{
return this.appliedForce + "N Out " + this.currentForce + "N In";
}
}