Merge remote-tracking branch 'origin/mc1.10' into mc1.10
This commit is contained in:
23
src/main/java/refinedstorage/apiimpl/storage/NBTStorage.java
Normal file
23
src/main/java/refinedstorage/apiimpl/storage/NBTStorage.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package refinedstorage.apiimpl.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class NBTStorage {
|
||||
public static void constructFromDrive(ItemStack disk, int slot, ItemStorageNBT[] itemStorages, FluidStorageNBT[] fluidStorages, Function<ItemStack, ItemStorageNBT> itemStorageSupplier, Function<ItemStack, FluidStorageNBT> fluidStorageNBTSupplier) {
|
||||
if (disk == null) {
|
||||
itemStorages[slot] = null;
|
||||
fluidStorages[slot] = null;
|
||||
} else {
|
||||
if (disk.getItem() == RefinedStorageItems.STORAGE_DISK) {
|
||||
itemStorages[slot] = itemStorageSupplier.apply(disk);
|
||||
} else if (disk.getItem() == RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
fluidStorages[slot] = fluidStorageNBTSupplier.apply(disk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,29 @@
|
||||
package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
|
||||
public interface IItemValidator {
|
||||
IItemValidator ITEM_STORAGE_DISK = new ItemValidatorBasic(RefinedStorageItems.STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && ItemStorageNBT.isValid(disk);
|
||||
}
|
||||
};
|
||||
IItemValidator FLUID_STORAGE_DISK = new ItemValidatorBasic(RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && FluidStorageNBT.isValid(disk);
|
||||
}
|
||||
};
|
||||
IItemValidator STORAGE_DISK = new IItemValidator() {
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return ITEM_STORAGE_DISK.isValid(stack) || FLUID_STORAGE_DISK.isValid(stack);
|
||||
}
|
||||
};
|
||||
|
||||
boolean isValid(ItemStack stack);
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@ import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IFluidStorageProvider;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
import refinedstorage.api.storage.item.IItemStorageProvider;
|
||||
import refinedstorage.apiimpl.storage.NBTStorage;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import refinedstorage.block.EnumFluidStorageType;
|
||||
import refinedstorage.block.EnumItemStorageType;
|
||||
import refinedstorage.inventory.IItemValidator;
|
||||
import refinedstorage.inventory.ItemHandlerBasic;
|
||||
import refinedstorage.inventory.ItemHandlerFluid;
|
||||
import refinedstorage.inventory.ItemValidatorBasic;
|
||||
import refinedstorage.tile.config.IComparable;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
import refinedstorage.tile.config.IPrioritizable;
|
||||
@@ -85,34 +86,13 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
||||
private static final String NBT_STORED = "Stored";
|
||||
private static final String NBT_TYPE = "Type";
|
||||
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, new ItemValidatorBasic(RefinedStorageItems.STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && ItemStorageNBT.isValid(disk);
|
||||
}
|
||||
}, new ItemValidatorBasic(RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && FluidStorageNBT.isValid(disk);
|
||||
}
|
||||
}) {
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
ItemStack disk = getStackInSlot(slot);
|
||||
|
||||
if (disk == null) {
|
||||
itemStorages[slot] = null;
|
||||
fluidStorages[slot] = null;
|
||||
} else {
|
||||
if (disk.getItem() == RefinedStorageItems.STORAGE_DISK) {
|
||||
itemStorages[slot] = new ItemStorage(disk);
|
||||
} else if (disk.getItem() == RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
fluidStorages[slot] = new FluidStorage(disk);
|
||||
}
|
||||
}
|
||||
NBTStorage.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
||||
|
||||
if (network != null) {
|
||||
network.getItemStorage().rebuild();
|
||||
|
||||
@@ -11,15 +11,15 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.apiimpl.storage.NBTStorage;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
import refinedstorage.block.EnumFluidStorageType;
|
||||
import refinedstorage.block.EnumItemStorageType;
|
||||
import refinedstorage.inventory.IItemValidator;
|
||||
import refinedstorage.inventory.ItemHandlerBasic;
|
||||
import refinedstorage.inventory.ItemHandlerFluid;
|
||||
import refinedstorage.inventory.ItemValidatorBasic;
|
||||
import refinedstorage.tile.config.IComparable;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
import refinedstorage.tile.config.IType;
|
||||
@@ -68,34 +68,13 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
||||
fluidStorages = new FluidStorage[6];
|
||||
}
|
||||
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(12, this, new ItemValidatorBasic(RefinedStorageItems.STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && ItemStorageNBT.isValid(disk);
|
||||
}
|
||||
}, new ItemValidatorBasic(RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack disk) {
|
||||
return super.isValid(disk) && FluidStorageNBT.isValid(disk);
|
||||
}
|
||||
}) {
|
||||
private ItemHandlerBasic disks = new ItemHandlerBasic(12, this, IItemValidator.STORAGE_DISK) {
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && slot < 6) {
|
||||
ItemStack disk = getStackInSlot(slot);
|
||||
|
||||
if (disk == null) {
|
||||
itemStorages[slot] = null;
|
||||
fluidStorages[slot] = null;
|
||||
} else {
|
||||
if (disk.getItem() == RefinedStorageItems.STORAGE_DISK) {
|
||||
itemStorages[slot] = new ItemStorage(disk);
|
||||
} else if (disk.getItem() == RefinedStorageItems.FLUID_STORAGE_DISK) {
|
||||
fluidStorages[slot] = new FluidStorage(disk);
|
||||
}
|
||||
}
|
||||
NBTStorage.constructFromDrive(getStackInSlot(slot), slot, itemStorages, fluidStorages, s -> new ItemStorage(s), s -> new FluidStorage(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user