Merge branch '6.5.x' of github.com:BuildCraft/BuildCraft into 7.1.x

This commit is contained in:
Adrian 2015-07-11 17:31:48 +02:00
commit 0d3b5b2eb7
21 changed files with 181 additions and 145 deletions

View file

@ -38,7 +38,7 @@ public abstract class Schematic {
* Blocks are build in various stages, in order to make sure that a block * Blocks are build in various stages, in order to make sure that a block
* can indeed be placed, and that it's unlikely to disturb other blocks. * can indeed be placed, and that it's unlikely to disturb other blocks.
*/ */
public static enum BuildingStage { public enum BuildingStage {
/** /**
* Standalone blocks can be placed in the air, and they don't change * Standalone blocks can be placed in the air, and they don't change
* once placed. * once placed.

View file

@ -194,9 +194,9 @@ public class AIRobot {
if (aiRobotClass != null) { if (aiRobotClass != null) {
delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class) delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class)
.newInstance(robot); .newInstance(robot);
delegateAI.parentAI = this;
if (delegateAI.canLoadFromNBT()) { if (delegateAI.canLoadFromNBT()) {
delegateAI.parentAI = this;
delegateAI.loadFromNBT(sub); delegateAI.loadFromNBT(sub);
} }
} }

View file

@ -22,7 +22,7 @@ apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo apply plugin: 'maven' // for uploading to a maven repo
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
version = "7.0.13" version = "7.0.14"
group= "com.mod-buildcraft" group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension] archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]

View file

@ -0,0 +1,19 @@
Improvements:
* Quarries now dig through light fluids and stop on dense fluids. Behaviour might change later, so watch out! (asie)
Bugs fixed:
* [#2880] Try to fix fluid pipe bug (asie)
* [#2878] Robot NPE for robots prior to 7.0.13 fix (asie)
* [#2877] Survival blueprint crash (asie)
* [#2841] Another crash with Oil in the Nether (asie)
* [#2837] Massive lag with Construction Markers (hea3ven)
* [#2831] Robots sinking through the ground (hea3ven)
* [#2825, #2618, #1777] Quarry issues with just about every translucent block (asie)
* Allow Builders to use arbitrary IPathProviders (asie)
* Block breaking robots sleeping in mid air (hea3ven)
* Error in robot AI loading (hea3ven)
* Incorrect Request Needed Items action name (asie)
* Packages crashing Minecraft if mods are removed (asie)
* Robots ignoring gate config on their linked station when equipping items (hea3ven)

View file

@ -1,3 +1,3 @@
1.6.4:BuildCraft:4.2.2 1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.16 1.7.2:BuildCraft:6.0.16
1.7.10:BuildCraft:7.0.13 1.7.10:BuildCraft:7.0.14

View file

@ -489,7 +489,6 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.softBlocks.add(Blocks.snow); BuildCraftAPI.softBlocks.add(Blocks.snow);
BuildCraftAPI.softBlocks.add(Blocks.vine); BuildCraftAPI.softBlocks.add(Blocks.vine);
BuildCraftAPI.softBlocks.add(Blocks.fire); BuildCraftAPI.softBlocks.add(Blocks.fire);
BuildCraftAPI.softBlocks.add(Blocks.air);
FMLCommonHandler.instance().bus().register(new TickHandlerCore()); FMLCommonHandler.instance().bus().register(new TickHandlerCore());

View file

@ -152,22 +152,26 @@ public class LibraryDatabase {
int sepIndex = fileName.lastIndexOf(LibraryId.BPT_SEP_CHARACTER); int sepIndex = fileName.lastIndexOf(LibraryId.BPT_SEP_CHARACTER);
int dotIndex = fileName.lastIndexOf('.'); int dotIndex = fileName.lastIndexOf('.');
String extension = fileName.substring(dotIndex + 1); if (dotIndex > 0) {
String extension = fileName.substring(dotIndex + 1);
if (sepIndex > 0) { if (sepIndex > 0) {
String prefix = fileName.substring(0, sepIndex); String prefix = fileName.substring(0, sepIndex);
String suffix = fileName.substring(sepIndex + 1); String suffix = fileName.substring(sepIndex + 1);
id.name = prefix; id.name = prefix;
id.uniqueId = LibraryId.toBytes(suffix.substring(0, suffix.length() - (extension.length() + 1))); id.uniqueId = LibraryId.toBytes(suffix.substring(0, suffix.length() - (extension.length() + 1)));
} else {
id.name = fileName.substring(0, dotIndex);
id.uniqueId = new byte[0];
}
id.extension = extension;
if (!blueprintIds.contains(id)) {
blueprintIds.add(id);
}
} else { } else {
id.name = fileName.substring(0, dotIndex); BCLog.logger.warn("Found incorrectly named (no extension) blueprint file: '%s'!", fileName);
id.uniqueId = new byte[0];
}
id.extension = extension;
if (!blueprintIds.contains(id)) {
blueprintIds.add(id);
} }
} }

View file

@ -209,7 +209,6 @@ public class TileConstructionMarker extends TileBuildCraft implements IBuildingI
@Override @Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
if (side.isServer() && "uploadBuildersInAction".equals(command)) { if (side.isServer() && "uploadBuildersInAction".equals(command)) {
BuildCraftCore.instance.sendToServer(new PacketCommand(this, "uploadBuildersInAction", null));
for (BuildingItem i : buildersInAction) { for (BuildingItem i : buildersInAction) {
BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, createLaunchItemPacket(i)); BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, createLaunchItemPacket(i));
} }

View file

@ -17,6 +17,7 @@ import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -31,6 +32,7 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidBlock;
import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftBuilders;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
@ -313,9 +315,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes
for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) { for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) {
Block block = worldObj.getBlock(nextTarget[0], y, nextTarget[2]); if (isQuarriableBlock(nextTarget[0], y, nextTarget[2])) {
if (BlockUtils.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2])
|| !BuildCraftAPI.isSoftBlock(worldObj, nextTarget[0], y, nextTarget[2])) {
createColumnVisitList(); createColumnVisitList();
columnVisitListIsUpdated = true; columnVisitListIsUpdated = true;
nextTarget = null; nextTarget = null;
@ -340,8 +340,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
*/ */
private void createColumnVisitList() { private void createColumnVisitList() {
visitList.clear(); visitList.clear();
Integer[][] columnHeights = new Integer[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
boolean[][] blockedColumns = new boolean[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2]; boolean[][] blockedColumns = new boolean[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
for (int searchY = yCoord + 3; searchY >= 1; --searchY) { for (int searchY = yCoord + 3; searchY >= 1; --searchY) {
@ -372,29 +370,16 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
for (int searchZ = startZ; searchZ != endZ; searchZ += incZ) { for (int searchZ = startZ; searchZ != endZ; searchZ += incZ) {
if (!blockedColumns[searchX][searchZ]) { if (!blockedColumns[searchX][searchZ]) {
Integer height = columnHeights[searchX][searchZ];
int bx = box.xMin + searchX + 1, by = searchY, bz = box.zMin + searchZ + 1; int bx = box.xMin + searchX + 1, by = searchY, bz = box.zMin + searchZ + 1;
if (height == null) {
columnHeights[searchX][searchZ] = height = worldObj.getHeightValue(bx, bz);
}
if (height > 0 && height < by && worldObj.provider.dimensionId != -1) {
continue;
}
Block block = worldObj.getBlock(bx, by, bz); Block block = worldObj.getBlock(bx, by, bz);
if (!BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)) { if (!BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)) {
blockedColumns[searchX][searchZ] = true; blockedColumns[searchX][searchZ] = true;
} else if (!BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz)) { } else if (!BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz) && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)) {
visitList.add(new int[]{bx, by, bz}); visitList.add(new int[]{bx, by, bz});
} }
if (height == 0 && !worldObj.isAirBlock(bx, by, bz)) {
columnHeights[searchX][searchZ] = by;
}
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this // Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > builder.blueprint.sizeZ * builder.blueprint.sizeX * 2) { if (visitList.size() > builder.blueprint.sizeZ * builder.blueprint.sizeX * 2) {
@ -487,7 +472,8 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
private boolean isQuarriableBlock(int bx, int by, int bz) { private boolean isQuarriableBlock(int bx, int by, int bz) {
Block block = worldObj.getBlock(bx, by, bz); Block block = worldObj.getBlock(bx, by, bz);
return BlockUtils.canChangeBlock(block, worldObj, bx, by, bz) return BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)
&& !BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz); && !BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz)
&& !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock);
} }
@Override @Override

View file

@ -11,7 +11,6 @@ package buildcraft.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;

View file

@ -265,8 +265,10 @@ public class BptBuilderBlueprint extends BptBuilderBase {
private int getBuildListCount() { private int getBuildListCount() {
int out = 0; int out = 0;
for (int i = 0; i < buildStageOccurences.length; i++) { if (buildStageOccurences != null) {
out += buildStageOccurences[i]; for (int i = 0; i < buildStageOccurences.length; i++) {
out += buildStageOccurences[i];
}
} }
return out; return out;
} }

View file

@ -186,7 +186,7 @@ public class BlockBuildCraftFluid extends BlockFluidClassic {
} }
@Override @Override
public boolean canDropFromExplosion(Explosion p_149659_1_) { public boolean canDropFromExplosion(Explosion explosion) {
return false; return false;
} }
} }

View file

@ -119,6 +119,7 @@ public final class BlockUtils {
world.spawnEntityInWorld(entityitem); world.spawnEntityInWorld(entityitem);
} }
@Deprecated
public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) { public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) {
if (block == null || block.isAir(world, x, y, z)) { if (block == null || block.isAir(world, x, y, z)) {
return false; return false;
@ -139,13 +140,13 @@ public final class BlockUtils {
return false; return false;
} }
// TODO: Make this support all "heavy" liquids, not just oil/lava
if (block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() != null && "oil".equals(((IFluidBlock) block).getFluid().getName())) {
return false;
}
if (block == Blocks.lava || block == Blocks.flowing_lava) { if (block == Blocks.lava || block == Blocks.flowing_lava) {
return false; return false;
} else if (block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() != null) {
Fluid f = ((IFluidBlock) block).getFluid();
if (f.getDensity(world, x, y, z) >= 3000) {
return false;
}
} }
return true; return true;

View file

@ -14,7 +14,6 @@ import net.minecraft.world.IBlockAccess;
import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.BuildCraftAPI;
public class WorldPropertyIsSoft extends WorldProperty { public class WorldPropertyIsSoft extends WorldProperty {
@Override @Override
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) { public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
return block == null return block == null

View file

@ -62,7 +62,10 @@ public class DockingStationPipe extends DockingStation {
public IPipeTile getPipe() { public IPipeTile getPipe() {
if (pipe == null) { if (pipe == null) {
pipe = (IPipeTile) world.getTileEntity(x(), y(), z()); TileEntity tile = world.getTileEntity(x(), y(), z());
if (tile instanceof IPipeTile) {
pipe = (IPipeTile) tile;
}
} }
if (pipe == null || ((TileEntity) pipe).isInvalid()) { if (pipe == null || ((TileEntity) pipe).isInvalid()) {

View file

@ -10,11 +10,10 @@ package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.ITransactor; import buildcraft.core.lib.inventory.ITransactor;
import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.Transactor;
@ -37,18 +36,24 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
filter = new AggregateFilter(ActionRobotFilterTool.getGateFilter(iRobot.getLinkedStation()), iFilter); filter = new AggregateFilter(ActionRobotFilterTool.getGateFilter(iRobot.getLinkedStation()), iFilter);
} }
@Override
public void start() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
}
@Override @Override
public void update() { public void update() {
if (robot.getDockingStation() == null) { if (robot.getDockingStation() == null) {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); setSuccess(false);
} else { terminate();
if (delay++ > 40) { }
if (equipItemStack()) {
terminate(); if (delay++ > 40) {
} else { if (equipItemStack()) {
delay = 0; terminate();
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); } else {
} delay = 0;
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
} }
} }
} }
@ -71,31 +76,20 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
} }
private boolean equipItemStack() { private boolean equipItemStack() {
if (robot.getDockingStation() != null) { IInventory tileInventory = robot.getDockingStation().getItemInput();
DockingStation station = robot.getDockingStation(); if (tileInventory == null) {
return false;
ItemStack itemFound = null;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
station.y() + dir.offsetY, station.z() + dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IInventory) {
ITransactor trans = Transactor.getTransactorFor(nearbyTile);
itemFound = trans.remove(filter, dir.getOpposite(), true);
if (itemFound != null) {
break;
}
}
}
if (itemFound != null) {
robot.setItemInUse(itemFound);
return true;
}
} }
ITransactor trans = Transactor.getTransactorFor(tileInventory);
ItemStack itemFound = trans.remove(filter, ForgeDirection.UNKNOWN, true);
if (itemFound != null) {
robot.setItemInUse(itemFound);
return true;
}
return false; return false;
} }
} }

View file

@ -36,7 +36,7 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
if (station == robot.getLinkedStation() && station == robot.getDockingStation()) { if (station == robot.getLinkedStation() && station == robot.getDockingStation()) {
terminate(); terminate();
} else { } else {
if (station.takeAsMain(robot)) { if (station != null && station.takeAsMain(robot)) {
startDelegateAI(new AIRobotGotoBlock(robot, startDelegateAI(new AIRobotGotoBlock(robot,
station.x() + station.side().offsetX * 2, station.x() + station.side().offsetX * 2,
station.y() + station.side().offsetY * 2, station.y() + station.side().offsetY * 2,
@ -52,10 +52,10 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
public void delegateAIEnded(AIRobot ai) { public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoBlock) { if (ai instanceof AIRobotGotoBlock) {
if (ai.success()) { if (ai.success()) {
startDelegateAI(new AIRobotStraightMoveTo(robot, startDelegateAI(new AIRobotStraightMoveTo(robot,
station.x() + 0.5F + station.side().offsetX * 0.5F, station.x() + 0.5F + station.side().offsetX * 0.5F,
station.y() + 0.5F + station.side().offsetY * 0.5F, station.y() + 0.5F + station.side().offsetY * 0.5F,
station.z() + 0.5F + station.side().offsetZ * 0.5F)); station.z() + 0.5F + station.side().offsetZ * 0.5F));
} else { } else {
terminate(); terminate();
} }

View file

@ -15,7 +15,7 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.IStackFilter; import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.ai.AIRobotBreak; import buildcraft.robotics.ai.AIRobotBreak;
import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack; import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robotics.ai.AIRobotSleep; import buildcraft.robotics.ai.AIRobotGotoSleep;
public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearchBlock { public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearchBlock {
@ -45,7 +45,7 @@ public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearc
public void delegateAIEnded(AIRobot ai) { public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotFetchAndEquipItemStack) { if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (!ai.success()) { if (!ai.success()) {
startDelegateAI(new AIRobotSleep(robot)); startDelegateAI(new AIRobotGotoSleep(robot));
} }
} else if (ai instanceof AIRobotBreak) { } else if (ai instanceof AIRobotBreak) {
releaseBlockFound(ai.success()); releaseBlockFound(ai.success());

View file

@ -112,7 +112,12 @@ public class TileStampingTable extends TileLaserTableBase implements IHasWork, I
NBTTagCompound tag = NBTUtils.getItemData(input); NBTTagCompound tag = NBTUtils.getItemData(input);
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
if (tag.hasKey("item" + i)) { if (tag.hasKey("item" + i)) {
crafting.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i))); ItemStack is = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i));
if (is != null) {
crafting.setInventorySlotContents(i, is);
} else {
return;
}
} else { } else {
crafting.setInventorySlotContents(i, null); crafting.setInventorySlotContents(i, null);
} }

View file

@ -47,18 +47,22 @@ public class PackageFontRenderer extends FontRenderer {
if (pkgTag.hasKey("item" + slotPos)) { if (pkgTag.hasKey("item" + slotPos)) {
ItemStack slotStack = ItemStack.loadItemStackFromNBT(pkgTag.getCompoundTag("item" + slotPos)); ItemStack slotStack = ItemStack.loadItemStackFromNBT(pkgTag.getCompoundTag("item" + slotPos));
GL11.glTranslatef(0.0F, 0.0F, 32.0F); if (slotStack != null) {
GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glTranslatef(0.0F, 0.0F, 32.0F);
FontRenderer font = slotStack.getItem().getFontRenderer(slotStack); GL11.glScalef(0.5F, 0.5F, 0.5F);
itemRender.zLevel = 200.0F; FontRenderer font = slotStack.getItem().getFontRenderer(slotStack);
itemRender.zLevel = 200.0F;
if (font == null || font instanceof PackageFontRenderer) { if (font == null || font instanceof PackageFontRenderer) {
font = Minecraft.getMinecraft().fontRenderer; font = Minecraft.getMinecraft().fontRenderer;
}
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.zLevel = 0.0F;
} else {
realRenderer.drawString("X", rx, y, 0xFF0000);
} }
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.zLevel = 0.0F;
} }
rx += 7; rx += 7;

View file

@ -226,9 +226,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
return; return;
} }
if (fluidType != null) { moveFluids();
moveFluids();
}
if (networkSyncTracker.markTimeIfDelay(container.getWorldObj())) { if (networkSyncTracker.markTimeIfDelay(container.getWorldObj())) {
boolean init = false; boolean init = false;
@ -245,17 +243,22 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
} }
private void moveFluids() { private void moveFluids() {
short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay); if (fluidType != null) {
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0); short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay);
int outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0);
moveFromPipe(outputCount); if (fluidType != null) {
moveFromCenter(); moveFromPipe(outputCount);
moveToCenter(); moveFromCenter();
moveToCenter();
}
} else {
computeTTLs();
}
} }
private void moveFromPipe(short outputCount) { private void moveFromPipe(int outputCount) {
// Move liquid from the non-center to the connected output blocks // Move liquid from the non-center to the connected output blocks
boolean pushed = false;
if (outputCount > 0) { if (outputCount > 0) {
for (ForgeDirection o : directions) { for (ForgeDirection o : directions) {
if (transferState[o.ordinal()] == TransferState.Output) { if (transferState[o.ordinal()] == TransferState.Output) {
@ -270,7 +273,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (liquidToPush.amount > 0) { if (liquidToPush.amount > 0) {
int filled = ((IFluidHandler) target).fill(o.getOpposite(), liquidToPush, true); int filled = ((IFluidHandler) target).fill(o.getOpposite(), liquidToPush, true);
section.drain(filled, true); section.drain(filled, true);
pushed = true;
if (filled <= 0) { if (filled <= 0) {
outputTTL[o.ordinal()]--; outputTTL[o.ordinal()]--;
} }
@ -278,19 +280,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
} }
} }
} }
if (pushed) {
boolean hasFluid = false;
for (PipeSection s: sections) {
if (s.amount > 0) {
hasFluid = true;
break;
}
}
if (!hasFluid) {
setFluidType(null);
}
}
} }
private void moveFromCenter() { private void moveFromCenter() {
@ -361,43 +350,76 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
} }
} }
private short computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) { private void computeTTLs() {
short outputCount = 0; for (int i = 0; i < 6; i++) {
if (transferState[i] == TransferState.Input) {
if (inputTTL[i] > 0) {
inputTTL[i]--;
} else {
transferState[i] = TransferState.None;
}
}
// Processes all interna4al tanks if (outputCooldown[i] > 0) {
outputCooldown[i]--;
} else {
if (outputTTL[i] > 0) {
outputTTL[i]--;
} else {
transferState[i] = TransferState.None;
}
}
}
}
private int computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) {
int outputCount = 0;
int fluidAmount = 0;
// Processes all internal tanks
for (ForgeDirection direction : orientations) { for (ForgeDirection direction : orientations) {
sections[direction.ordinal()].setTime(newTimeSlot); int dirI = direction.ordinal();
sections[direction.ordinal()].moveFluids(); PipeSection section = sections[dirI];
fluidAmount += section.amount;
section.setTime(newTimeSlot);
section.moveFluids();
// Input processing // Input processing
if (direction == ForgeDirection.UNKNOWN) { if (direction == ForgeDirection.UNKNOWN) {
continue; continue;
} }
if (transferState[direction.ordinal()] == TransferState.Input) { if (transferState[dirI] == TransferState.Input) {
inputTTL[direction.ordinal()]--; inputTTL[dirI]--;
if (inputTTL[direction.ordinal()] <= 0) { if (inputTTL[dirI] <= 0) {
transferState[direction.ordinal()] = TransferState.None; transferState[dirI] = TransferState.None;
} }
continue; continue;
} }
if (!container.pipe.outputOpen(direction)) { if (!container.pipe.outputOpen(direction)) {
transferState[direction.ordinal()] = TransferState.None; transferState[dirI] = TransferState.None;
continue; continue;
} }
if (outputCooldown[direction.ordinal()] > 0) { if (outputCooldown[dirI] > 0) {
outputCooldown[direction.ordinal()]--; outputCooldown[dirI]--;
continue; continue;
} }
if (outputTTL[direction.ordinal()] <= 0) { if (outputTTL[dirI] <= 0) {
transferState[direction.ordinal()] = TransferState.None; transferState[dirI] = TransferState.None;
outputCooldown[direction.ordinal()] = OUTPUT_COOLDOWN; outputCooldown[dirI] = OUTPUT_COOLDOWN;
outputTTL[direction.ordinal()] = OUTPUT_TTL; outputTTL[dirI] = OUTPUT_TTL;
continue; continue;
} }
if (canReceiveCache[direction.ordinal()] && outputOpen(direction)) { if (canReceiveCache[dirI] && outputOpen(direction)) {
transferState[direction.ordinal()] = TransferState.Output; transferState[dirI] = TransferState.Output;
outputCount++; outputCount++;
} }
} }
if (fluidAmount == 0) {
setFluidType(null);
}
return outputCount; return outputCount;
} }