Utils ported
This commit is contained in:
@@ -23,9 +23,11 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.util.*;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -37,7 +39,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -71,10 +73,6 @@ import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
@@ -90,8 +88,8 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
private final CraftingInventory craftingInv;
|
||||
private final AppEngInternalInventory gridInv = new AppEngInternalInventory(this, 9 + 1, 1);
|
||||
private final AppEngInternalInventory patternInv = new AppEngInternalInventory(this, 1, 1);
|
||||
private final ItemTransferable gridInvExt = new WrapperFilteredItemHandler(this.gridInv, new CraftingGridFilter());
|
||||
private final ItemTransferable internalInv = new WrapperChainedItemHandler(this.gridInv, this.patternInv);
|
||||
private final FixedItemInv gridInvExt = new WrapperFilteredItemHandler(this.gridInv, new CraftingGridFilter());
|
||||
private final FixedItemInv internalInv = new WrapperChainedItemHandler(this.gridInv, this.patternInv);
|
||||
private final IConfigManager settings;
|
||||
private final UpgradeInventory upgrades;
|
||||
private boolean isPowered = false;
|
||||
@@ -133,8 +131,8 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
this.myPlan = patternDetails;
|
||||
this.pushDirection = AEPartLocation.fromFacing(where);
|
||||
|
||||
for (int x = 0; x < table.getSizeInventory(); x++) {
|
||||
this.gridInv.setStackInSlot(x, table.getStackInSlot(x));
|
||||
for (int x = 0; x < table.size(); x++) {
|
||||
this.gridInv.setStackInSlot(x, table.getStack(x));
|
||||
}
|
||||
|
||||
this.updateSleepiness();
|
||||
@@ -170,8 +168,8 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) {
|
||||
this.craftingInv.setInventorySlotContents(x, this.gridInv.getStackInSlot(x));
|
||||
for (int x = 0; x < this.craftingInv.size(); x++) {
|
||||
this.craftingInv.setStack(x, this.gridInv.getStackInSlot(x));
|
||||
}
|
||||
|
||||
return !this.myPlan.getOutput(this.craftingInv, this.getWorld()).isEmpty();
|
||||
@@ -208,7 +206,7 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
final ItemStack pattern = this.myPlan.getPattern();
|
||||
if (!pattern.isEmpty()) {
|
||||
final CompoundTag compound = new CompoundTag();
|
||||
pattern.write(compound);
|
||||
pattern.toTag(compound);
|
||||
data.put("myPlan", compound);
|
||||
data.putInt("pushDirection", this.pushDirection.ordinal());
|
||||
}
|
||||
@@ -223,7 +221,7 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
public void fromTag(BlockState state, final CompoundTag data) {
|
||||
super.fromTag(state, data);
|
||||
if (data.contains("myPlan")) {
|
||||
final ItemStack myPat = ItemStack.read(data.getCompound("myPlan"));
|
||||
final ItemStack myPat = ItemStack.fromTag(data.getCompound("myPlan"));
|
||||
|
||||
if (!myPat.isEmpty() && myPat.getItem() instanceof EncodedPatternItem) {
|
||||
final World w = this.getWorld();
|
||||
@@ -290,7 +288,7 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("upgrades")) {
|
||||
return this.upgrades;
|
||||
}
|
||||
@@ -308,17 +306,17 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.internalInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(Direction side) {
|
||||
protected FixedItemInv getItemHandlerForSide(Direction side) {
|
||||
return this.gridInvExt;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (inv == this.gridInv || inv == this.patternInv) {
|
||||
this.recalculatePlan();
|
||||
@@ -401,20 +399,20 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
if (this.progress >= 100) {
|
||||
for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) {
|
||||
this.craftingInv.setInventorySlotContents(x, this.gridInv.getStackInSlot(x));
|
||||
for (int x = 0; x < this.craftingInv.size(); x++) {
|
||||
this.craftingInv.setStack(x, this.gridInv.getStackInSlot(x));
|
||||
}
|
||||
|
||||
this.progress = 0;
|
||||
final ItemStack output = this.myPlan.getOutput(this.craftingInv, this.getWorld());
|
||||
if (!output.isEmpty()) {
|
||||
BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) this.getWorld()), output,
|
||||
BasicEventHooks.firePlayerCraftingEvent((PlayerEntity) FakePlayer.getOrCreate((ServerWorld) this.getWorld()), output,
|
||||
this.craftingInv);
|
||||
|
||||
this.pushOut(output.copy());
|
||||
|
||||
for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) {
|
||||
this.gridInv.setStackInSlot(x, Platform.getContainerItem(this.craftingInv.getStackInSlot(x)));
|
||||
for (int x = 0; x < this.craftingInv.size(); x++) {
|
||||
this.gridInv.setStackInSlot(x, Platform.getRecipeRemainder(this.craftingInv.getStack(x)));
|
||||
}
|
||||
|
||||
if (ItemHandlerUtil.isEmpty(this.patternInv)) {
|
||||
@@ -561,12 +559,12 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return slot == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
if (slot >= 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.tile.grindstone;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@@ -36,7 +36,7 @@ import appeng.tile.AEBaseInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
@@ -45,7 +45,7 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
private static final int SLOT_PROCESSING = 6;
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 7);
|
||||
private final ItemTransferable invExt = new WrapperFilteredItemHandler(this.inv, new GrinderFilter());
|
||||
private final FixedItemInv invExt = new WrapperFilteredItemHandler(this.inv, new GrinderFilter());
|
||||
private int points;
|
||||
|
||||
public GrinderBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
@@ -60,17 +60,17 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(Direction side) {
|
||||
protected FixedItemInv getItemHandlerForSide(Direction side) {
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
}
|
||||
|
||||
this.points = 0;
|
||||
final InventoryAdaptor sia = new AdaptorItemHandler(new RangedWrapper(this.inv, 3, 6));
|
||||
final InventoryAdaptor sia = new AdaptorFixedInv(new RangedWrapper(this.inv, 3, 6));
|
||||
|
||||
this.addItem(sia, r.getRecipeOutput());
|
||||
|
||||
@@ -162,12 +162,12 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
|
||||
private class GrinderFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slotIndex, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slotIndex, int amount) {
|
||||
return slotIndex >= 3 && slotIndex <= 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slotIndex, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slotIndex, ItemStack stack) {
|
||||
if (!GrinderRecipes.isValidIngredient(world, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,14 +146,14 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
|
||||
if (!simulate) {
|
||||
if (existing.isEmpty()) {
|
||||
this.inv[slot] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
|
||||
.createStack(reachedLimit ? Platform.copyStackWithSize(stack, limit) : stack);
|
||||
} else {
|
||||
existing.grow(reachedLimit ? limit : stack.getCount());
|
||||
existing.increment(reachedLimit ? limit : stack.getCount());
|
||||
}
|
||||
this.fireOnChangeInventory(slot, InvOperation.INSERT, ItemStack.EMPTY,
|
||||
reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
|
||||
reachedLimit ? Platform.copyStackWithSize(stack, limit) : stack);
|
||||
}
|
||||
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
|
||||
return reachedLimit ? Platform.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,11 +169,11 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
|
||||
return split;
|
||||
} else {
|
||||
if (!simulate) {
|
||||
split.grow(-amount);
|
||||
split.increment(-amount);
|
||||
this.fireOnChangeInventory(slot, InvOperation.EXTRACT,
|
||||
ItemHandlerHelper.copyStackWithSize(split, amount), ItemStack.EMPTY);
|
||||
Platform.copyStackWithSize(split, amount), ItemStack.EMPTY);
|
||||
}
|
||||
return ItemHandlerHelper.copyStackWithSize(split, amount);
|
||||
return Platform.copyStackWithSize(split, amount);
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.tile.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -50,8 +50,8 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 63);
|
||||
private final ConfigManager manager = new ConfigManager(this);
|
||||
|
||||
private ItemTransferable cacheUpgrades = null;
|
||||
private ItemTransferable cacheConfig = null;
|
||||
private FixedItemInv cacheUpgrades = null;
|
||||
private FixedItemInv cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
public CellWorkbenchBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
@@ -60,7 +60,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
this.cell.setEnableClientEvents(true);
|
||||
}
|
||||
|
||||
public ItemTransferable getCellUpgradeInventory() {
|
||||
public FixedItemInv getCellUpgradeInventory() {
|
||||
if (this.cacheUpgrades == null) {
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if (cell == null) {
|
||||
@@ -72,7 +72,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemTransferable inv = cell.getUpgradesInventory(is);
|
||||
final FixedItemInv inv = cell.getUpgradesInventory(is);
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (inv == this.cell && !this.locked) {
|
||||
this.locked = true;
|
||||
@@ -138,11 +138,11 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
this.cacheUpgrades = null;
|
||||
this.cacheConfig = null;
|
||||
|
||||
final ItemTransferable configInventory = this.getCellConfigInventory();
|
||||
final FixedItemInv configInventory = this.getCellConfigInventory();
|
||||
if (configInventory != null) {
|
||||
boolean cellHasConfig = false;
|
||||
for (int x = 0; x < configInventory.getSlots(); x++) {
|
||||
if (!configInventory.getStackInSlot(x).isEmpty()) {
|
||||
for (int x = 0; x < configInventory.getSlotCount(); x++) {
|
||||
if (!configInventory.getInvStack(x).isEmpty()) {
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
|
||||
if (cellHasConfig) {
|
||||
for (int x = 0; x < this.config.getSlots(); x++) {
|
||||
this.config.setStackInSlot(x, configInventory.getStackInSlot(x));
|
||||
this.config.setStackInSlot(x, configInventory.getInvStack(x));
|
||||
}
|
||||
} else {
|
||||
ItemHandlerUtil.copy(this.config, configInventory, false);
|
||||
@@ -166,7 +166,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
this.locked = false;
|
||||
} else if (inv == this.config && !this.locked) {
|
||||
this.locked = true;
|
||||
final ItemTransferable c = this.getCellConfigInventory();
|
||||
final FixedItemInv c = this.getCellConfigInventory();
|
||||
if (c != null) {
|
||||
ItemHandlerUtil.copy(this.config, c, false);
|
||||
// copy items back. The ConfigInventory may changed the items on insert
|
||||
@@ -176,7 +176,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
}
|
||||
}
|
||||
|
||||
private ItemTransferable getCellConfigInventory() {
|
||||
private FixedItemInv getCellConfigInventory() {
|
||||
if (this.cacheConfig == null) {
|
||||
final ICellWorkbenchItem cell = this.getCell();
|
||||
if (cell == null) {
|
||||
@@ -188,7 +188,7 @@ public class CellWorkbenchBlockEntity extends AEBaseBlockEntity
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemTransferable inv = cell.getConfigInventory(is);
|
||||
final FixedItemInv inv = cell.getConfigInventory(is);
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -132,12 +132,12 @@ public class ChargerBlockEntity extends AENetworkPowerBlockEntity implements ICr
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
try {
|
||||
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
|
||||
@@ -253,15 +253,15 @@ public class ChargerBlockEntity extends AENetworkPowerBlockEntity implements ICr
|
||||
|
||||
private class ChargerInvFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, final int i, final ItemStack itemstack) {
|
||||
public boolean allowInsert(FixedItemInv inv, final int i, final ItemStack itemstack) {
|
||||
final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal();
|
||||
|
||||
return Platform.isChargeable(itemstack) || cert.isSameAs(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, final int slotIndex, int amount) {
|
||||
ItemStack extractedItem = inv.getStackInSlot(slotIndex);
|
||||
public boolean allowExtract(FixedItemInv inv, final int slotIndex, int amount) {
|
||||
ItemStack extractedItem = inv.getInvStack(slotIndex);
|
||||
|
||||
if (Platform.isChargeable(extractedItem)) {
|
||||
final IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -70,13 +70,13 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
|
||||
private final AppEngInternalInventory outputSlot = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory storageSlot = new AppEngInternalInventory(this, 1);
|
||||
private final ItemTransferable inputSlot = new CondenseItemHandler();
|
||||
private final FixedItemInv inputSlot = new CondenseItemHandler();
|
||||
private final IFluidHandler fluidHandler = new FluidHandler();
|
||||
private final MEHandler meHandler = new MEHandler();
|
||||
|
||||
private final ItemTransferable externalInv = new WrapperChainedItemHandler(this.inputSlot,
|
||||
private final FixedItemInv externalInv = new WrapperChainedItemHandler(this.inputSlot,
|
||||
new WrapperFilteredItemHandler(this.outputSlot, AEItemFilters.EXTRACT_ONLY));
|
||||
private final ItemTransferable combinedInv = new WrapperChainedItemHandler(this.inputSlot, this.outputSlot,
|
||||
private final FixedItemInv combinedInv = new WrapperChainedItemHandler(this.inputSlot, this.outputSlot,
|
||||
this.storageSlot);
|
||||
|
||||
private double storedPower = 0;
|
||||
@@ -143,7 +143,7 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
this.outputSlot.insertItem(0, output, false);
|
||||
}
|
||||
|
||||
ItemTransferable getOutputSlot() {
|
||||
FixedItemInv getOutputSlot() {
|
||||
return this.outputSlot;
|
||||
}
|
||||
|
||||
@@ -168,12 +168,12 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.combinedInv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (inv == this.outputSlot) {
|
||||
this.meHandler.outputChanged(added, removed);
|
||||
@@ -211,7 +211,7 @@ public class CondenserBlockEntity extends AEBaseInvBlockEntity implements IConfi
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
private class CondenseItemHandler implements ItemTransferable {
|
||||
private class CondenseItemHandler implements FixedItemInv {
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
|
||||
@@ -63,7 +63,7 @@ class CondenserItemInventory implements IMEMonitor<IAEItemStack>, ITickingMonito
|
||||
@Override
|
||||
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) {
|
||||
AEItemStack ret = null;
|
||||
ItemStack slotItem = this.target.getOutputSlot().getStackInSlot(0);
|
||||
ItemStack slotItem = this.target.getOutputSlot().getInvStack(0);
|
||||
if (!slotItem.isEmpty() && request.isSameType(slotItem)) {
|
||||
int count = (int) Math.min(request.getStackSize(), Integer.MAX_VALUE);
|
||||
ret = AEItemStack
|
||||
@@ -74,8 +74,8 @@ class CondenserItemInventory implements IMEMonitor<IAEItemStack>, ITickingMonito
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(final IItemList<IAEItemStack> out) {
|
||||
if (!this.target.getOutputSlot().getStackInSlot(0).isEmpty()) {
|
||||
out.add(AEItemStack.fromItemStack(this.target.getOutputSlot().getStackInSlot(0)));
|
||||
if (!this.target.getOutputSlot().getInvStack(0).isEmpty()) {
|
||||
out.add(AEItemStack.fromItemStack(this.target.getOutputSlot().getInvStack(0)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -90,9 +90,9 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory(this, 1, 1);
|
||||
private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory(this, 2, 1);
|
||||
|
||||
private final ItemTransferable topItemHandlerExtern;
|
||||
private final ItemTransferable bottomItemHandlerExtern;
|
||||
private final ItemTransferable sideItemHandlerExtern;
|
||||
private final FixedItemInv topItemHandlerExtern;
|
||||
private final FixedItemInv bottomItemHandlerExtern;
|
||||
private final FixedItemInv sideItemHandlerExtern;
|
||||
|
||||
private InscriberRecipe cachedTask = null;
|
||||
|
||||
@@ -207,12 +207,12 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
try {
|
||||
if (slot == 0) {
|
||||
@@ -342,7 +342,7 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("inv")) {
|
||||
return this.getInternalInventory();
|
||||
}
|
||||
@@ -355,7 +355,7 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
protected FixedItemInv getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
if (facing == this.getUp()) {
|
||||
return this.topItemHandlerExtern;
|
||||
} else if (facing == this.getUp().getOpposite()) {
|
||||
@@ -411,7 +411,7 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
*/
|
||||
private class ItemHandlerFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
if (InscriberBlockEntity.this.isSmash()) {
|
||||
return false;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class InscriberBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
// output slot
|
||||
if (slot == 1) {
|
||||
return false;
|
||||
|
||||
@@ -6,10 +6,10 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -38,7 +38,7 @@ public final class InscriberRecipes {
|
||||
* Returns an unmodifiable view of all registered inscriber recipes.
|
||||
*/
|
||||
public static Iterable<InscriberRecipe> getRecipes(World world) {
|
||||
Collection<IRecipe<IInventory>> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE)
|
||||
Collection<Recipe<Inventory>> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE)
|
||||
.values();
|
||||
return Iterables.filter(unfilteredRecipes, InscriberRecipe.class);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -196,7 +196,7 @@ public class InterfaceBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
return this.duality.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@@ -211,12 +211,12 @@ public class InterfaceBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.duality.getInternalInventory();
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
this.duality.onChangeInventory(inv, slot, mc, removed, added);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.EnumSet;
|
||||
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.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -110,7 +110,7 @@ public class SecurityStationBlockEntity extends AENetworkBlockEntity implements
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class SecurityStationBlockEntity extends AENetworkBlockEntity implements
|
||||
int offset = 0;
|
||||
for (final IAEItemStack ais : this.inventory.getStoredItems()) {
|
||||
final CompoundTag it = new CompoundTag();
|
||||
ais.createItemStack().write(it);
|
||||
ais.createItemStack().toTag(it);
|
||||
storedItems.put(String.valueOf(offset), it);
|
||||
offset++;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class SecurityStationBlockEntity extends AENetworkBlockEntity implements
|
||||
for (final Object key : storedItems.keySet()) {
|
||||
final INBT obj = storedItems.get((String) key);
|
||||
if (obj instanceof CompoundTag) {
|
||||
this.inventory.getStoredItems().add(AEItemStack.fromItemStack(ItemStack.read((CompoundTag) obj)));
|
||||
this.inventory.getStoredItems().add(AEItemStack.fromItemStack(ItemStack.fromTag((CompoundTag) obj)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -56,7 +56,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
public static final int MAX_BURN_SPEED = 200;
|
||||
public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1);
|
||||
private final ItemTransferable invExt = new WrapperFilteredItemHandler(this.inv, new FuelSlotFilter());
|
||||
private final FixedItemInv invExt = new WrapperFilteredItemHandler(this.inv, new FuelSlotFilter());
|
||||
|
||||
private int burnSpeed = 100;
|
||||
private double burnTime = 0;
|
||||
@@ -110,17 +110,17 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
protected FixedItemInv getItemHandlerForSide(@Nonnull Direction facing) {
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
if (this.canEatFuel()) {
|
||||
@@ -217,7 +217,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
is.shrink(1);
|
||||
|
||||
if (is.isEmpty()) {
|
||||
this.inv.setStackInSlot(0, fuelItem.getContainerItem(is));
|
||||
this.inv.setStackInSlot(0, fuelItem.getRecipeRemainder(is));
|
||||
} else {
|
||||
this.inv.setStackInSlot(0, is);
|
||||
}
|
||||
@@ -270,12 +270,12 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
|
||||
private class FuelSlotFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
return ForgeHooks.getBurnTime(inv.getStackInSlot(slot)) == 0;
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return ForgeHooks.getBurnTime(inv.getInvStack(slot)) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return ForgeHooks.getBurnTime(stack) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class CableBusBlockEntity extends AEBaseBlockEntity implements AEMultiTil
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors() {
|
||||
if (this.world != null && this.world.isBlockLoaded(this.pos) && !CableBusContainer.isLoading()) {
|
||||
if (this.world != null && this.world.isChunkLoaded(this.pos) && !CableBusContainer.isLoading()) {
|
||||
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -168,12 +168,12 @@ public class ControllerBlockEntity extends AENetworkPowerBlockEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return EmptyFixedItemInv.INSTANCE;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.tile.networking;
|
||||
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
@@ -68,12 +68,12 @@ public class EnergyAcceptorBlockEntity extends AENetworkPowerBlockEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return EmptyFixedItemInv.INSTANCE;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.tile.networking;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@@ -117,12 +117,12 @@ public class WirelessBlockEntity extends AENetworkInvBlockEntity implements IWir
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -113,12 +113,12 @@ public class QuantumBridgeBlockEntity extends AENetworkInvBlockEntity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.internalInventory;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (this.cluster != null) {
|
||||
this.cluster.updateStatus(true);
|
||||
@@ -126,7 +126,7 @@ public class QuantumBridgeBlockEntity extends AENetworkInvBlockEntity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(Direction side) {
|
||||
protected FixedItemInv getItemHandlerForSide(Direction side) {
|
||||
if (this.isCenter()) {
|
||||
return this.internalInventory;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.tile.spatial;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -55,7 +55,7 @@ import appeng.util.inv.filter.IAEItemFilter;
|
||||
public class SpatialIOPortBlockEntity extends AENetworkInvBlockEntity implements IWorldCallable<Void> {
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 2);
|
||||
private final ItemTransferable invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
|
||||
private final FixedItemInv invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
public SpatialIOPortBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
@@ -161,29 +161,29 @@ public class SpatialIOPortBlockEntity extends AENetworkInvBlockEntity implements
|
||||
|
||||
@Override
|
||||
protected @Nonnull
|
||||
ItemTransferable getItemHandlerForSide(@Nonnull Direction side) {
|
||||
FixedItemInv getItemHandlerForSide(@Nonnull Direction side) {
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
|
||||
private class SpatialIOFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return (slot == 0 && SpatialIOPortBlockEntity.this.isSpatialCell(stack));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -113,7 +113,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity {
|
||||
private final AppEngInternalInventory inputInventory = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory(this, 1);
|
||||
private final ItemTransferable internalInventory = new WrapperChainedItemHandler(this.inputInventory,
|
||||
private final FixedItemInv internalInventory = new WrapperChainedItemHandler(this.inputInventory,
|
||||
this.cellInventory);
|
||||
|
||||
private final IActionSource mySrc = new MachineSource(this);
|
||||
@@ -425,12 +425,12 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.internalInventory;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (inv == this.cellInventory) {
|
||||
this.cellHandler = null;
|
||||
@@ -456,7 +456,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(@Nonnull Direction side) {
|
||||
protected FixedItemInv getItemHandlerForSide(@Nonnull Direction side) {
|
||||
if (side == this.getForward()) {
|
||||
return this.cellInventory;
|
||||
} else {
|
||||
@@ -785,12 +785,12 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
|
||||
private class InputInventoryFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
if (ChestBlockEntity.this.isPowered()) {
|
||||
ChestBlockEntity.this.updateHandler();
|
||||
return ChestBlockEntity.this.cellHandler != null && ChestBlockEntity.this.cellHandler
|
||||
@@ -803,12 +803,12 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
private static class CellInventoryFilter implements IAEItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return AEApi.instance().registries().cell().getHandler(stack) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -304,12 +304,12 @@ public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestO
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (this.isCached) {
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
@@ -422,12 +422,12 @@ public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestO
|
||||
private class CellValidInventoryFilter implements IAEItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return !stack.isEmpty() && AEApi.instance().registries().cell().isCellHandled(stack);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.IdentityHashMap;
|
||||
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.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -69,7 +69,7 @@ import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
@@ -84,11 +84,11 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
|
||||
private final AppEngInternalInventory inputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS);
|
||||
private final AppEngInternalInventory outputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS);
|
||||
private final ItemTransferable combinedInventory = new WrapperChainedItemHandler(this.inputCells, this.outputCells);
|
||||
private final FixedItemInv combinedInventory = new WrapperChainedItemHandler(this.inputCells, this.outputCells);
|
||||
|
||||
private final ItemTransferable inputCellsExt = new WrapperFilteredItemHandler(this.inputCells,
|
||||
private final FixedItemInv inputCellsExt = new WrapperFilteredItemHandler(this.inputCells,
|
||||
AEItemFilters.INSERT_ONLY);
|
||||
private final ItemTransferable outputCellsExt = new WrapperFilteredItemHandler(this.outputCells,
|
||||
private final FixedItemInv outputCellsExt = new WrapperFilteredItemHandler(this.outputCells,
|
||||
AEItemFilters.EXTRACT_ONLY);
|
||||
|
||||
private final UpgradeInventory upgrades;
|
||||
@@ -186,7 +186,7 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInventoryByName(final String name) {
|
||||
public FixedItemInv getInventoryByName(final String name) {
|
||||
if (name.equals("upgrades")) {
|
||||
return this.upgrades;
|
||||
}
|
||||
@@ -212,12 +212,12 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.combinedInventory;
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
if (this.inputCells == inv) {
|
||||
this.updateTask();
|
||||
@@ -225,7 +225,7 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemTransferable getItemHandlerForSide(final Direction facing) {
|
||||
protected FixedItemInv getItemHandlerForSide(final Direction facing) {
|
||||
if (facing == this.getUp() || facing == this.getUp().getOpposite()) {
|
||||
return this.inputCellsExt;
|
||||
} else {
|
||||
@@ -393,7 +393,7 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
private boolean moveSlot(final int x) {
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler(this.outputCells);
|
||||
final InventoryAdaptor ad = new AdaptorFixedInv(this.outputCells);
|
||||
if (ad.addItems(this.inputCells.getStackInSlot(x)).isEmpty()) {
|
||||
this.inputCells.setStackInSlot(x, ItemStack.EMPTY);
|
||||
return true;
|
||||
|
||||
@@ -30,7 +30,7 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.block.storage.SkyChestBlock;
|
||||
import appeng.tile.AEBaseInvBlockEntity;
|
||||
@@ -77,7 +77,7 @@ public class SkyChestBlockEntity extends AEBaseInvBlockEntity implements ITickab
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTransferable getInternalInventory() {
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ public class SkyChestBlockEntity extends AEBaseInvBlockEntity implements ITickab
|
||||
Block block = getCachedState().getBlock();
|
||||
if (block instanceof SkyChestBlock) {
|
||||
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||
this.world.notifyNeighborsOfStateChange(this.pos, block);
|
||||
this.world.updateNeighborsAlways(this.pos, block);
|
||||
// FIXME: Uhm, we are we doing this?
|
||||
this.world.notifyNeighborsOfStateChange(this.pos.down(), block);
|
||||
this.world.updateNeighborsAlways(this.pos.down(), block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class SkyChestBlockEntity extends AEBaseInvBlockEntity implements ITickab
|
||||
}
|
||||
|
||||
@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 removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user