working on start pump more
Doesn't work well or at all currently
This commit is contained in:
parent
604703ab28
commit
4da59e8d3a
3 changed files with 46 additions and 119 deletions
|
@ -119,17 +119,14 @@ public class FluidMech extends ModPrefab
|
||||||
proxy.Init();
|
proxy.Init();
|
||||||
|
|
||||||
/* TILE ENTITY REGISTER CALLS */
|
/* TILE ENTITY REGISTER CALLS */
|
||||||
GameRegistry.registerTileEntity(TileEntityPipe.class, "lmPipeTile");
|
GameRegistry.registerTileEntity(TileEntityPipe.class, "FluidPipe");
|
||||||
GameRegistry.registerTileEntity(TileEntityGenericPipe.class, "lmGenPipeTile");
|
GameRegistry.registerTileEntity(TileEntityGenericPipe.class, "ColoredPipe");
|
||||||
GameRegistry.registerTileEntity(TileEntityStarterPump.class, "lmPumpTile");
|
GameRegistry.registerTileEntity(TileEntityStarterPump.class, "starterPump");
|
||||||
//GameRegistry.registerTileEntity(TileEntityRod.class, "lmRodTile");
|
GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "ReleaseValve");
|
||||||
GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "lmReleaseValve");
|
GameRegistry.registerTileEntity(TileEntityTank.class, "FluidTank");
|
||||||
GameRegistry.registerTileEntity(TileEntityTank.class, "lmTank");
|
GameRegistry.registerTileEntity(TileEntitySink.class, "FluidSink");
|
||||||
//GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
|
GameRegistry.registerTileEntity(TileEntityDrain.class, "FluidDrain");
|
||||||
GameRegistry.registerTileEntity(TileEntitySink.class, "lmSink");
|
GameRegistry.registerTileEntity(TileEntityConstructionPump.class, "ConstructionPump");
|
||||||
GameRegistry.registerTileEntity(TileEntityDrain.class, "lmDrain");
|
|
||||||
GameRegistry.registerTileEntity(TileEntityConstructionPump.class, "lmConPump");
|
|
||||||
GameRegistry.registerTileEntity(TileEntityPipeWindow.class, "lmPipeWindow");
|
|
||||||
|
|
||||||
/* LANG LOADING */
|
/* LANG LOADING */
|
||||||
FMLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
FMLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class BlockPumpMachine extends BlockFM
|
||||||
|
|
||||||
public BlockPumpMachine(int id)
|
public BlockPumpMachine(int id)
|
||||||
{
|
{
|
||||||
super("FluidMachine", id, Material.iron);
|
super("StarterPump", id, Material.iron);
|
||||||
this.setHardness(1f);
|
this.setHardness(1f);
|
||||||
this.setResistance(5f);
|
this.setResistance(5f);
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,9 @@ public class BlockPumpMachine extends BlockFM
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(int meta)
|
public int damageDropped(int meta)
|
||||||
{
|
|
||||||
if (meta < 4)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||||
|
@ -62,56 +58,17 @@ public class BlockPumpMachine extends BlockFM
|
||||||
|
|
||||||
if (meta < 4)
|
if (meta < 4)
|
||||||
{
|
{
|
||||||
new ItemStack(FluidMech.recipeLoader.blockMachine, 1, 0);
|
return new ItemStack(FluidMech.recipeLoader.blockMachine, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
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;
|
|
||||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, angle + MetaGroup.getGroupStartMeta(MetaGroup.getGrouping(meta)), 3);
|
|
||||||
|
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
|
||||||
if (p instanceof EntityPlayer)
|
|
||||||
{
|
|
||||||
// ((EntityPlayer) p).sendChatToPlayer("meta:" +
|
|
||||||
// world.getBlockMetadata(x, y, z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world)
|
public TileEntity createNewTileEntity(World world)
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World var1, int meta)
|
|
||||||
{
|
|
||||||
if (meta >= 12)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (meta >= 8)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (meta >= 4)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return new TileEntityStarterPump();
|
return new TileEntityStarterPump();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||||
|
@ -119,26 +76,4 @@ public class BlockPumpMachine extends BlockFM
|
||||||
par3List.add(new ItemStack(par1, 1, 0));
|
par3List.add(new ItemStack(par1, 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
int meta = par1World.getBlockMetadata(x, y, z);
|
|
||||||
int g = MetaGroup.getGrouping(meta);
|
|
||||||
TileEntity ent = par1World.getBlockTileEntity(x, y, z);
|
|
||||||
int angle = MathHelper.floor_double((par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
||||||
|
|
||||||
if (meta == (g * 4) + 3)
|
|
||||||
{
|
|
||||||
par1World.setBlockMetadataWithNotify(x, y, z, (g * 4), 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
par1World.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
|
||||||
}
|
|
||||||
if (ent instanceof TileEntityStarterPump)
|
|
||||||
{
|
|
||||||
((TileEntityStarterPump) ent).getConnections();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,16 @@ import dark.core.helpers.MetaGroup;
|
||||||
import dark.core.helpers.Pair;
|
import dark.core.helpers.Pair;
|
||||||
import dark.fluid.common.FluidMech;
|
import dark.fluid.common.FluidMech;
|
||||||
|
|
||||||
public class TileEntityStarterPump extends TileEntityMachine implements IPacketReceiver, IToolReadOut, ITileConnector
|
public class TileEntityStarterPump extends TileEntityMachine implements IToolReadOut, ITileConnector
|
||||||
{
|
{
|
||||||
public final static float WATTS_PER_TICK = 20;
|
|
||||||
|
|
||||||
private int currentWorldEdits = 0;
|
private int currentWorldEdits = 0;
|
||||||
private static final int MAX_WORLD_EDITS_PER_PROCESS = 30;
|
private static final int MAX_WORLD_EDITS_PER_PROCESS = 5;
|
||||||
|
|
||||||
private List<Vector3> updateQue = new ArrayList<Vector3>();
|
private List<Vector3> updateQue = new ArrayList<Vector3>();
|
||||||
private LiquidPathFinder pathLiquid;
|
private LiquidPathFinder pathLiquid;
|
||||||
|
|
||||||
public int pos = 0;
|
public int pos = 0;
|
||||||
public boolean running = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initiate()
|
public void initiate()
|
||||||
|
@ -66,16 +64,17 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (!this.worldObj.isRemote && !this.isDisabled() && this.ticks % 20 == 0 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, yCoord))
|
if (!this.worldObj.isRemote && !this.isDisabled() && this.ticks % 20 == 0)
|
||||||
|
{
|
||||||
|
this.currentWorldEdits = 0;
|
||||||
|
|
||||||
|
if (this.canRun())
|
||||||
{
|
{
|
||||||
if (this.getLiquidFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10)
|
if (this.getLiquidFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10)
|
||||||
{
|
{
|
||||||
this.getLiquidFinder().start(new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN), false);
|
this.getLiquidFinder().start(new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN), false);
|
||||||
}
|
}
|
||||||
boolean prevRun = this.running;
|
|
||||||
if (this.canRun())
|
|
||||||
{
|
|
||||||
this.running = true;
|
|
||||||
if (this.getLiquidFinder().results.size() > 0)
|
if (this.getLiquidFinder().results.size() > 0)
|
||||||
{
|
{
|
||||||
System.out.println("StartPump>>DrainArea>>Targets>" + this.getLiquidFinder().results.size());
|
System.out.println("StartPump>>DrainArea>>Targets>" + this.getLiquidFinder().results.size());
|
||||||
|
@ -84,19 +83,22 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR
|
||||||
|
|
||||||
while (fluidList.hasNext())
|
while (fluidList.hasNext())
|
||||||
{
|
{
|
||||||
System.out.println("StartPump>>DrainArea>>Draining>>NextFluidBlock");
|
|
||||||
Vector3 drainLocation = fluidList.next();
|
Vector3 drainLocation = fluidList.next();
|
||||||
FluidStack drainStack = FluidHelper.drainBlock(this.worldObj, drainLocation, false);
|
FluidStack drainStack = FluidHelper.drainBlock(this.worldObj, drainLocation, false);
|
||||||
|
System.out.println("StartPump>>DrainArea>>Draining>>NextFluidBlock>" + (drainStack == null ? "Null" : drainStack.amount + "mb of " + drainStack.getFluid().getName()));
|
||||||
|
|
||||||
if (this.currentWorldEdits >= MAX_WORLD_EDITS_PER_PROCESS)
|
if (this.currentWorldEdits >= MAX_WORLD_EDITS_PER_PROCESS)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (drainStack != null && FluidHelper.fillTanksAllSides(worldObj, new Vector3(this), drainStack, false, ForgeDirection.DOWN) >= drainStack.amount)
|
int fillV = FluidHelper.fillTanksAllSides(worldObj, new Vector3(this), drainStack, false, ForgeDirection.DOWN);
|
||||||
|
System.out.println("StartPump>>DrainArea>>Draining>>NextFluidBlock>Filled>" + fillV + "mb");
|
||||||
|
if (drainStack != null && fillV >= drainStack.amount)
|
||||||
{
|
{
|
||||||
System.out.println("StartPump>>DrainArea>>Draining>>Fluid>" + drainLocation.toString());
|
System.out.println("StartPump>>DrainArea>>Draining>>Fluid>" + drainLocation.toString());
|
||||||
/* REMOVE BLOCK */
|
/* REMOVE BLOCK */
|
||||||
FluidHelper.drainBlock(this.worldObj, drainLocation, true);
|
FluidHelper.drainBlock(this.worldObj, drainLocation, true);
|
||||||
|
FluidHelper.fillTanksAllSides(worldObj, new Vector3(this), drainStack, true, ForgeDirection.DOWN);
|
||||||
this.currentWorldEdits++;
|
this.currentWorldEdits++;
|
||||||
fluidList.remove();
|
fluidList.remove();
|
||||||
/* ADD TO UPDATE QUE */
|
/* ADD TO UPDATE QUE */
|
||||||
|
@ -108,39 +110,32 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (this.updateQue.size() > 0)
|
||||||
{
|
{
|
||||||
this.running = false;
|
for (Vector3 vec : this.updateQue)
|
||||||
|
{
|
||||||
|
this.worldObj.markBlockForUpdate(vec.intX(), vec.intY(), vec.intZ());
|
||||||
|
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
Vector3 veb = vec.clone().modifyPositionFromSide(direction);
|
||||||
|
if (!updateQue.contains(veb))
|
||||||
|
{
|
||||||
|
updateQue.add(veb);
|
||||||
|
this.worldObj.markBlockForUpdate(veb.intX(), veb.intY(), veb.intZ());
|
||||||
}
|
}
|
||||||
if (running != prevRun)
|
}
|
||||||
{
|
}
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
this.updateQue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public boolean canRun()
|
||||||
{
|
{
|
||||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, this.running);
|
return super.canRun() && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (worldObj.isRemote)
|
|
||||||
{
|
|
||||||
this.running = data.readBoolean();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,7 +147,7 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR
|
||||||
@Override
|
@Override
|
||||||
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
|
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
|
||||||
{
|
{
|
||||||
return String.format("%.2f/%.2fWatts %f SourceBlocks", this.getEnergyStored(), this.getMaxEnergyStored(), this.getLiquidFinder().results.size());
|
return String.format("%.2f/%.2fWatts %d SourceBlocks", this.getEnergyStored(), this.getMaxEnergyStored(), this.getLiquidFinder().results.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue