improve robot tool handling, fix #3090

This commit is contained in:
asiekierka 2015-10-25 09:13:17 +01:00
parent d29a9bafd8
commit 9abd7e2a8a
6 changed files with 37 additions and 9 deletions

View file

@ -1,6 +1,7 @@
Improvements:
* [#3088] Miner Robots now support enchantments correctly. (asie)
* Robots ignore broken tools and unload them when they break - think Tinkers' Construct here. (asie)
* Stained Glass Pipe recipes now support ore dictionary colored glass. (asie)
* Tweaked item movement speed in pipes. (asie)
@ -12,6 +13,7 @@ Bugs fixed:
* [#3092, #3087, #3085] Robot unstucking code being a terrible hack - removed it for now (asie)
* [#3091, #3083] Various recipe disabling crashes (asie)
* [#3090] Robots delete repairable tools after they break (asie)
* [#3082] Void not killing robots (asie)
* [#3081] Emzuli Pipe behaviour bug (asie)

View file

@ -105,7 +105,7 @@ public class AIRobotBreak extends AIRobot {
.onBlockDestroyed(robot.getHeldItem(), robot.worldObj, block, blockToBreak.x,
blockToBreak.y, blockToBreak.z, robot);
if (robot.getHeldItem().getItemDamage() >= robot.getHeldItem().getMaxDamage()) {
if (robot.getHeldItem().stackSize == 0) {
robot.setItemInUse(null);
}
}

View file

@ -67,7 +67,7 @@ public class AIRobotUnload extends AIRobot {
if (!ActionRobotFilter
.canInteractWithItem(station, new ArrayStackOrListFilter(robotSlot.getStackInSlot()),
ActionStationAcceptItems.class)) {
return false;
continue;
}
ItemStack stack = robotSlot.getStackInSlot();
@ -81,6 +81,28 @@ public class AIRobotUnload extends AIRobot {
}
}
if (robot.getHeldItem() != null) {
if (!ActionRobotFilter
.canInteractWithItem(station, new ArrayStackOrListFilter(robot.getHeldItem()),
ActionStationAcceptItems.class)) {
return false;
}
ItemStack stack = robot.getHeldItem();
int used = output.injectItem(stack, doUnload, injectSide, null);
if (used > 0) {
if (doUnload) {
if (stack.stackSize <= used) {
robot.setItemInUse(null);
} else {
stack.stackSize -= used;
}
}
return true;
}
}
return false;
}

View file

@ -16,6 +16,8 @@ import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.ai.AIRobotBreak;
import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robotics.ai.AIRobotGotoSleep;
import buildcraft.robotics.ai.AIRobotGotoStationAndUnload;
import buildcraft.robotics.ai.AIRobotUnload;
public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearchBlock {
@ -31,9 +33,13 @@ public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearc
startDelegateAI(new AIRobotFetchAndEquipItemStack(robot, new IStackFilter() {
@Override
public boolean matches(ItemStack stack) {
return isExpectedTool(stack);
return stack != null
&& (stack.getItemDamage() < stack.getMaxDamage())
&& isExpectedTool(stack);
}
}));
} else if (robot.getHeldItem() != null && robot.getHeldItem().getItemDamage() >= robot.getHeldItem().getMaxDamage()) {
startDelegateAI(new AIRobotGotoStationAndUnload(robot));
} else if (blockFound() != null) {
startDelegateAI(new AIRobotBreak(robot, blockFound()));
} else {
@ -43,7 +49,7 @@ public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearc
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (ai instanceof AIRobotFetchAndEquipItemStack || ai instanceof AIRobotGotoStationAndUnload) {
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
}

View file

@ -41,10 +41,8 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
private void detectHarvestLevel() {
ItemStack stack = robot.getHeldItem();
if (stack != null && stack.getItem().getToolClasses(stack).contains("pickaxe")) {
ItemPickaxe pickaxe = (ItemPickaxe) stack.getItem();
harvestLevel = pickaxe.getHarvestLevel(stack, "pickaxe");
if (stack != null && stack.getItem() != null && stack.getItem().getToolClasses(stack).contains("pickaxe")) {
harvestLevel = stack.getItem().getHarvestLevel(stack, "pickaxe");
}
}

View file

@ -14,7 +14,7 @@ public final class TransportConstants {
public static final float PIPE_MIN_SPEED = (1.0F / 80.0F);
public static final float PIPE_MAX_SPEED = (1.0F / 7.0F);
public static final float PIPE_SLOWDOWN_SPEED = 0.005F;
public static final float PIPE_SLOWDOWN_SPEED = 0.008F;
public static final float PIPE_DEFAULT_SPEED = (1.0F / 25.0F);
/**