updated to 1.5.1

This commit is contained in:
Rseifert 2013-04-03 22:28:20 -04:00
parent a15208b618
commit 2eb5d04c85
12 changed files with 108 additions and 51 deletions

6
.gitignore vendored
View file

@ -11,10 +11,10 @@ CHANGELOG
!/src/minecraft/fluidmech/
!/src/minecraft/hydraulic/
!/src/minecraft/org/
!/resources/
!/models/
!/resources/models/
!/resources/mods/fluidmech/
!/resources/mods/mcmod.info
!info.txt
!AssemblyLineStandard.xml
!publish.bat
!publish_obf.bat
!include.bat

View file

@ -33,12 +33,12 @@ public class ItemBasic extends Item
{
for (ItemStack itemStack : list)
{
this.icons.add(iconRegister.func_94245_a(this.getUnlocalizedName(itemStack).replace("item.", FluidMech.TEXTURE_NAME_PREFIX)));
this.icons.add(iconRegister.registerIcon(this.getUnlocalizedName(itemStack).replace("item.", FluidMech.TEXTURE_NAME_PREFIX)));
}
}
else
{
this.iconIndex = iconRegister.func_94245_a(this.getUnlocalizedName().replace("item.", FluidMech.TEXTURE_NAME_PREFIX));
this.iconIndex = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", FluidMech.TEXTURE_NAME_PREFIX));
}
}

View file

@ -176,7 +176,7 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement
if (fillAmmount > 0)
{
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord - 1, zCoord, 0, 0, 3);
worldObj.setBlockMetadataWithNotify(xCoord, yCoord - 1, zCoord, 0, 0);
return true;
}
}

View file

@ -0,0 +1,26 @@
package fluidmech.common.machines;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
public class TileEntityPump extends TileEntityElectricityRunnable
{
public static final double WATTS_PER_TICK = 100;
private ForgeDirection outputSide = ForgeDirection.UNKNOWN;
private ForgeDirection inputSide = ForgeDirection.UNKNOWN;
@Override
public ElectricityPack getRequest()
{
return new ElectricityPack(WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return direction != outputSide && direction != inputSide ;
}
}

View file

@ -39,18 +39,18 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
connected = connectionHelper.getSurroundingTileEntities(this);
for (int i = 0; i < 6; i++)
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (connected[i] instanceof ITankContainer)
if (connected[dir.ordinal()] instanceof ITankContainer)
{
if (connected[i] instanceof IColorCoded && !this.canConnect(((IColorCoded) connected[i]).getColor()))
if (connected[dir.ordinal()] instanceof IColorCoded && !this.canConnect(((IColorCoded) connected[dir.ordinal()]).getColor()))
{
connected[i] = null;
connected[dir.ordinal()] = null;
}
}
else
{
connected[i] = null;
connected[dir.ordinal()] = null;
}
}
@ -69,7 +69,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
if (inputPipe != null)
{
ILiquidTank pipeVolume = inputPipe.getTanks(ForgeDirection.UNKNOWN)[0];
int ammountFilled = inputPipe.getNetwork().addFluidToNetwork(this, stack, 100, true);
int ammountFilled = inputPipe.getNetwork().addFluidToNetwork(this, stack, true);
drainedTank.drain(ForgeDirection.UNKNOWN, ammountFilled, true);
}
}

View file

@ -44,7 +44,7 @@ public class BlockGenerator extends BlockAdvanced
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving, ItemStack stack)
{
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockAndMetadataWithNotify(x, y, z, blockID, angle, 3);
world.setBlockMetadataWithNotify(x, y, z, blockID, angle);
}
@Override
@ -54,11 +54,11 @@ public class BlockGenerator extends BlockAdvanced
int metadata = par1World.getBlockMetadata(x, y, z);
if (metadata < 3)
{
par1World.setBlockAndMetadataWithNotify(x, y, z, blockID, metadata + angle, 3);
par1World.setBlockMetadataWithNotify(x, y, z, blockID, metadata + angle);
}
else
{
par1World.setBlockAndMetadataWithNotify(x, y, z, blockID, 0, 3);
par1World.setBlockMetadataWithNotify(x, y, z, blockID, 0);
}
return true;
}

View file

@ -59,7 +59,7 @@ public class BlockRod extends BlockAdvanced
dX++;
break;
}
world.setBlockAndMetadataWithNotify(i, j, k, blockID, meta, 3);
world.setBlockMetadataWithNotify(i, j, k, blockID, meta);
}
@Override

View file

@ -110,11 +110,11 @@ public class BlockPipe extends BlockAdvanced
{
if (tank.getLiquid().itemID == Block.waterStill.blockID)
{
world.setBlockAndMetadataWithNotify(x, y, z, Block.waterStill.blockID, 7, 3);
world.setBlockMetadataWithNotify(x, y, z, Block.waterStill.blockID, 7);
}
if (tank.getLiquid().itemID == Block.lavaStill.blockID)
{
world.setBlockAndMetadataWithNotify(x, y, z, Block.lavaStill.blockID, 4, 3);
world.setBlockMetadataWithNotify(x, y, z, Block.lavaStill.blockID, 4);
}
}
}

View file

@ -138,7 +138,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
{
if (!this.worldObj.isRemote)
{
this.getNetwork().splitNetwork(this);
this.getNetwork().splitNetwork(this.worldObj, this);
}
super.invalidate();
@ -394,7 +394,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
{
return 0;
}
return this.getNetwork().addFluidToNetwork(worldObj.getBlockTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ), resource, 0, doFill);
return this.getNetwork().addFluidToNetwork(worldObj.getBlockTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ), resource, doFill);
}
@Override
@ -404,7 +404,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
{
return 0;
}
return this.getNetwork().addFluidToNetwork(this, resource, 0, doFill);
return this.getNetwork().addFluidToNetwork(this, resource,doFill);
}
@Override
@ -509,7 +509,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
LiquidStack stack = tankContainer.drain(dir, LiquidContainerRegistry.BUCKET_VOLUME, false);
if (stack != null && stack.amount > 0)
{
int fill = this.getNetwork().addFluidToNetwork((TileEntity) tankContainer, stack, 0, true);
int fill = this.getNetwork().addFluidToNetwork((TileEntity) tankContainer, stack,true);
tankContainer.drain(dir, fill, true);
}
}
@ -564,7 +564,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
{
if (damageAllowed)
{
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0, 3);
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0);
return true;
}
return false;

View file

@ -28,7 +28,7 @@ public class TileEntityPipeWindow extends TileEntityPipeExtention
if (pipe != null)
{
stack = pipe.getNetwork().getTank().getLiquid();
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord + 1, yCoord, 0, 0, 3);
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, yCoord, 0, 0);
}
}
else

View file

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
@ -20,6 +21,7 @@ import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.common.FMLLog;
/**
@ -149,11 +151,11 @@ public class HydraulicNetwork
{
return;
}
if (ent instanceof IFluidNetworkPart)
else if (ent instanceof IFluidNetworkPart)
{
this.addNetworkPart((IFluidNetworkPart) ent);
}
if (!fluidTanks.contains(ent))
else if (!fluidTanks.contains(ent))
{
fluidTanks.add(ent);
}
@ -232,14 +234,28 @@ public class HydraulicNetwork
}
/**
* Tries to add the liquid stack to the network's valid machines. Same as the fill method for
* ITankContainer in that it will fill machines, however it also includes pressure if the
* machine also adds pressure to the network. Called mostly by pipes as they are filled from
* other mod sources
* Adds FLuid to this network from one of the connected Pipes
*
* @return The amount of Liquid used.
* @param source - Were this liquid came from
* @param stack - LiquidStack to be sent
* @param doFill - actually fill the tank or just check numbers
* @return the amount of liquid consumed from the init stack
*/
public int addFluidToNetwork(TileEntity source, LiquidStack stack, double pressure, boolean doFill)
public int addFluidToNetwork(TileEntity source, LiquidStack stack, boolean doFill)
{
return this.addFluidToNetwork(source, stack, doFill, true);
}
/**
* Adds FLuid to this network from one of the connected Pipes
*
* @param source - Were this liquid came from
* @param stack - LiquidStack to be sent
* @param doFill - actually fill the tank or just check numbers
* @param allowStore - allows the network to store this liquid in the pipes
* @return the amount of liquid consumed from the init stack
*/
public int addFluidToNetwork(TileEntity source, LiquidStack stack, boolean doFill, boolean allowStore)
{
int used = 0;
LiquidStack prevCombined = this.combinedStorage.getLiquid();
@ -323,7 +339,7 @@ public class HydraulicNetwork
used = secondayFill.fill(fillDir, stack, doFill);
System.out.println("Seconday Target " + used + doFill);
}
else if (this.combinedStorage.getLiquid() == null || this.combinedStorage.getLiquid().amount < this.combinedStorage.getCapacity())
else if (allowStore && (this.combinedStorage.getLiquid() == null || this.combinedStorage.getLiquid().amount < this.combinedStorage.getCapacity()))
{
used = this.combinedStorage.fill(stack, doFill);
System.out.println("Network Target filled for " + used + doFill);
@ -523,7 +539,7 @@ public class HydraulicNetwork
// as needed
}
public void splitNetwork(IConnectionProvider splitPoint)
public void splitNetwork(World world, IConnectionProvider splitPoint)
{
if (splitPoint instanceof TileEntity)
{
@ -547,15 +563,16 @@ public class HydraulicNetwork
if (connectedBlockA != connectedBlockB && connectedBlockB instanceof IConnectionProvider)
{
Pathfinder finder = new PathfinderCheckerPipes((IConnectionProvider) connectedBlockB, splitPoint);
finder.init((IConnectionProvider) connectedBlockA);
Pathfinder finder = new PathfinderCheckerPipes(world, (IConnectionProvider) connectedBlockB, splitPoint);
finder.init(new Vector3(connectedBlockA));
if (finder.results.size() > 0)
{
/* STILL CONNECTED SOMEWHERE ELSE */
for (IConnectionProvider node : finder.iteratedNodes)
for (Vector3 node : finder.closedSet)
{
if (node instanceof IFluidNetworkPart)
TileEntity entity = node.getTileEntity(world);
if (entity instanceof IFluidNetworkPart)
{
if (node != splitPoint)
{
@ -569,9 +586,10 @@ public class HydraulicNetwork
/* NO LONGER CONNECTED ELSE WHERE SO SPLIT AND REFRESH */
HydraulicNetwork newNetwork = new HydraulicNetwork(this.color);
int parts = 0;
for (IConnectionProvider node : finder.iteratedNodes)
for (Vector3 node : finder.closedSet)
{
if (node instanceof IFluidNetworkPart)
TileEntity entity = node.getTileEntity(world);
if (entity instanceof IFluidNetworkPart)
{
if (node != splitPoint)
{

View file

@ -1,42 +1,55 @@
package hydraulic.fluidnetwork;
import hydraulic.api.IPipeConnection;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.path.IPathCallBack;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
/**
* Check if a conductor connects with another.
*/
public class PathfinderCheckerPipes extends Pathfinder
{
public PathfinderCheckerPipes(final IConnectionProvider targetConnector, final IConnectionProvider... ignoreConnector)
public PathfinderCheckerPipes(final World world, final IConnectionProvider targetConnector, final IConnectionProvider... ignoreConnector)
{
super(new IPathCallBack()
{
@Override
public boolean isValidNode(Pathfinder finder, ForgeDirection direction, IConnectionProvider provider, IConnectionProvider connectedBlock)
public Set<Vector3> getConnectedNodes(Pathfinder finder, Vector3 currentNode)
{
if (connectedBlock instanceof IPipeConnection && !Arrays.asList(ignoreConnector).contains(connectedBlock))
Set<Vector3> neighbors = new HashSet<Vector3>();
for (int i = 0; i < 6; i++)
{
if (((IPipeConnection) connectedBlock).canConnect((TileEntity) connectedBlock, direction.getOpposite()))
ForgeDirection direction = ForgeDirection.getOrientation(i);
Vector3 position = currentNode.clone().modifyPositionFromSide(direction);
TileEntity connectedBlock = position.getTileEntity(world);
if (connectedBlock instanceof IFluidNetworkPart && !Arrays.asList(ignoreConnector).contains(connectedBlock))
{
return true;
if (((IFluidNetworkPart) connectedBlock).canConnect(connectedBlock, direction.getOpposite()))
{
neighbors.add(position);
}
}
}
return false;
return neighbors;
}
@Override
public boolean onSearch(Pathfinder finder, IConnectionProvider provider)
public boolean onSearch(Pathfinder finder, Vector3 node)
{
if (provider == targetConnector)
if (node.getTileEntity(world) == targetConnector)
{
finder.results.add(provider);
finder.results.add(node);
return true;
}