From 367fa3f1e2f0ad69317f1225ed97c5815dcb5789 Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Thu, 9 Jul 2015 15:55:03 -0300 Subject: [PATCH 01/11] fix robots sinking through the ground, fixes #2831 --- common/buildcraft/robotics/DockingStationPipe.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/robotics/DockingStationPipe.java b/common/buildcraft/robotics/DockingStationPipe.java index 39181335..f685e465 100644 --- a/common/buildcraft/robotics/DockingStationPipe.java +++ b/common/buildcraft/robotics/DockingStationPipe.java @@ -62,7 +62,10 @@ public class DockingStationPipe extends DockingStation { public IPipeTile getPipe() { 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()) { From 0db636f6b53f914a7da37ab4ef9fd07a3340b54c Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Thu, 9 Jul 2015 16:34:33 -0300 Subject: [PATCH 02/11] fix robots ignoring gate config on their linked station when eqqupping items --- .../ai/AIRobotFetchAndEquipItemStack.java | 64 +++++++++---------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java b/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java index 2514c042..e056409a 100755 --- a/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java +++ b/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java @@ -10,11 +10,10 @@ package buildcraft.robotics.ai; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.robots.AIRobot; -import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; import buildcraft.core.lib.inventory.ITransactor; import buildcraft.core.lib.inventory.Transactor; @@ -37,18 +36,24 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot { filter = new AggregateFilter(ActionRobotFilterTool.getGateFilter(iRobot.getLinkedStation()), iFilter); } + @Override + public void start() { + startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); + } + @Override public void update() { if (robot.getDockingStation() == null) { - startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); - } else { - if (delay++ > 40) { - if (equipItemStack()) { - terminate(); - } else { - delay = 0; - startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); - } + setSuccess(false); + terminate(); + } + + if (delay++ > 40) { + if (equipItemStack()) { + terminate(); + } else { + delay = 0; + startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1)); } } } @@ -71,31 +76,20 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot { } private boolean equipItemStack() { - if (robot.getDockingStation() != null) { - DockingStation station = robot.getDockingStation(); - - 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; - } + IInventory tileInventory = robot.getDockingStation().getItemInput(); + if (tileInventory == null) { + return false; } + + ITransactor trans = Transactor.getTransactorFor(tileInventory); + + ItemStack itemFound = trans.remove(filter, ForgeDirection.UNKNOWN, true); + + if (itemFound != null) { + robot.setItemInUse(itemFound); + return true; + } + return false; } } From 51ac62ce7b4814ffd5aad980697955431f81d11d Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Thu, 9 Jul 2015 16:37:37 -0300 Subject: [PATCH 03/11] fix block breaking robots sleeping in mid air --- .../robotics/boards/BoardRobotGenericBreakBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java b/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java index 4e080e0f..40195a09 100644 --- a/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java +++ b/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java @@ -15,7 +15,7 @@ import buildcraft.api.robots.EntityRobotBase; import buildcraft.core.lib.inventory.filters.IStackFilter; import buildcraft.robotics.ai.AIRobotBreak; import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack; -import buildcraft.robotics.ai.AIRobotSleep; +import buildcraft.robotics.ai.AIRobotGotoSleep; public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearchBlock { @@ -45,7 +45,7 @@ public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearc public void delegateAIEnded(AIRobot ai) { if (ai instanceof AIRobotFetchAndEquipItemStack) { if (!ai.success()) { - startDelegateAI(new AIRobotSleep(robot)); + startDelegateAI(new AIRobotGotoSleep(robot)); } } else if (ai instanceof AIRobotBreak) { releaseBlockFound(ai.success()); From f81541c8db19caf5058902c5ef9b06b28e40cf21 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 10 Jul 2015 09:46:55 +0200 Subject: [PATCH 04/11] fix #2877, #2878, add changelog --- buildcraft_resources/changelog/7.0.14 | 10 ++++++++++ .../core/blueprints/BptBuilderBlueprint.java | 6 ++++-- .../buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java | 10 +++++----- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 buildcraft_resources/changelog/7.0.14 diff --git a/buildcraft_resources/changelog/7.0.14 b/buildcraft_resources/changelog/7.0.14 new file mode 100644 index 00000000..4af0bab7 --- /dev/null +++ b/buildcraft_resources/changelog/7.0.14 @@ -0,0 +1,10 @@ +Bugs fixed: + +* [#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) +* [#2831] Robots sinking through the ground (hea3ven) +* Allow Builders to use arbitrary IPathProviders (asie) +* Block breaking robots sleeping in mid air (hea3ven) +* Incorrect Request Needed Items action name (asie) +* Robots ignoring gate config on their linked station when equipping items (hea3ven) diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index c94befc7..732a7cca 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -265,8 +265,10 @@ public class BptBuilderBlueprint extends BptBuilderBase { private int getBuildListCount() { int out = 0; - for (int i = 0; i < buildStageOccurences.length; i++) { - out += buildStageOccurences[i]; + if (buildStageOccurences != null) { + for (int i = 0; i < buildStageOccurences.length; i++) { + out += buildStageOccurences[i]; + } } return out; } diff --git a/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java b/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java index 10845d71..d83fe543 100755 --- a/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java +++ b/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java @@ -36,7 +36,7 @@ public class AIRobotGoAndLinkToDock extends AIRobot { if (station == robot.getLinkedStation() && station == robot.getDockingStation()) { terminate(); } else { - if (station.takeAsMain(robot)) { + if (station != null && station.takeAsMain(robot)) { startDelegateAI(new AIRobotGotoBlock(robot, station.x() + station.side().offsetX * 2, station.y() + station.side().offsetY * 2, @@ -52,10 +52,10 @@ public class AIRobotGoAndLinkToDock extends AIRobot { public void delegateAIEnded(AIRobot ai) { if (ai instanceof AIRobotGotoBlock) { if (ai.success()) { - startDelegateAI(new AIRobotStraightMoveTo(robot, - station.x() + 0.5F + station.side().offsetX * 0.5F, - station.y() + 0.5F + station.side().offsetY * 0.5F, - station.z() + 0.5F + station.side().offsetZ * 0.5F)); + startDelegateAI(new AIRobotStraightMoveTo(robot, + station.x() + 0.5F + station.side().offsetX * 0.5F, + station.y() + 0.5F + station.side().offsetY * 0.5F, + station.z() + 0.5F + station.side().offsetZ * 0.5F)); } else { terminate(); } From 6995b9afb39efa702784c0f78a735f07d8cde362 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 10 Jul 2015 12:57:59 +0200 Subject: [PATCH 05/11] fix #2860, improve fluid heuristics --- .../buildcraft/builders/LibraryDatabase.java | 30 +++++++++++-------- .../buildcraft/core/lib/utils/BlockUtils.java | 10 +++---- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/common/buildcraft/builders/LibraryDatabase.java b/common/buildcraft/builders/LibraryDatabase.java index 26ef28ad..0323fbc2 100644 --- a/common/buildcraft/builders/LibraryDatabase.java +++ b/common/buildcraft/builders/LibraryDatabase.java @@ -150,22 +150,26 @@ public class LibraryDatabase { int sepIndex = fileName.lastIndexOf(LibraryId.BPT_SEP_CHARACTER); int dotIndex = fileName.lastIndexOf('.'); - String extension = fileName.substring(dotIndex + 1); + if (dotIndex > 0) { + String extension = fileName.substring(dotIndex + 1); - if (sepIndex > 0) { - String prefix = fileName.substring(0, sepIndex); - String suffix = fileName.substring(sepIndex + 1); + if (sepIndex > 0) { + String prefix = fileName.substring(0, sepIndex); + String suffix = fileName.substring(sepIndex + 1); - id.name = prefix; - id.uniqueId = LibraryId.toBytes(suffix.substring(0, suffix.length() - (extension.length() + 1))); + id.name = prefix; + 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 { - id.name = fileName.substring(0, dotIndex); - id.uniqueId = new byte[0]; - } - id.extension = extension; - - if (!blueprintIds.contains(id)) { - blueprintIds.add(id); + BCLog.logger.warn("Found incorrectly named (no extension) blueprint file: '%s'!", fileName); } } diff --git a/common/buildcraft/core/lib/utils/BlockUtils.java b/common/buildcraft/core/lib/utils/BlockUtils.java index a9faae9f..e501e821 100644 --- a/common/buildcraft/core/lib/utils/BlockUtils.java +++ b/common/buildcraft/core/lib/utils/BlockUtils.java @@ -139,13 +139,13 @@ public final class BlockUtils { 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) { 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; From 4c0d83a838c145537fe95a87dcab299774a3886d Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Fri, 10 Jul 2015 09:11:50 -0300 Subject: [PATCH 06/11] fix an error in the robots ai loading --- api/buildcraft/api/robots/AIRobot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/buildcraft/api/robots/AIRobot.java b/api/buildcraft/api/robots/AIRobot.java index f22f8680..445f06cc 100755 --- a/api/buildcraft/api/robots/AIRobot.java +++ b/api/buildcraft/api/robots/AIRobot.java @@ -194,9 +194,9 @@ public class AIRobot { if (aiRobotClass != null) { delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class) .newInstance(robot); + delegateAI.parentAI = this; if (delegateAI.canLoadFromNBT()) { - delegateAI.parentAI = this; delegateAI.loadFromNBT(sub); } } From 2a4d591f8009dab54fec03b1d69328a7a8eaa51b Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Fri, 10 Jul 2015 09:13:31 -0300 Subject: [PATCH 07/11] fix packet spam on the construction marker, fixes #2837 --- common/buildcraft/builders/TileConstructionMarker.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common/buildcraft/builders/TileConstructionMarker.java b/common/buildcraft/builders/TileConstructionMarker.java index 15fec451..dfa40624 100755 --- a/common/buildcraft/builders/TileConstructionMarker.java +++ b/common/buildcraft/builders/TileConstructionMarker.java @@ -209,7 +209,6 @@ public class TileConstructionMarker extends TileBuildCraft implements IBuildingI @Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isServer() && "uploadBuildersInAction".equals(command)) { - BuildCraftCore.instance.sendToServer(new PacketCommand(this, "uploadBuildersInAction", null)); for (BuildingItem i : buildersInAction) { BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, createLaunchItemPacket(i)); } From f18757da0f99425ad30c886117c40e942805b2ec Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 10 Jul 2015 22:31:51 +0200 Subject: [PATCH 08/11] fix Package handling when mods are removed --- .../buildcraft/silicon/TileStampingTable.java | 7 +++++- .../silicon/render/PackageFontRenderer.java | 24 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/common/buildcraft/silicon/TileStampingTable.java b/common/buildcraft/silicon/TileStampingTable.java index f771edbe..4be60803 100644 --- a/common/buildcraft/silicon/TileStampingTable.java +++ b/common/buildcraft/silicon/TileStampingTable.java @@ -112,7 +112,12 @@ public class TileStampingTable extends TileLaserTableBase implements IHasWork, I NBTTagCompound tag = NBTUtils.getItemData(input); for (int i = 0; i < 9; 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 { crafting.setInventorySlotContents(i, null); } diff --git a/common/buildcraft/silicon/render/PackageFontRenderer.java b/common/buildcraft/silicon/render/PackageFontRenderer.java index 1c41c1b9..abeb80f4 100644 --- a/common/buildcraft/silicon/render/PackageFontRenderer.java +++ b/common/buildcraft/silicon/render/PackageFontRenderer.java @@ -47,18 +47,22 @@ public class PackageFontRenderer extends FontRenderer { if (pkgTag.hasKey("item" + slotPos)) { ItemStack slotStack = ItemStack.loadItemStackFromNBT(pkgTag.getCompoundTag("item" + slotPos)); - GL11.glTranslatef(0.0F, 0.0F, 32.0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - FontRenderer font = slotStack.getItem().getFontRenderer(slotStack); - itemRender.zLevel = 200.0F; + if (slotStack != null) { + GL11.glTranslatef(0.0F, 0.0F, 32.0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + FontRenderer font = slotStack.getItem().getFontRenderer(slotStack); + itemRender.zLevel = 200.0F; - if (font == null || font instanceof PackageFontRenderer) { - font = Minecraft.getMinecraft().fontRenderer; + if (font == null || font instanceof PackageFontRenderer) { + 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; From 3ba539ade3c16de32a3172d6326ba4aff8b7177f Mon Sep 17 00:00:00 2001 From: Adrian Date: Sat, 11 Jul 2015 09:20:51 +0200 Subject: [PATCH 09/11] update changelog, try to fix #2880 --- buildcraft_resources/changelog/7.0.14 | 4 + .../transport/PipeTransportFluids.java | 106 +++++++++++------- 2 files changed, 68 insertions(+), 42 deletions(-) diff --git a/buildcraft_resources/changelog/7.0.14 b/buildcraft_resources/changelog/7.0.14 index 4af0bab7..292bbd3e 100644 --- a/buildcraft_resources/changelog/7.0.14 +++ b/buildcraft_resources/changelog/7.0.14 @@ -1,10 +1,14 @@ 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) * 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) diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 29366912..12b03fce 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -226,9 +226,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler return; } - if (fluidType != null) { - moveFluids(); - } + moveFluids(); if (networkSyncTracker.markTimeIfDelay(container.getWorldObj())) { boolean init = false; @@ -245,17 +243,22 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } private void moveFluids() { - short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay); - short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0); + if (fluidType != null) { + short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay); + int outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0); - moveFromPipe(outputCount); - moveFromCenter(); - moveToCenter(); + if (fluidType != null) { + moveFromPipe(outputCount); + 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 - boolean pushed = false; if (outputCount > 0) { for (ForgeDirection o : directions) { if (transferState[o.ordinal()] == TransferState.Output) { @@ -270,7 +273,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (liquidToPush.amount > 0) { int filled = ((IFluidHandler) target).fill(o.getOpposite(), liquidToPush, true); section.drain(filled, true); - pushed = true; if (filled <= 0) { 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() { @@ -361,43 +350,76 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } } - private short computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) { - short outputCount = 0; + private void computeTTLs() { + 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) { - sections[direction.ordinal()].setTime(newTimeSlot); - sections[direction.ordinal()].moveFluids(); + int dirI = direction.ordinal(); + PipeSection section = sections[dirI]; + + fluidAmount += section.amount; + section.setTime(newTimeSlot); + section.moveFluids(); + // Input processing if (direction == ForgeDirection.UNKNOWN) { continue; } - if (transferState[direction.ordinal()] == TransferState.Input) { - inputTTL[direction.ordinal()]--; - if (inputTTL[direction.ordinal()] <= 0) { - transferState[direction.ordinal()] = TransferState.None; + if (transferState[dirI] == TransferState.Input) { + inputTTL[dirI]--; + if (inputTTL[dirI] <= 0) { + transferState[dirI] = TransferState.None; } continue; } if (!container.pipe.outputOpen(direction)) { - transferState[direction.ordinal()] = TransferState.None; + transferState[dirI] = TransferState.None; continue; } - if (outputCooldown[direction.ordinal()] > 0) { - outputCooldown[direction.ordinal()]--; + if (outputCooldown[dirI] > 0) { + outputCooldown[dirI]--; continue; } - if (outputTTL[direction.ordinal()] <= 0) { - transferState[direction.ordinal()] = TransferState.None; - outputCooldown[direction.ordinal()] = OUTPUT_COOLDOWN; - outputTTL[direction.ordinal()] = OUTPUT_TTL; + if (outputTTL[dirI] <= 0) { + transferState[dirI] = TransferState.None; + outputCooldown[dirI] = OUTPUT_COOLDOWN; + outputTTL[dirI] = OUTPUT_TTL; continue; } - if (canReceiveCache[direction.ordinal()] && outputOpen(direction)) { - transferState[direction.ordinal()] = TransferState.Output; + if (canReceiveCache[dirI] && outputOpen(direction)) { + transferState[dirI] = TransferState.Output; outputCount++; } } + + if (fluidAmount == 0) { + setFluidType(null); + } + return outputCount; } From 915d900a409208c7be968f009d222d2b2bc29eb7 Mon Sep 17 00:00:00 2001 From: Adrian Date: Sat, 11 Jul 2015 14:31:01 +0200 Subject: [PATCH 10/11] revert february 2013 optimization - fix 3 issues related to quarry mining --- api/buildcraft/api/blueprints/Schematic.java | 2 +- buildcraft_resources/changelog/7.0.14 | 1 + common/buildcraft/BuildCraftCore.java | 1 - common/buildcraft/builders/TileQuarry.java | 19 +------------------ .../buildcraft/core/lib/utils/BlockUtils.java | 1 + .../core/properties/WorldPropertyIsSoft.java | 1 - 6 files changed, 4 insertions(+), 21 deletions(-) diff --git a/api/buildcraft/api/blueprints/Schematic.java b/api/buildcraft/api/blueprints/Schematic.java index 4db2d289..b08cb4ea 100755 --- a/api/buildcraft/api/blueprints/Schematic.java +++ b/api/buildcraft/api/blueprints/Schematic.java @@ -38,7 +38,7 @@ public abstract class Schematic { * 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. */ - public static enum BuildingStage { + public enum BuildingStage { /** * Standalone blocks can be placed in the air, and they don't change * once placed. diff --git a/buildcraft_resources/changelog/7.0.14 b/buildcraft_resources/changelog/7.0.14 index 292bbd3e..cfd93a68 100644 --- a/buildcraft_resources/changelog/7.0.14 +++ b/buildcraft_resources/changelog/7.0.14 @@ -6,6 +6,7 @@ Bugs fixed: * [#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) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 0c61ba94..71fa1ed6 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -466,7 +466,6 @@ public class BuildCraftCore extends BuildCraftMod { BuildCraftAPI.softBlocks.add(Blocks.snow); BuildCraftAPI.softBlocks.add(Blocks.vine); BuildCraftAPI.softBlocks.add(Blocks.fire); - BuildCraftAPI.softBlocks.add(Blocks.air); FMLCommonHandler.instance().bus().register(new TickHandlerCore()); diff --git a/common/buildcraft/builders/TileQuarry.java b/common/buildcraft/builders/TileQuarry.java index b31f1b08..bd5e7de3 100644 --- a/common/buildcraft/builders/TileQuarry.java +++ b/common/buildcraft/builders/TileQuarry.java @@ -313,9 +313,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI 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++) { - Block block = worldObj.getBlock(nextTarget[0], y, nextTarget[2]); - if (BlockUtils.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2]) - || !BuildCraftAPI.isSoftBlock(worldObj, nextTarget[0], y, nextTarget[2])) { + if (isQuarriableBlock(nextTarget[0], y, nextTarget[2])) { createColumnVisitList(); columnVisitListIsUpdated = true; nextTarget = null; @@ -340,8 +338,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI */ private void createColumnVisitList() { 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]; for (int searchY = yCoord + 3; searchY >= 1; --searchY) { @@ -372,17 +368,8 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI for (int searchZ = startZ; searchZ != endZ; searchZ += incZ) { if (!blockedColumns[searchX][searchZ]) { - Integer height = columnHeights[searchX][searchZ]; 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); if (!BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)) { @@ -391,10 +378,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI 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 if (visitList.size() > builder.blueprint.sizeZ * builder.blueprint.sizeX * 2) { diff --git a/common/buildcraft/core/lib/utils/BlockUtils.java b/common/buildcraft/core/lib/utils/BlockUtils.java index e501e821..f8c319fd 100644 --- a/common/buildcraft/core/lib/utils/BlockUtils.java +++ b/common/buildcraft/core/lib/utils/BlockUtils.java @@ -119,6 +119,7 @@ public final class BlockUtils { world.spawnEntityInWorld(entityitem); } + @Deprecated public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) { if (block == null || block.isAir(world, x, y, z)) { return false; diff --git a/common/buildcraft/core/properties/WorldPropertyIsSoft.java b/common/buildcraft/core/properties/WorldPropertyIsSoft.java index cf778f19..dc4c7d3d 100755 --- a/common/buildcraft/core/properties/WorldPropertyIsSoft.java +++ b/common/buildcraft/core/properties/WorldPropertyIsSoft.java @@ -14,7 +14,6 @@ import net.minecraft.world.IBlockAccess; import buildcraft.api.core.BuildCraftAPI; public class WorldPropertyIsSoft extends WorldProperty { - @Override public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) { return block == null From 45384e0a53c2bd2b395b19425995e1097b09ffb1 Mon Sep 17 00:00:00 2001 From: Adrian Date: Sat, 11 Jul 2015 14:31:19 +0200 Subject: [PATCH 11/11] BuildCraft 7.0.14 --- build.gradle | 2 +- buildcraft_resources/changelog/7.0.14 | 4 ++++ buildcraft_resources/versions.txt | 2 +- common/buildcraft/builders/TilePathMarker.java | 1 - common/buildcraft/builders/TileQuarry.java | 7 +++++-- common/buildcraft/core/lib/block/BlockBuildCraftFluid.java | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 47b14cf4..f499e5c6 100755 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'forge' // adds the forge dependency apply plugin: 'maven' // for uploading to a maven repo apply plugin: 'checkstyle' -version = "7.0.13" +version = "7.0.14" 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] diff --git a/buildcraft_resources/changelog/7.0.14 b/buildcraft_resources/changelog/7.0.14 index cfd93a68..034c73a6 100644 --- a/buildcraft_resources/changelog/7.0.14 +++ b/buildcraft_resources/changelog/7.0.14 @@ -1,3 +1,7 @@ +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) diff --git a/buildcraft_resources/versions.txt b/buildcraft_resources/versions.txt index d04682a1..9deba00e 100755 --- a/buildcraft_resources/versions.txt +++ b/buildcraft_resources/versions.txt @@ -1,3 +1,3 @@ 1.6.4:BuildCraft:4.2.2 1.7.2:BuildCraft:6.0.16 -1.7.10:BuildCraft:7.0.13 +1.7.10:BuildCraft:7.0.14 diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index 84d70eb9..55708807 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -11,7 +11,6 @@ package buildcraft.builders; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import io.netty.buffer.ByteBuf; diff --git a/common/buildcraft/builders/TileQuarry.java b/common/buildcraft/builders/TileQuarry.java index bd5e7de3..d17679b9 100644 --- a/common/buildcraft/builders/TileQuarry.java +++ b/common/buildcraft/builders/TileQuarry.java @@ -17,6 +17,7 @@ import com.google.common.collect.Sets; import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; 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.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.IFluidBlock; import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftCore; @@ -374,7 +376,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI if (!BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)) { 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}); } @@ -470,7 +472,8 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI private boolean isQuarriableBlock(int bx, int by, int bz) { Block block = worldObj.getBlock(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 diff --git a/common/buildcraft/core/lib/block/BlockBuildCraftFluid.java b/common/buildcraft/core/lib/block/BlockBuildCraftFluid.java index 822206ef..9bbb1c80 100644 --- a/common/buildcraft/core/lib/block/BlockBuildCraftFluid.java +++ b/common/buildcraft/core/lib/block/BlockBuildCraftFluid.java @@ -186,7 +186,7 @@ public class BlockBuildCraftFluid extends BlockFluidClassic { } @Override - public boolean canDropFromExplosion(Explosion p_149659_1_) { + public boolean canDropFromExplosion(Explosion explosion) { return false; } }