fix #2991, fix #2976, fix #2974, BuildCraft 7.0.22

This commit is contained in:
asiekierka 2015-09-04 17:40:36 +02:00
parent e3ff1ea288
commit 1d9341e22e
10 changed files with 72 additions and 22 deletions

View file

@ -10,7 +10,6 @@ package buildcraft.api.blueprints;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -98,13 +97,15 @@ public abstract class Schematic {
}
}
if (stack.stackSize == 0 && stack.getItem().getContainerItem() != null) {
Item container = stack.getItem().getContainerItem();
ItemStack newStack = new ItemStack(container);
if (stack.stackSize == 0) {
stack.stackSize = 1;
if (stack.getItem().hasContainerItem(stack)) {
ItemStack newStack = stack.getItem().getContainerItem(stack);
slot.setStackInSlot(newStack);
} else if (stack.stackSize == 0) {
} else {
slot.setStackInSlot(null);
}
}
return result;
}

View file

@ -3,9 +3,12 @@ Bugs fixed:
* [#3000] Robots only charge to 20% when "go to home" is true (hea3ven, asie)
* [#2996] DockingStationPipe crash (asie)
* [#2994] Dupe with just about anything that mines (asie)
* [#2991] Carrier robots ignoring Provide Items filters (asie)
* [#2984] List sorting crash with flowers (asie)
* [#2978] Programming Table refusing to work after item removal (asie)
* [#2977, #2526] Assembly Table voiding excess energy (just made it not void it after all) (asie)
* [#2976] Builder dupes (asie)
* [#2974] Single Energy Pulse fix makes things worse - revert to previous code (asie)
* [#2971] Stamping Table overflow on multiple-output items (asie)
* [#2969] Crash when Silicon present without Transport (asie)
* [#2964] Fluid/laser textures breaking on texture pack change (asie)

View file

@ -935,7 +935,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
for (IInvSlot slot : InventoryIterator.getIterable(this)) {
if (slot.getStackInSlot() != null) {
if (StackHelper.isMatchingItem(requirement, slot.getStackInSlot())) {
if (StackHelper.isEqualItem(requirement, slot.getStackInSlot())) {
if (slot.getStackInSlot().stackSize >= left) {
return 0;
} else {

View file

@ -9,7 +9,6 @@
package buildcraft.core;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.WeakHashMap;

View file

@ -528,7 +528,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
boolean compatibleContainer = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
if (StackHelper.isMatchingItem(reqStk, invStk, true, true) || compatibleContainer) {
if (StackHelper.isEqualItem(reqStk, invStk) || compatibleContainer) {
try {
stacksUsed.add(slot.useItem(context, reqStk, slotInv));
} catch (Throwable t) {
@ -611,7 +611,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
boolean fluidFound = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
if (fluidFound || StackHelper.isMatchingItem(reqStk, invStk, true, true)) {
if (fluidFound || StackHelper.isEqualItem(reqStk, invStk)) {
try {
usedStack = slot.getSchematic().useItem(context, reqStk, slotInv);
slot.addStackConsumed (usedStack);

View file

@ -85,7 +85,7 @@ public class BuildingSlotBlock extends BuildingSlot {
for (ItemStack s : sb.storedRequirements) {
boolean contains = false;
for (ItemStack ss : oldRequirements) {
if (StackHelper.isMatchingItem(s, ss)) {
if (StackHelper.isEqualItem(s, ss)) {
contains = true;
break;
}

View file

@ -133,7 +133,7 @@ public class StackHelper {
return false;
}
public static boolean isMatchingItemOrList(ItemStack a, ItemStack b) {
public static boolean isMatchingItemOrList(final ItemStack a, final ItemStack b) {
if (a == null || b == null) {
return false;
}
@ -157,10 +157,21 @@ public class StackHelper {
* @param comparison The stack to compare.
* @return true if id, damage and NBT match.
*/
public static boolean isMatchingItem(ItemStack base, ItemStack comparison) {
public static boolean isMatchingItem(final ItemStack base, final ItemStack comparison) {
return isMatchingItem(base, comparison, true, true);
}
/**
* This variant also checks damage for damaged items.
*/
public static boolean isEqualItem(final ItemStack a, final ItemStack b) {
if (isMatchingItem(a, b, false, true)) {
return isWildcard(a) || isWildcard(b) || a.getItemDamage() == b.getItemDamage();
} else {
return false;
}
}
/**
* Compares item id, and optionally damage and NBT. Accepts wildcard damage.
* Ignores damage entirely if the item doesn't have subtypes.

View file

@ -74,6 +74,7 @@ public class AIRobotLoad extends AIRobot {
if (stack == null
|| !filter.matches(stack)
|| !ActionStationProvideItems.canExtractItem(station, stack)
|| !ActionRobotFilter.canInteractWithItem(station, filter,
ActionStationProvideItems.class)) {
continue;

View file

@ -9,11 +9,15 @@
package buildcraft.robotics.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.inventory.filters.StatementParameterStackFilter;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
@ -48,4 +52,24 @@ public class ActionStationProvideItems extends BCStatement implements IActionInt
IStatementParameter[] parameters) {
}
public static boolean canExtractItem(DockingStation station, ItemStack stack) {
boolean hasFilter = false;
for (StatementSlot s : station.getActiveActions()) {
if (s.statement instanceof ActionStationProvideItems) {
StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);
if (param.hasFilter()) {
hasFilter = true;
if (param.matches(stack)) {
return true;
}
}
}
}
return !hasFilter;
}
}

View file

@ -21,7 +21,6 @@ import buildcraft.api.gates.IGate;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatement;
import buildcraft.core.lib.utils.MathUtils;
import buildcraft.transport.statements.ActionEnergyPulsar;
import buildcraft.transport.statements.ActionSingleEnergyPulse;
@ -39,6 +38,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
}
private class GateExpansionControllerPulsar extends GateExpansionController {
private static final int PULSE_PERIOD = 10;
private boolean isActive;
private boolean singlePulse;
@ -58,7 +58,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
@Override
public void startResolution() {
if (isActive) {
if (isActive()) {
disablePulse();
}
}
@ -84,35 +84,46 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
@Override
public void tick(IGate gate) {
if (!isActive && hasPulsed) {
hasPulsed = false;
}
if (tick++ % PULSE_PERIOD != 0) {
// only do the treatement once every period
return;
}
gate.setPulsing(isActive);
if (!isActive) {
gate.setPulsing(false);
return;
}
if (pipeTile instanceof IEnergyHandler && ((singlePulse && !hasPulsed) || (!singlePulse && isActive))) {
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, MathUtils.clamp(1 << (count - 1), 1, 64) * 10,
if (pipeTile instanceof IEnergyHandler && (!singlePulse || !hasPulsed)) {
gate.setPulsing(true);
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, Math.min(1 << (count - 1), 64) * 10,
false);
hasPulsed = true;
} else {
gate.setPulsing(true);
}
}
private void enableSinglePulse(int count) {
isActive = true;
singlePulse = true;
hasPulsed = false;
isActive = true;
this.count = count;
}
private void enablePulse(int count) {
isActive = true;
hasPulsed = false;
singlePulse = false;
this.count = count;
}
private void disablePulse() {
if (!isActive) {
hasPulsed = false;
}
isActive = false;
this.count = 0;
}