Utils ported
This commit is contained in:
@@ -21,7 +21,7 @@ package appeng.parts.misc;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -159,7 +159,7 @@ public class InterfacePart extends BasicStatePart implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
return this.duality.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class InterfacePart extends BasicStatePart implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc,
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
this.duality.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -52,11 +52,11 @@ import appeng.util.item.AEItemStack;
|
||||
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor {
|
||||
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
||||
private IActionSource mySource;
|
||||
private final ItemTransferable itemHandler;
|
||||
private final FixedItemInv itemHandler;
|
||||
private final IGridProxyable proxyable;
|
||||
private final InventoryCache cache;
|
||||
|
||||
ItemHandlerAdapter(ItemTransferable itemHandler, IGridProxyable proxy) {
|
||||
ItemHandlerAdapter(FixedItemInv itemHandler, IGridProxyable proxy) {
|
||||
this.itemHandler = itemHandler;
|
||||
this.proxyable = proxy;
|
||||
this.cache = new InventoryCache(this.itemHandler);
|
||||
@@ -67,7 +67,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
ItemStack orgInput = iox.createItemStack();
|
||||
ItemStack remaining = orgInput;
|
||||
|
||||
int slotCount = this.itemHandler.getSlots();
|
||||
int slotCount = this.itemHandler.getSlotCount();
|
||||
boolean simulate = (type == Actionable.SIMULATE);
|
||||
|
||||
// This uses a brute force approach and tries to jam it in every slot the
|
||||
@@ -104,8 +104,8 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
|
||||
final boolean simulate = (mode == Actionable.SIMULATE);
|
||||
|
||||
for (int i = 0; i < this.itemHandler.getSlots(); i++) {
|
||||
ItemStack stackInInventorySlot = this.itemHandler.getStackInSlot(i);
|
||||
for (int i = 0; i < this.itemHandler.getSlotCount(); i++) {
|
||||
ItemStack stackInInventorySlot = this.itemHandler.getInvStack(i);
|
||||
|
||||
if (!Platform.itemComparisons().isSameItem(stackInInventorySlot, requestedItemStack)) {
|
||||
continue;
|
||||
@@ -139,7 +139,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
if (gathered.isEmpty()) {
|
||||
gathered = extracted.copy();
|
||||
} else {
|
||||
gathered.grow(extracted.getCount());
|
||||
gathered.increment(extracted.getCount());
|
||||
}
|
||||
remainingCurrentSlot -= extracted.getCount();
|
||||
}
|
||||
@@ -220,9 +220,9 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
|
||||
private static class InventoryCache {
|
||||
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
||||
private final ItemTransferable itemHandler;
|
||||
private final FixedItemInv itemHandler;
|
||||
|
||||
public InventoryCache(ItemTransferable itemHandler) {
|
||||
public InventoryCache(FixedItemInv itemHandler) {
|
||||
this.itemHandler = itemHandler;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
|
||||
public List<IAEItemStack> update() {
|
||||
final List<IAEItemStack> changes = new ArrayList<>();
|
||||
final int slots = this.itemHandler.getSlots();
|
||||
final int slots = this.itemHandler.getSlotCount();
|
||||
|
||||
// Make room for new slots
|
||||
if (slots > this.cachedAeStacks.length) {
|
||||
@@ -243,7 +243,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
for (int slot = 0; slot < slots; slot++) {
|
||||
// Save the old stuff
|
||||
final IAEItemStack oldAeIS = this.cachedAeStacks[slot];
|
||||
final ItemStack newIS = this.itemHandler.getStackInSlot(slot);
|
||||
final ItemStack newIS = this.itemHandler.getInvStack(slot);
|
||||
|
||||
this.handlePossibleSlotChanges(slot, oldAeIS, newIS, changes);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -167,7 +167,7 @@ public class StorageBusPart extends UpgradeablePart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final ItemTransferable inv, final int slot, final InvOperation mc,
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class StorageBusPart extends UpgradeablePart
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.Config;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ public class StorageBusPart extends UpgradeablePart
|
||||
}
|
||||
|
||||
// Check via cap for IItemHandler
|
||||
final LazyOptional<ItemTransferable> handlerExtOpt = target
|
||||
final LazyOptional<FixedItemInv> handlerExtOpt = target
|
||||
.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide);
|
||||
if (handlerExtOpt.isPresent()) {
|
||||
return new ItemHandlerAdapter(handlerExtOpt.orElse(null), this);
|
||||
@@ -380,12 +380,12 @@ public class StorageBusPart extends UpgradeablePart
|
||||
return Objects.hash(target, accessorOpt.orElse(null));
|
||||
}
|
||||
|
||||
final LazyOptional<ItemTransferable> itemHandlerOpt = target
|
||||
final LazyOptional<FixedItemInv> itemHandlerOpt = target
|
||||
.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide);
|
||||
|
||||
if (itemHandlerOpt.isPresent()) {
|
||||
ItemTransferable itemHandler = itemHandlerOpt.orElse(null);
|
||||
return Objects.hash(target, itemHandler, itemHandler.getSlots());
|
||||
FixedItemInv itemHandler = itemHandlerOpt.orElse(null);
|
||||
return Objects.hash(target, itemHandler, itemHandler.getSlotCount());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user