This commit is contained in:
asiekierka 2015-10-15 17:41:59 +02:00
parent b7cf71a7dd
commit d2258ff497
2 changed files with 31 additions and 22 deletions

View file

@ -1,4 +1,5 @@
Bugs fixed:
* [#3079] Emzuli pipe's round-robin extraction behaving incorrectly (asie)
* [#3075] Rare crash in AIRobotGoAndLinkToDock (asie)
* Robot unstucking issues (asie)

View file

@ -17,6 +17,7 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -88,13 +89,10 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
*/
@Override
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
if (activeFlags.isEmpty()) {
return null;
}
incrementFilter();
if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)) {
return null;
}
@ -110,26 +108,36 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
}
@Override
public ItemStack checkExtractGeneric(net.minecraft.inventory.ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null && stack.stackSize > 0) {
public ItemStack checkExtractGeneric(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
if (inventory == null) {
return null;
}
ItemStack filter = getCurrentFilter();
if (filter == null) {
return null;
}
if (!StackHelper.isMatchingItemOrList(stack, filter)) {
continue;
}
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
continue;
}
if (doRemove) {
int stackSize = (int) Math.floor(battery.useEnergy(10, stack.stackSize * 10, false) / 10);
return inventory.decrStackSize(i, stackSize);
for (int k : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
ItemStack slot = inventory.getStackInSlot(k);
if (slot != null && slot.stackSize > 0 && inventory.canExtractItem(k, slot, from.ordinal())) {
if (!StackHelper.isMatchingItemOrList(slot, filter)) {
continue;
}
if (doRemove) {
int maxStackSize = slot.stackSize;
int stackSize = Math.min(maxStackSize, battery.getEnergyStored() / 10);
int energyUsed = (int) (stackSize * 10 * speedMultiplier);
battery.useEnergy(energyUsed, energyUsed, false);
// Only increment the filter position after a successful extraction
incrementFilter();
return inventory.decrStackSize(k, stackSize);
} else {
return stack;
return slot;
}
}
}
@ -226,6 +234,6 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
}
private ItemStack getCurrentFilter() {
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
return filters.getStackInSlot(currentFilter % filterCount);
}
}