API compiles
This commit is contained in:
@@ -20,11 +20,11 @@ package appeng.util;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
@@ -39,9 +39,9 @@ import appeng.util.inv.ItemSlot;
|
||||
* import/export buses.
|
||||
*/
|
||||
public abstract class InventoryAdaptor implements Iterable<ItemSlot> {
|
||||
public static InventoryAdaptor getAdaptor(final TileEntity te, final Direction d) {
|
||||
public static InventoryAdaptor getAdaptor(final BlockEntity te, final Direction d) {
|
||||
if (te != null) {
|
||||
LazyOptional<IItemHandler> cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d);
|
||||
LazyOptional<ItemTransferable> cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d);
|
||||
|
||||
// Attempt getting an IItemHandler for the given side via caps
|
||||
if (cap.isPresent()) {
|
||||
|
||||
@@ -32,9 +32,10 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -45,26 +46,21 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
@@ -255,7 +251,7 @@ public class Platform {
|
||||
|
||||
final ISecurityGrid sg = g.getCache(ISecurityGrid.class);
|
||||
if (!sg.hasPermission(player, requiredPermission)) {
|
||||
player.sendMessage(new TranslationTextComponent("appliedenergistics2.permission_denied")
|
||||
player.sendMessage(new TranslatableText("appliedenergistics2.permission_denied")
|
||||
.applyTextStyle(TextFormatting.RED));
|
||||
// FIXME trace logging?
|
||||
return false;
|
||||
@@ -277,7 +273,7 @@ public class Platform {
|
||||
ServerWorld serverWorld = (ServerWorld) w;
|
||||
|
||||
final BlockState state = w.getBlockState(pos);
|
||||
final TileEntity tileEntity = w.getTileEntity(pos);
|
||||
final BlockEntity tileEntity = w.getTileEntity(pos);
|
||||
|
||||
List<ItemStack> out = Block.getDrops(state, serverWorld, pos, tileEntity);
|
||||
|
||||
@@ -316,8 +312,8 @@ public class Platform {
|
||||
return Math.abs(RANDOM_GENERATOR.nextInt());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static List<ITextComponent> getTooltip(final Object o) {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static List<Text> getTooltip(final Object o) {
|
||||
if (o == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -356,7 +352,7 @@ public class Platform {
|
||||
return "** Null";
|
||||
}
|
||||
|
||||
final ResourceLocation n = ForgeRegistries.FLUIDS.getKey(fs.getFluidStack().getFluid());
|
||||
final Identifier n = ForgeRegistries.FLUIDS.getKey(fs.getFluidStack().getFluid());
|
||||
return n == null ? "** Null" : n.getNamespace();
|
||||
}
|
||||
|
||||
@@ -365,14 +361,14 @@ public class Platform {
|
||||
+ ModList.get().getModContainerById(modId).map(mc -> mc.getModInfo().getDisplayName()).orElse(null);
|
||||
}
|
||||
|
||||
public static ITextComponent getItemDisplayName(final Object o) {
|
||||
public static Text getItemDisplayName(final Object o) {
|
||||
if (o == null) {
|
||||
return new StringTextComponent("** Null");
|
||||
}
|
||||
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
if (o instanceof AEItemStack) {
|
||||
final ITextComponent n = ((AEItemStack) o).getDisplayName();
|
||||
final Text n = ((AEItemStack) o).getDisplayName();
|
||||
return n == null ? new StringTextComponent("** Null") : n;
|
||||
} else if (o instanceof ItemStack) {
|
||||
itemStack = (ItemStack) o;
|
||||
@@ -384,28 +380,28 @@ public class Platform {
|
||||
return itemStack.getDisplayName();
|
||||
} catch (final Exception errA) {
|
||||
try {
|
||||
return new TranslationTextComponent(itemStack.getTranslationKey());
|
||||
return new TranslatableText(itemStack.getTranslationKey());
|
||||
} catch (final Exception errB) {
|
||||
return new StringTextComponent("** Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ITextComponent getFluidDisplayName(Object o) {
|
||||
public static Text getFluidDisplayName(Object o) {
|
||||
if (o == null) {
|
||||
return new StringTextComponent("** Null");
|
||||
}
|
||||
FluidStack fluidStack = null;
|
||||
FluidVolume fluidStack = null;
|
||||
if (o instanceof AEFluidStack) {
|
||||
fluidStack = ((AEFluidStack) o).getFluidStack();
|
||||
} else if (o instanceof FluidStack) {
|
||||
fluidStack = (FluidStack) o;
|
||||
} else if (o instanceof FluidVolume) {
|
||||
fluidStack = (FluidVolume) o;
|
||||
} else {
|
||||
return new StringTextComponent("**Invalid Object");
|
||||
}
|
||||
ITextComponent n = fluidStack.getDisplayName();
|
||||
Text n = fluidStack.getDisplayName();
|
||||
if (n == null) {
|
||||
n = new TranslationTextComponent(fluidStack.getTranslationKey());
|
||||
n = new TranslatableText(fluidStack.getTranslationKey());
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -694,7 +690,7 @@ public class Platform {
|
||||
return new LookDirection(from, to);
|
||||
}
|
||||
|
||||
public static RayTraceResult rayTrace(final PlayerEntity p, final boolean hitBlocks, final boolean hitEntities) {
|
||||
public static HitResult rayTrace(final PlayerEntity p, final boolean hitBlocks, final boolean hitEntities) {
|
||||
final World w = p.getEntityWorld();
|
||||
|
||||
final float f = 1.0F;
|
||||
@@ -714,7 +710,7 @@ public class Platform {
|
||||
|
||||
final Vec3d vec31 = vec3.add(f7 * d3, f6 * d3, f8 * d3);
|
||||
|
||||
final AxisAlignedBB bb = new AxisAlignedBB(Math.min(vec3.x, vec31.x), Math.min(vec3.y, vec31.y),
|
||||
final Box bb = new Box(Math.min(vec3.x, vec31.x), Math.min(vec3.y, vec31.y),
|
||||
Math.min(vec3.z, vec31.z), Math.max(vec3.x, vec31.x), Math.max(vec3.y, vec31.y),
|
||||
Math.max(vec3.z, vec31.z)).grow(16, 16, 16);
|
||||
|
||||
@@ -732,7 +728,7 @@ public class Platform {
|
||||
|
||||
f1 = 0.3F;
|
||||
// FIXME: Three different bounding boxes available, should double-check
|
||||
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Box boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Vec3d rtResult = boundingBox.rayTrace(vec3, vec31).orElse(null);
|
||||
|
||||
if (rtResult != null) {
|
||||
@@ -747,7 +743,7 @@ public class Platform {
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceResult pos = null;
|
||||
HitResult pos = null;
|
||||
Vec3d vec = null;
|
||||
|
||||
if (hitBlocks) {
|
||||
@@ -984,7 +980,7 @@ public class Platform {
|
||||
return gs.hasPermission(playerID, SecurityPermissions.BUILD);
|
||||
}
|
||||
|
||||
public static void configurePlayer(final PlayerEntity player, final AEPartLocation side, final TileEntity tile) {
|
||||
public static void configurePlayer(final PlayerEntity player, final AEPartLocation side, final BlockEntity tile) {
|
||||
float pitch = 0.0f;
|
||||
float yaw = 0.0f;
|
||||
// player.yOffset = 1.8f;
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
|
||||
package appeng.util.helpers;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
public class ItemHandlerUtil {
|
||||
private ItemHandlerUtil() {
|
||||
}
|
||||
|
||||
public static void setStackInSlot(final IItemHandler inv, final int slot, final ItemStack stack) {
|
||||
public static void setStackInSlot(final ItemTransferable inv, final int slot, final ItemStack stack) {
|
||||
if (inv instanceof IItemHandlerModifiable) {
|
||||
((IItemHandlerModifiable) inv).setStackInSlot(slot, stack);
|
||||
} else {
|
||||
@@ -36,13 +36,13 @@ public class ItemHandlerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear(final IItemHandler inv) {
|
||||
public static void clear(final ItemTransferable inv) {
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
setStackInSlot(inv, x, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEmpty(final IItemHandler inv) {
|
||||
public static boolean isEmpty(final ItemTransferable inv) {
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
if (!inv.getStackInSlot(x).isEmpty()) {
|
||||
return false;
|
||||
@@ -51,13 +51,13 @@ public class ItemHandlerUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void copy(final IItemHandler from, final IItemHandler to, boolean deepCopy) {
|
||||
public static void copy(final ItemTransferable from, final ItemTransferable to, boolean deepCopy) {
|
||||
for (int i = 0; i < Math.min(from.getSlots(), to.getSlots()); ++i) {
|
||||
setStackInSlot(to, i, deepCopy ? from.getStackInSlot(i).copy() : from.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(final CraftingInventory from, final IItemHandler to, boolean deepCopy) {
|
||||
public static void copy(final CraftingInventory from, final ItemTransferable to, boolean deepCopy) {
|
||||
for (int i = 0; i < Math.min(from.getSizeInventory(), to.getSlots()); ++i) {
|
||||
setStackInSlot(to, i, deepCopy ? from.getStackInSlot(i).copy() : from.getStackInSlot(i));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import java.util.Objects;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.text.Text;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -48,10 +48,10 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
|
||||
private final AESharedItemStack sharedStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private ITextComponent displayName;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private List<ITextComponent> tooltip;
|
||||
@Environment(EnvType.CLIENT)
|
||||
private Text displayName;
|
||||
@Environment(EnvType.CLIENT)
|
||||
private List<Text> tooltip;
|
||||
|
||||
private AEItemStack(final AEItemStack is) {
|
||||
this.setStackSize(is.getStackSize());
|
||||
@@ -104,7 +104,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
i.putBoolean(NBT_CRAFTABLE, this.isCraftable());
|
||||
}
|
||||
|
||||
public static AEItemStack fromPacket(final PacketBuffer buffer) {
|
||||
public static AEItemStack fromPacket(final PacketByteBuf buffer) {
|
||||
final boolean isCraftable = buffer.readBoolean();
|
||||
final long stackSize = buffer.readVarLong();
|
||||
final long countRequestable = buffer.readVarLong();
|
||||
@@ -121,7 +121,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket(final PacketBuffer buffer) {
|
||||
public void writeToPacket(final PacketByteBuf buffer) {
|
||||
buffer.writeBoolean(this.isCraftable());
|
||||
buffer.writeVarLong(this.getStackSize());
|
||||
buffer.writeVarLong(this.getCountRequestable());
|
||||
@@ -226,23 +226,23 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName();
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public List<ITextComponent> getToolTip() {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public List<Text> getToolTip() {
|
||||
if (this.tooltip == null) {
|
||||
this.tooltip = Platform.getTooltip(this.asItemStackRepresentation());
|
||||
}
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public ITextComponent getDisplayName() {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public Text getDisplayName() {
|
||||
if (this.displayName == null) {
|
||||
this.displayName = Platform.getItemDisplayName(this.asItemStackRepresentation());
|
||||
}
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public String getModID() {
|
||||
return this.getDefinition().getItem().getRegistryName().getNamespace();
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ package appeng.util.iterators;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public final class InvIterator implements Iterator<ItemStack> {
|
||||
private final IItemHandler inventory;
|
||||
private final ItemTransferable inventory;
|
||||
private final int size;
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
public InvIterator(final IItemHandler inventory) {
|
||||
public InvIterator(final ItemTransferable inventory) {
|
||||
this.inventory = inventory;
|
||||
this.size = this.inventory.getSlots();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user