Utils ported
This commit is contained in:
@@ -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