parent
e3ff1ea288
commit
1d9341e22e
10 changed files with 72 additions and 22 deletions
|
@ -10,7 +10,6 @@ package buildcraft.api.blueprints;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
@ -98,13 +97,15 @@ public abstract class Schematic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.stackSize == 0 && stack.getItem().getContainerItem() != null) {
|
if (stack.stackSize == 0) {
|
||||||
Item container = stack.getItem().getContainerItem();
|
stack.stackSize = 1;
|
||||||
ItemStack newStack = new ItemStack(container);
|
if (stack.getItem().hasContainerItem(stack)) {
|
||||||
|
ItemStack newStack = stack.getItem().getContainerItem(stack);
|
||||||
slot.setStackInSlot(newStack);
|
slot.setStackInSlot(newStack);
|
||||||
} else if (stack.stackSize == 0) {
|
} else {
|
||||||
slot.setStackInSlot(null);
|
slot.setStackInSlot(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,12 @@ Bugs fixed:
|
||||||
* [#3000] Robots only charge to 20% when "go to home" is true (hea3ven, asie)
|
* [#3000] Robots only charge to 20% when "go to home" is true (hea3ven, asie)
|
||||||
* [#2996] DockingStationPipe crash (asie)
|
* [#2996] DockingStationPipe crash (asie)
|
||||||
* [#2994] Dupe with just about anything that mines (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)
|
* [#2984] List sorting crash with flowers (asie)
|
||||||
* [#2978] Programming Table refusing to work after item removal (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)
|
* [#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)
|
* [#2971] Stamping Table overflow on multiple-output items (asie)
|
||||||
* [#2969] Crash when Silicon present without Transport (asie)
|
* [#2969] Crash when Silicon present without Transport (asie)
|
||||||
* [#2964] Fluid/laser textures breaking on texture pack change (asie)
|
* [#2964] Fluid/laser textures breaking on texture pack change (asie)
|
||||||
|
|
|
@ -935,7 +935,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
|
||||||
|
|
||||||
for (IInvSlot slot : InventoryIterator.getIterable(this)) {
|
for (IInvSlot slot : InventoryIterator.getIterable(this)) {
|
||||||
if (slot.getStackInSlot() != null) {
|
if (slot.getStackInSlot() != null) {
|
||||||
if (StackHelper.isMatchingItem(requirement, slot.getStackInSlot())) {
|
if (StackHelper.isEqualItem(requirement, slot.getStackInSlot())) {
|
||||||
if (slot.getStackInSlot().stackSize >= left) {
|
if (slot.getStackInSlot().stackSize >= left) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
package buildcraft.core;
|
package buildcraft.core;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
|
|
@ -528,7 +528,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
|
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
|
||||||
boolean compatibleContainer = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
|
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 {
|
try {
|
||||||
stacksUsed.add(slot.useItem(context, reqStk, slotInv));
|
stacksUsed.add(slot.useItem(context, reqStk, slotInv));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -611,7 +611,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
|
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
|
||||||
boolean fluidFound = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
|
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 {
|
try {
|
||||||
usedStack = slot.getSchematic().useItem(context, reqStk, slotInv);
|
usedStack = slot.getSchematic().useItem(context, reqStk, slotInv);
|
||||||
slot.addStackConsumed (usedStack);
|
slot.addStackConsumed (usedStack);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class BuildingSlotBlock extends BuildingSlot {
|
||||||
for (ItemStack s : sb.storedRequirements) {
|
for (ItemStack s : sb.storedRequirements) {
|
||||||
boolean contains = false;
|
boolean contains = false;
|
||||||
for (ItemStack ss : oldRequirements) {
|
for (ItemStack ss : oldRequirements) {
|
||||||
if (StackHelper.isMatchingItem(s, ss)) {
|
if (StackHelper.isEqualItem(s, ss)) {
|
||||||
contains = true;
|
contains = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class StackHelper {
|
||||||
return false;
|
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) {
|
if (a == null || b == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,21 @@ public class StackHelper {
|
||||||
* @param comparison The stack to compare.
|
* @param comparison The stack to compare.
|
||||||
* @return true if id, damage and NBT match.
|
* @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);
|
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.
|
* Compares item id, and optionally damage and NBT. Accepts wildcard damage.
|
||||||
* Ignores damage entirely if the item doesn't have subtypes.
|
* Ignores damage entirely if the item doesn't have subtypes.
|
||||||
|
|
|
@ -74,6 +74,7 @@ public class AIRobotLoad extends AIRobot {
|
||||||
|
|
||||||
if (stack == null
|
if (stack == null
|
||||||
|| !filter.matches(stack)
|
|| !filter.matches(stack)
|
||||||
|
|| !ActionStationProvideItems.canExtractItem(station, stack)
|
||||||
|| !ActionRobotFilter.canInteractWithItem(station, filter,
|
|| !ActionRobotFilter.canInteractWithItem(station, filter,
|
||||||
ActionStationProvideItems.class)) {
|
ActionStationProvideItems.class)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -9,11 +9,15 @@
|
||||||
package buildcraft.robotics.statements;
|
package buildcraft.robotics.statements;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
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.IActionInternal;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
import buildcraft.api.statements.StatementParameterItemStack;
|
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.lib.utils.StringUtils;
|
||||||
import buildcraft.core.statements.BCStatement;
|
import buildcraft.core.statements.BCStatement;
|
||||||
|
|
||||||
|
@ -48,4 +52,24 @@ public class ActionStationProvideItems extends BCStatement implements IActionInt
|
||||||
IStatementParameter[] parameters) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import buildcraft.api.gates.IGate;
|
||||||
import buildcraft.api.gates.IGateExpansion;
|
import buildcraft.api.gates.IGateExpansion;
|
||||||
import buildcraft.api.statements.IActionInternal;
|
import buildcraft.api.statements.IActionInternal;
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.core.lib.utils.MathUtils;
|
|
||||||
import buildcraft.transport.statements.ActionEnergyPulsar;
|
import buildcraft.transport.statements.ActionEnergyPulsar;
|
||||||
import buildcraft.transport.statements.ActionSingleEnergyPulse;
|
import buildcraft.transport.statements.ActionSingleEnergyPulse;
|
||||||
|
|
||||||
|
@ -39,6 +38,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GateExpansionControllerPulsar extends GateExpansionController {
|
private class GateExpansionControllerPulsar extends GateExpansionController {
|
||||||
|
|
||||||
private static final int PULSE_PERIOD = 10;
|
private static final int PULSE_PERIOD = 10;
|
||||||
private boolean isActive;
|
private boolean isActive;
|
||||||
private boolean singlePulse;
|
private boolean singlePulse;
|
||||||
|
@ -58,7 +58,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startResolution() {
|
public void startResolution() {
|
||||||
if (isActive) {
|
if (isActive()) {
|
||||||
disablePulse();
|
disablePulse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,35 +84,46 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(IGate gate) {
|
public void tick(IGate gate) {
|
||||||
|
if (!isActive && hasPulsed) {
|
||||||
|
hasPulsed = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (tick++ % PULSE_PERIOD != 0) {
|
if (tick++ % PULSE_PERIOD != 0) {
|
||||||
// only do the treatement once every period
|
// only do the treatement once every period
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gate.setPulsing(isActive);
|
if (!isActive) {
|
||||||
|
gate.setPulsing(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pipeTile instanceof IEnergyHandler && ((singlePulse && !hasPulsed) || (!singlePulse && isActive))) {
|
if (pipeTile instanceof IEnergyHandler && (!singlePulse || !hasPulsed)) {
|
||||||
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, MathUtils.clamp(1 << (count - 1), 1, 64) * 10,
|
gate.setPulsing(true);
|
||||||
|
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, Math.min(1 << (count - 1), 64) * 10,
|
||||||
false);
|
false);
|
||||||
hasPulsed = true;
|
hasPulsed = true;
|
||||||
|
} else {
|
||||||
|
gate.setPulsing(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableSinglePulse(int count) {
|
private void enableSinglePulse(int count) {
|
||||||
isActive = true;
|
|
||||||
singlePulse = true;
|
singlePulse = true;
|
||||||
hasPulsed = false;
|
isActive = true;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enablePulse(int count) {
|
private void enablePulse(int count) {
|
||||||
isActive = true;
|
isActive = true;
|
||||||
hasPulsed = false;
|
|
||||||
singlePulse = false;
|
singlePulse = false;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disablePulse() {
|
private void disablePulse() {
|
||||||
|
if (!isActive) {
|
||||||
|
hasPulsed = false;
|
||||||
|
}
|
||||||
isActive = false;
|
isActive = false;
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue