Fix more bugs
This commit is contained in:
@@ -43,11 +43,19 @@ import java.math.RoundingMode;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public final class RSUtils {
|
public final class RSUtils {
|
||||||
|
private static final NonNullList EMPTY_NON_NULL_LIST = new NonNullList<Object>(Collections.emptyList(), null) {
|
||||||
|
};
|
||||||
|
|
||||||
|
public static <T> NonNullList<T> emptyNonNullList() {
|
||||||
|
return (NonNullList<T>) EMPTY_NON_NULL_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
||||||
|
|
||||||
public static final DecimalFormat QUANTITY_FORMATTER = new DecimalFormat("####0.#", DecimalFormatSymbols.getInstance(Locale.US));
|
public static final DecimalFormat QUANTITY_FORMATTER = new DecimalFormat("####0.#", DecimalFormatSymbols.getInstance(Locale.US));
|
||||||
@@ -266,7 +274,7 @@ public final class RSUtils {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FluidStack copyStack(FluidStack stack) {
|
public static FluidStack copyStack(@Nullable FluidStack stack) {
|
||||||
return stack == null ? null : stack.copy();
|
return stack == null ? null : stack.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ public interface INetworkItemHandler {
|
|||||||
* @param player the player that opened the network item
|
* @param player the player that opened the network item
|
||||||
* @param controllerWorld the world of the controller
|
* @param controllerWorld the world of the controller
|
||||||
* @param hand the hand the player opened it with
|
* @param hand the hand the player opened it with
|
||||||
* @return true if the opening was successful, false otherwise
|
|
||||||
*/
|
*/
|
||||||
boolean onOpen(EntityPlayer player, World controllerWorld, EnumHand hand);
|
void onOpen(EntityPlayer player, World controllerWorld, EnumHand hand);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player closes a network item.
|
* Called when the player closes a network item.
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.raoulvdberge.refinedstorage.api.storage;
|
package com.raoulvdberge.refinedstorage.api.storage;
|
||||||
|
|
||||||
import java.util.List;
|
import net.minecraft.util.NonNullList;
|
||||||
|
|
||||||
public interface IStorage<T> {
|
public interface IStorage<T> {
|
||||||
/**
|
/**
|
||||||
* @return stacks stored in this storage
|
* @return stacks stored in this storage
|
||||||
*/
|
*/
|
||||||
List<T> getStacks();
|
NonNullList<T> getStacks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the amount of fluids stored in this storage
|
* @return the amount of fluids stored in this storage
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemProvider;
|
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemProvider;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -32,7 +32,7 @@ public class NetworkItemHandler implements INetworkItemHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOpen(EntityPlayer player, World controllerWorld, EnumHand hand) {
|
public void onOpen(EntityPlayer player, World controllerWorld, EnumHand hand) {
|
||||||
boolean inRange = false;
|
boolean inRange = false;
|
||||||
|
|
||||||
for (INetworkNode node : network.getNodeGraph().all()) {
|
for (INetworkNode node : network.getNodeGraph().all()) {
|
||||||
@@ -50,20 +50,16 @@ public class NetworkItemHandler implements INetworkItemHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!inRange) {
|
if (!inRange) {
|
||||||
return false;
|
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.out_of_range"));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
INetworkItem item = ((INetworkItemProvider) player.getHeldItem(hand).getItem()).provide(this, player, player.getHeldItem(hand));
|
||||||
|
|
||||||
INetworkItem item = ((INetworkItemProvider) stack.getItem()).provide(this, player, stack);
|
|
||||||
|
|
||||||
if (item.onOpen(network, player, controllerWorld, hand)) {
|
if (item.onOpen(network, player, controllerWorld, hand)) {
|
||||||
items.add(item);
|
items.add(item);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A implementation of {@link IFluidStorage} that stores storage fluids in NBT.
|
* A implementation of {@link IFluidStorage} that stores storage fluids in NBT.
|
||||||
@@ -32,7 +31,7 @@ public abstract class FluidStorageNBT implements IFluidStorage {
|
|||||||
private int capacity;
|
private int capacity;
|
||||||
private TileEntity tile;
|
private TileEntity tile;
|
||||||
|
|
||||||
private List<FluidStack> stacks = new ArrayList<>();
|
private NonNullList<FluidStack> stacks = NonNullList.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link FluidStorageNBT#createNBT()} if it doesn't exist yet
|
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link FluidStorageNBT#createNBT()} if it doesn't exist yet
|
||||||
@@ -74,7 +73,7 @@ public abstract class FluidStorageNBT implements IFluidStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FluidStack> getStacks() {
|
public NonNullList<FluidStack> getStacks() {
|
||||||
return stacks;
|
return stacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,11 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A implementation of {@link IItemStorage} that stores storage items in NBT.
|
* A implementation of {@link IItemStorage} that stores storage items in NBT.
|
||||||
@@ -39,7 +38,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
|||||||
private int capacity;
|
private int capacity;
|
||||||
private TileEntity tile;
|
private TileEntity tile;
|
||||||
|
|
||||||
private List<ItemStack> stacks = new ArrayList<>();
|
private NonNullList<ItemStack> stacks = NonNullList.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link ItemStorageNBT#createNBT()} if it doesn't exist yet
|
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link ItemStorageNBT#createNBT()} if it doesn't exist yet
|
||||||
@@ -111,7 +110,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getStacks() {
|
public NonNullList<ItemStack> getStacks() {
|
||||||
return stacks;
|
return stacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class NetworkItemEnergyForge extends EnergyStorage {
|
|||||||
super(capacity, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
super(capacity, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
|
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
|
this.energy = stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_ENERGY) ? stack.getTagCompound().getInteger(NBT_ENERGY) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -51,19 +51,19 @@ public abstract class ItemNetworkItem extends ItemBase implements INetworkItemPr
|
|||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
|
||||||
if (!world.isRemote && isValid(stack)) {
|
if (!world.isRemote) {
|
||||||
World controllerWorld = DimensionManager.getWorld(getDimensionId(stack));
|
if (!isValid(stack)) {
|
||||||
|
|
||||||
TileEntity controller;
|
|
||||||
|
|
||||||
if (controllerWorld != null && ((controller = controllerWorld.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)))) instanceof TileController)) {
|
|
||||||
if (((TileController) controller).getNetworkItemHandler().onOpen(player, controllerWorld, hand)) {
|
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.out_of_range"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.not_found"));
|
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.not_found"));
|
||||||
|
} else {
|
||||||
|
World controllerWorld = DimensionManager.getWorld(getDimensionId(stack));
|
||||||
|
|
||||||
|
TileEntity controller;
|
||||||
|
|
||||||
|
if (controllerWorld != null && ((controller = controllerWorld.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)))) instanceof TileController)) {
|
||||||
|
((TileController) controller).getNetworkItemHandler().onOpen(player, controllerWorld, hand);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.not_found"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import com.raoulvdberge.refinedstorage.api.storage.fluid.IFluidStorage;
|
|||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FluidStorageExternal implements IFluidStorage {
|
public class FluidStorageExternal implements IFluidStorage {
|
||||||
private FluidStack cache;
|
private FluidStack cache;
|
||||||
@@ -35,8 +34,8 @@ public class FluidStorageExternal implements IFluidStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FluidStack> getStacks() {
|
public NonNullList<FluidStack> getStacks() {
|
||||||
return getContents() == null ? Collections.emptyList() : Collections.singletonList(getContents().copy());
|
return getContents() == null ? RSUtils.emptyNonNullList() : NonNullList.withSize(1, getContents().copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemStorageDSU extends ItemStorageExternal {
|
public class ItemStorageDSU extends ItemStorageExternal {
|
||||||
private TileExternalStorage externalStorage;
|
private TileExternalStorage externalStorage;
|
||||||
@@ -26,12 +26,12 @@ public class ItemStorageDSU extends ItemStorageExternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getStacks() {
|
public NonNullList<ItemStack> getStacks() {
|
||||||
if (unit.getStoredItemType() != null && unit.getStoredItemType().getCount() > 0) {
|
if (unit.getStoredItemType() != null && unit.getStoredItemType().getCount() > 0) {
|
||||||
return Collections.singletonList(unit.getStoredItemType().copy());
|
return NonNullList.withSize(1, unit.getStoredItemType().copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return RSUtils.emptyNonNullList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
|||||||
|
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemStorageDrawer extends ItemStorageExternal {
|
public class ItemStorageDrawer extends ItemStorageExternal {
|
||||||
private TileExternalStorage externalStorage;
|
private TileExternalStorage externalStorage;
|
||||||
private IDrawer drawer;
|
private IDrawer drawer;
|
||||||
@@ -26,7 +25,7 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getStacks() {
|
public NonNullList<ItemStack> getStacks() {
|
||||||
return getStacks(drawer);
|
return getStacks(drawer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,12 +54,12 @@ public class ItemStorageDrawer extends ItemStorageExternal {
|
|||||||
return externalStorage.getAccessType();
|
return externalStorage.getAccessType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getStacks(IDrawer drawer) {
|
public static NonNullList<ItemStack> getStacks(IDrawer drawer) {
|
||||||
if (!drawer.isEmpty() && drawer.getStoredItemCount() > 0) {
|
if (!drawer.isEmpty() && drawer.getStoredItemCount() > 0) {
|
||||||
return Collections.singletonList(drawer.getStoredItemCopy());
|
return NonNullList.withSize(1, drawer.getStoredItemCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return RSUtils.emptyNonNullList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack insertItem(TileExternalStorage externalStorage, IDrawer drawer, ItemStack stack, int size, boolean simulate) {
|
public static ItemStack insertItem(TileExternalStorage externalStorage, IDrawer drawer, ItemStack stack, int size, boolean simulate) {
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
|||||||
|
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemStorageDrawerGroup extends ItemStorageExternal {
|
public class ItemStorageDrawerGroup extends ItemStorageExternal {
|
||||||
private TileExternalStorage externalStorage;
|
private TileExternalStorage externalStorage;
|
||||||
@@ -18,8 +17,8 @@ public class ItemStorageDrawerGroup extends ItemStorageExternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getStacks() {
|
public NonNullList<ItemStack> getStacks() {
|
||||||
List<ItemStack> stacks = new ArrayList<>();
|
NonNullList<ItemStack> stacks = NonNullList.create();
|
||||||
|
|
||||||
for (int i = 0; i < drawers.getDrawerCount(); ++i) {
|
for (int i = 0; i < drawers.getDrawerCount(); ++i) {
|
||||||
if (drawers.isDrawerEnabled(i)) {
|
if (drawers.isDrawerEnabled(i)) {
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public abstract class ItemStorageExternal implements IItemStorage {
|
|||||||
|
|
||||||
ItemStack cached = cache.get(i);
|
ItemStack cached = cache.get(i);
|
||||||
|
|
||||||
if (cached != ItemStack.EMPTY && actual == ItemStack.EMPTY) {
|
if (!cached.isEmpty() && actual.isEmpty()) {
|
||||||
// If the cached is not empty but the actual is, we remove this item
|
// If the cached is not empty but the actual is, we remove this item
|
||||||
network.getItemStorageCache().remove(cached, cached.getCount());
|
network.getItemStorageCache().remove(cached, cached.getCount());
|
||||||
} else if (cached == ItemStack.EMPTY && actual != ItemStack.EMPTY) {
|
} else if (cached.isEmpty() && !actual.isEmpty()) {
|
||||||
// If the cached is empty and the actual isn't, we added this item
|
// If the cached is empty and the actual isn't, we added this item
|
||||||
network.getItemStorageCache().add(actual, actual.getCount(), false);
|
network.getItemStorageCache().add(actual, actual.getCount(), false);
|
||||||
} else if (cached == ItemStack.EMPTY && actual == ItemStack.EMPTY) {
|
} else if (cached.isEmpty() && actual.isEmpty()) {
|
||||||
// If they're both empty, nothing happens
|
// If they're both empty, nothing happens
|
||||||
} else if (!API.instance().getComparer().isEqualNoQuantity(cached, actual)) {
|
} else if (!API.instance().getComparer().isEqualNoQuantity(cached, actual)) {
|
||||||
// If both items mismatch, remove the old and add the new
|
// If both items mismatch, remove the old and add the new
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemStorageItemHandler extends ItemStorageExternal {
|
public class ItemStorageItemHandler extends ItemStorageExternal {
|
||||||
private TileExternalStorage externalStorage;
|
private TileExternalStorage externalStorage;
|
||||||
@@ -31,14 +30,14 @@ public class ItemStorageItemHandler extends ItemStorageExternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getStacks() {
|
public NonNullList<ItemStack> getStacks() {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
NonNullList<ItemStack> stacks = NonNullList.withSize(handler.getSlots(), ItemStack.EMPTY);
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
items.add(!handler.getStackInSlot(i).isEmpty() ? handler.getStackInSlot(i).copy() : null);
|
stacks.set(i, handler.getStackInSlot(i).copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return stacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user