diff --git a/src/minecraft/dark/fluid/common/FluidMech.java b/src/minecraft/dark/fluid/common/FluidMech.java index a0a1c2376..4adcacbd1 100644 --- a/src/minecraft/dark/fluid/common/FluidMech.java +++ b/src/minecraft/dark/fluid/common/FluidMech.java @@ -119,17 +119,14 @@ public class FluidMech extends ModPrefab proxy.Init(); /* TILE ENTITY REGISTER CALLS */ - GameRegistry.registerTileEntity(TileEntityPipe.class, "lmPipeTile"); - GameRegistry.registerTileEntity(TileEntityGenericPipe.class, "lmGenPipeTile"); - GameRegistry.registerTileEntity(TileEntityStarterPump.class, "lmPumpTile"); - //GameRegistry.registerTileEntity(TileEntityRod.class, "lmRodTile"); - GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "lmReleaseValve"); - GameRegistry.registerTileEntity(TileEntityTank.class, "lmTank"); - //GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen"); - GameRegistry.registerTileEntity(TileEntitySink.class, "lmSink"); - GameRegistry.registerTileEntity(TileEntityDrain.class, "lmDrain"); - GameRegistry.registerTileEntity(TileEntityConstructionPump.class, "lmConPump"); - GameRegistry.registerTileEntity(TileEntityPipeWindow.class, "lmPipeWindow"); + GameRegistry.registerTileEntity(TileEntityPipe.class, "FluidPipe"); + GameRegistry.registerTileEntity(TileEntityGenericPipe.class, "ColoredPipe"); + GameRegistry.registerTileEntity(TileEntityStarterPump.class, "starterPump"); + GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "ReleaseValve"); + GameRegistry.registerTileEntity(TileEntityTank.class, "FluidTank"); + GameRegistry.registerTileEntity(TileEntitySink.class, "FluidSink"); + GameRegistry.registerTileEntity(TileEntityDrain.class, "FluidDrain"); + GameRegistry.registerTileEntity(TileEntityConstructionPump.class, "ConstructionPump"); /* LANG LOADING */ FMLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages."); diff --git a/src/minecraft/dark/fluid/common/pump/BlockPumpMachine.java b/src/minecraft/dark/fluid/common/pump/BlockPumpMachine.java index 4bf376a79..6b09f9e01 100644 --- a/src/minecraft/dark/fluid/common/pump/BlockPumpMachine.java +++ b/src/minecraft/dark/fluid/common/pump/BlockPumpMachine.java @@ -21,7 +21,7 @@ public class BlockPumpMachine extends BlockFM public BlockPumpMachine(int id) { - super("FluidMachine", id, Material.iron); + super("StarterPump", id, Material.iron); this.setHardness(1f); this.setResistance(5f); } @@ -47,11 +47,7 @@ public class BlockPumpMachine extends BlockFM @Override public int damageDropped(int meta) { - if (meta < 4) - { - return 0; - } - return meta; + return 0; } @Override @@ -62,55 +58,16 @@ public class BlockPumpMachine extends BlockFM if (meta < 4) { - new ItemStack(FluidMech.recipeLoader.blockMachine, 1, 0); + return new ItemStack(FluidMech.recipeLoader.blockMachine, 1, 0); } 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 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 null; + return new TileEntityStarterPump(); } @Override @@ -119,26 +76,4 @@ public class BlockPumpMachine extends BlockFM 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; - } - } diff --git a/src/minecraft/dark/fluid/common/pump/TileEntityStarterPump.java b/src/minecraft/dark/fluid/common/pump/TileEntityStarterPump.java index fae945a39..d2eb02f5d 100644 --- a/src/minecraft/dark/fluid/common/pump/TileEntityStarterPump.java +++ b/src/minecraft/dark/fluid/common/pump/TileEntityStarterPump.java @@ -33,18 +33,16 @@ import dark.core.helpers.MetaGroup; import dark.core.helpers.Pair; 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 static final int MAX_WORLD_EDITS_PER_PROCESS = 30; + private static final int MAX_WORLD_EDITS_PER_PROCESS = 5; private List updateQue = new ArrayList(); private LiquidPathFinder pathLiquid; public int pos = 0; - public boolean running = false; @Override public void initiate() @@ -66,16 +64,17 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR { 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) { - if (this.getLiquidFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10) - { - this.getLiquidFinder().start(new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN), false); - } - boolean prevRun = this.running; + this.currentWorldEdits = 0; + if (this.canRun()) { - this.running = true; + if (this.getLiquidFinder().results.size() < TileEntityDrain.MAX_WORLD_EDITS_PER_PROCESS + 10) + { + this.getLiquidFinder().start(new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN), false); + } + if (this.getLiquidFinder().results.size() > 0) { System.out.println("StartPump>>DrainArea>>Targets>" + this.getLiquidFinder().results.size()); @@ -84,19 +83,22 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR while (fluidList.hasNext()) { - System.out.println("StartPump>>DrainArea>>Draining>>NextFluidBlock"); Vector3 drainLocation = fluidList.next(); 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) { 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()); /* REMOVE BLOCK */ FluidHelper.drainBlock(this.worldObj, drainLocation, true); + FluidHelper.fillTanksAllSides(worldObj, new Vector3(this), drainStack, true, ForgeDirection.DOWN); this.currentWorldEdits++; fluidList.remove(); /* ADD TO UPDATE QUE */ @@ -108,39 +110,32 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR } } } - else + + if (this.updateQue.size() > 0) { - this.running = false; - } - if (running != prevRun) - { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + 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()); + } + } + } + this.updateQue.clear(); } } } @Override - public Packet getDescriptionPacket() + public boolean canRun() { - return PacketManager.getPacket(FluidMech.CHANNEL, this, this.running); - } - - @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(); - } - + return super.canRun() && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); } @Override @@ -152,7 +147,7 @@ public class TileEntityStarterPump extends TileEntityMachine implements IPacketR @Override 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