API compiles

This commit is contained in:
Sebastian Hartte
2020-06-27 18:09:44 +02:00
parent ba71a82288
commit 80fbb58d4f
572 changed files with 2995 additions and 3037 deletions
@@ -21,16 +21,16 @@ package appeng.util.inv;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import appeng.api.config.FuzzyMode;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
public class AdaptorItemHandler extends InventoryAdaptor {
protected final IItemHandler itemHandler;
protected final ItemTransferable itemHandler;
public AdaptorItemHandler(IItemHandler itemHandler) {
public AdaptorItemHandler(ItemTransferable itemHandler) {
this.itemHandler = itemHandler;
}
@@ -18,11 +18,11 @@
package appeng.util.inv;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public interface IAEAppEngInventory {
void saveChanges();
void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
void onChangeInventory(ItemTransferable inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
}
@@ -21,17 +21,17 @@ package appeng.util.inv;
import java.util.Iterator;
import java.util.NoSuchElementException;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.ItemTransferable;
class ItemHandlerIterator implements Iterator<ItemSlot> {
private final IItemHandler itemHandler;
private final ItemTransferable itemHandler;
private final ItemSlot itemSlot = new ItemSlot();
private int slot = 0;
ItemHandlerIterator(IItemHandler itemHandler) {
ItemHandlerIterator(ItemTransferable itemHandler) {
this.itemHandler = itemHandler;
}
@@ -22,23 +22,23 @@ import java.util.ArrayList;
import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.util.helpers.ItemHandlerUtil;
public class WrapperChainedItemHandler implements IItemHandlerModifiable {
private IItemHandler[] itemHandler; // the handlers
private ItemTransferable[] itemHandler; // the handlers
private int[] baseIndex; // index-offsets of the different handlers
private int slotCount; // number of total slots
public WrapperChainedItemHandler(IItemHandler... itemHandler) {
public WrapperChainedItemHandler(ItemTransferable... itemHandler) {
this.setItemHandlers(itemHandler);
}
private void setItemHandlers(IItemHandler[] handlers) {
private void setItemHandlers(ItemTransferable[] handlers) {
this.itemHandler = handlers;
this.baseIndex = new int[this.itemHandler.length];
int index = 0;
@@ -63,7 +63,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
return -1;
}
private IItemHandler getHandlerFromIndex(int index) {
private ItemTransferable getHandlerFromIndex(int index) {
if (index < 0 || index >= this.itemHandler.length) {
return EmptyHandler.INSTANCE;
}
@@ -79,12 +79,12 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
public void cycleOrder() {
if (this.itemHandler.length > 1) {
ArrayList<IItemHandler> newOrder = new ArrayList<>();
ArrayList<ItemTransferable> newOrder = new ArrayList<>();
newOrder.add(this.itemHandler[this.itemHandler.length - 1]);
for (int i = 0; i < this.itemHandler.length - 1; ++i) {
newOrder.add(this.itemHandler[i]);
}
this.setItemHandlers(newOrder.toArray(new IItemHandler[this.itemHandler.length]));
this.setItemHandlers(newOrder.toArray(new ItemTransferable[this.itemHandler.length]));
}
}
@@ -97,7 +97,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Nonnull
public ItemStack getStackInSlot(final int slot) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int targetSlot = this.getSlotFromIndex(slot, index);
return handler.getStackInSlot(targetSlot);
}
@@ -106,7 +106,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Nonnull
public ItemStack insertItem(final int slot, @Nonnull ItemStack stack, boolean simulate) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int targetSlot = this.getSlotFromIndex(slot, index);
return handler.insertItem(targetSlot, stack, simulate);
}
@@ -115,7 +115,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int targetSlot = this.getSlotFromIndex(slot, index);
return handler.extractItem(targetSlot, amount, simulate);
}
@@ -123,7 +123,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Override
public int getSlotLimit(int slot) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int localSlot = this.getSlotFromIndex(slot, index);
return handler.getSlotLimit(localSlot);
}
@@ -131,7 +131,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Override
public void setStackInSlot(int slot, ItemStack stack) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int targetSlot = this.getSlotFromIndex(slot, index);
ItemHandlerUtil.setStackInSlot(handler, targetSlot, stack);
}
@@ -139,7 +139,7 @@ public class WrapperChainedItemHandler implements IItemHandlerModifiable {
@Override
public boolean isItemValid(int slot, ItemStack stack) {
int index = this.getIndexForSlot(slot);
IItemHandler handler = this.getHandlerFromIndex(index);
ItemTransferable handler = this.getHandlerFromIndex(index);
int targetSlot = this.getSlotFromIndex(slot, index);
return handler.isItemValid(targetSlot, stack);
}
@@ -21,17 +21,17 @@ package appeng.util.inv;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.filter.IAEItemFilter;
public class WrapperFilteredItemHandler implements IItemHandlerModifiable {
private final IItemHandler handler;
private final ItemTransferable handler;
private final IAEItemFilter filter;
public WrapperFilteredItemHandler(@Nonnull IItemHandler handler, @Nonnull IAEItemFilter filter) {
public WrapperFilteredItemHandler(@Nonnull ItemTransferable handler, @Nonnull IAEItemFilter filter) {
this.handler = handler;
this.filter = filter;
}
@@ -21,14 +21,14 @@ package appeng.util.inv;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import appeng.util.helpers.ItemHandlerUtil;
public class WrapperInvItemHandler implements IInventory {
private final IItemHandler inv;
private final ItemTransferable inv;
public WrapperInvItemHandler(final IItemHandler inv) {
public WrapperInvItemHandler(final ItemTransferable inv) {
this.inv = inv;
}
@@ -20,18 +20,18 @@ package appeng.util.inv;
import javax.annotation.Nonnull;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.helpers.ItemHandlerUtil;
public class WrapperRangeItemHandler implements IItemHandlerModifiable {
private final IItemHandler compose;
private final ItemTransferable compose;
private final int minSlot;
private final int maxSlot;
public WrapperRangeItemHandler(IItemHandler compose, int minSlot, int maxSlotExclusive) {
public WrapperRangeItemHandler(ItemTransferable compose, int minSlot, int maxSlotExclusive) {
this.compose = compose;
this.minSlot = minSlot;
this.maxSlot = maxSlotExclusive;
@@ -21,15 +21,15 @@ package appeng.util.inv;
import java.util.function.Supplier;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.helpers.ItemHandlerUtil;
public class WrapperSupplierItemHandler implements IItemHandlerModifiable {
private final Supplier<IItemHandler> sourceHandler;
private final Supplier<ItemTransferable> sourceHandler;
public WrapperSupplierItemHandler(Supplier<IItemHandler> source) {
public WrapperSupplierItemHandler(Supplier<ItemTransferable> source) {
this.sourceHandler = source;
}
@@ -18,8 +18,8 @@
package appeng.util.inv.filter;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.definitions.IItemDefinition;
@@ -31,12 +31,12 @@ public class AEItemDefinitionFilter implements IAEItemFilter {
}
@Override
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
return true;
}
@Override
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
return this.definition.isSameAs(stack);
}
@@ -18,8 +18,8 @@
package appeng.util.inv.filter;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class AEItemFilters {
public static final IAEItemFilter INSERT_ONLY = new InsertOnlyFilter();
@@ -30,24 +30,24 @@ public class AEItemFilters {
private static class InsertOnlyFilter implements IAEItemFilter {
@Override
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
return false;
}
@Override
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
return true;
}
}
private static class ExtractOnlyFilter implements IAEItemFilter {
@Override
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
public boolean allowExtract(ItemTransferable inv, int slot, int amount) {
return true;
}
@Override
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
public boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack) {
return false;
}
}
@@ -18,11 +18,11 @@
package appeng.util.inv.filter;
import alexiil.mc.lib.attributes.item.ItemTransferable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public interface IAEItemFilter {
boolean allowExtract(IItemHandler inv, int slot, int amount);
boolean allowExtract(ItemTransferable inv, int slot, int amount);
boolean allowInsert(IItemHandler inv, int slot, ItemStack stack);
boolean allowInsert(ItemTransferable inv, int slot, ItemStack stack);
}