1.5 -> 1.6 migration: item and fluid storage blocks. #1816
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# Refined Storage Changelog
|
# Refined Storage Changelog
|
||||||
|
|
||||||
### 1.6
|
### 1.6
|
||||||
|
NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined Storage 1.6.x and are getting converted upon loading the world. It is however not possible to revert back to Refined Storage 1.5.x when a world has already been converted to Refined Storage 1.6.x.
|
||||||
|
|
||||||
- Removed Regulator mode in the Exporter (raoulvdberge)
|
- Removed Regulator mode in the Exporter (raoulvdberge)
|
||||||
- Removed MCMultiPart integration (raoulvdberge)
|
- Removed MCMultiPart integration (raoulvdberge)
|
||||||
- Removed Project E integration (raoulvdberge)
|
- Removed Project E integration (raoulvdberge)
|
||||||
|
@@ -77,10 +77,8 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||||
if (storage != null) {
|
|
||||||
storages.add(storage);
|
storages.add(storage);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -91,9 +89,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
|||||||
public NBTTagCompound write(NBTTagCompound tag) {
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
super.write(tag);
|
super.write(tag);
|
||||||
|
|
||||||
if (storageId != null) {
|
|
||||||
tag.setUniqueId(NBT_ID, storageId);
|
tag.setUniqueId(NBT_ID, storageId);
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -107,6 +103,8 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
|||||||
|
|
||||||
loadStorage();
|
loadStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OneSixMigrationHelper.migrateFluidStorageBlock(this, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadStorage() {
|
public void loadStorage() {
|
||||||
|
@@ -72,10 +72,8 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||||
if (storage != null) {
|
|
||||||
storages.add(storage);
|
storages.add(storage);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||||
@@ -91,9 +89,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
|||||||
public NBTTagCompound write(NBTTagCompound tag) {
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
super.write(tag);
|
super.write(tag);
|
||||||
|
|
||||||
if (storageId != null) {
|
|
||||||
tag.setUniqueId(NBT_ID, storageId);
|
tag.setUniqueId(NBT_ID, storageId);
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -107,6 +103,8 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
|||||||
|
|
||||||
loadStorage();
|
loadStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OneSixMigrationHelper.migrateItemStorageBlock(this, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadStorage() {
|
public void loadStorage() {
|
||||||
|
@@ -5,6 +5,10 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
|||||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IOneSixMigrationHelper;
|
import com.raoulvdberge.refinedstorage.api.util.IOneSixMigrationHelper;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
||||||
|
import com.raoulvdberge.refinedstorage.block.FluidStorageType;
|
||||||
|
import com.raoulvdberge.refinedstorage.block.ItemStorageType;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@@ -31,18 +35,12 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
|
|
||||||
private static final String NBT_FLUIDS = "Fluids";
|
private static final String NBT_FLUIDS = "Fluids";
|
||||||
|
|
||||||
@Override
|
private static UUID createItemDisk(World world, int capacity, NBTTagCompound legacyTag) {
|
||||||
public boolean migrateDisk(World world, ItemStack disk) {
|
|
||||||
IStorageDiskProvider provider = (IStorageDiskProvider) disk.getItem();
|
|
||||||
|
|
||||||
switch (provider.getType()) {
|
|
||||||
case ITEM:
|
|
||||||
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_ITEMS)) {
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
IStorageDisk<ItemStack> newDisk = API.instance().createDefaultItemDisk(world, provider.getCapacity(disk));
|
IStorageDisk<ItemStack> newDisk = API.instance().createDefaultItemDisk(world, capacity);
|
||||||
|
|
||||||
NBTTagList list = (NBTTagList) disk.getTagCompound().getTag(NBT_ITEMS);
|
NBTTagList list = (NBTTagList) legacyTag.getTag(NBT_ITEMS);
|
||||||
|
|
||||||
for (int i = 0; i < list.tagCount(); ++i) {
|
for (int i = 0; i < list.tagCount(); ++i) {
|
||||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||||
@@ -64,19 +62,15 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
||||||
API.instance().getStorageDiskManager(world).markForSaving();
|
API.instance().getStorageDiskManager(world).markForSaving();
|
||||||
|
|
||||||
provider.setId(disk, id);
|
return id;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
private static UUID createFluidDisk(World world, int capacity, NBTTagCompound legacyTag) {
|
||||||
case FLUID:
|
|
||||||
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_FLUIDS)) {
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
IStorageDisk<FluidStack> newDisk = API.instance().createDefaultFluidDisk(world, provider.getCapacity(disk));
|
IStorageDisk<FluidStack> newDisk = API.instance().createDefaultFluidDisk(world, capacity);
|
||||||
|
|
||||||
NBTTagList list = (NBTTagList) disk.getTagCompound().getTag(NBT_FLUIDS);
|
NBTTagList list = (NBTTagList) legacyTag.getTag(NBT_FLUIDS);
|
||||||
|
|
||||||
for (int i = 0; i < list.tagCount(); ++i) {
|
for (int i = 0; i < list.tagCount(); ++i) {
|
||||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
||||||
@@ -89,7 +83,25 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
||||||
API.instance().getStorageDiskManager(world).markForSaving();
|
API.instance().getStorageDiskManager(world).markForSaving();
|
||||||
|
|
||||||
provider.setId(disk, id);
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean migrateDisk(World world, ItemStack disk) {
|
||||||
|
IStorageDiskProvider provider = (IStorageDiskProvider) disk.getItem();
|
||||||
|
|
||||||
|
switch (provider.getType()) {
|
||||||
|
case ITEM:
|
||||||
|
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_ITEMS)) {
|
||||||
|
provider.setId(disk, createItemDisk(world, provider.getCapacity(disk), disk.getTagCompound()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case FLUID:
|
||||||
|
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_FLUIDS)) {
|
||||||
|
provider.setId(disk, createFluidDisk(world, provider.getCapacity(disk), disk.getTagCompound()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -197,4 +209,42 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
filterable.setMode(IFilter.MODE_BLACKLIST);
|
filterable.setMode(IFilter.MODE_BLACKLIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String NBT_STORAGE = "Storage";
|
||||||
|
|
||||||
|
public static void migrateItemStorageBlock(NetworkNodeStorage storage, NBTTagCompound tag) {
|
||||||
|
if (tag.hasKey(NBT_STORAGE)) {
|
||||||
|
NBTTagCompound storageTag = tag.getCompoundTag(NBT_STORAGE);
|
||||||
|
|
||||||
|
storage.setStorageId(createItemDisk(storage.getWorld(), storage.getType().getCapacity(), storageTag));
|
||||||
|
storage.loadStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void migrateItemStorageBlockItem(World world, ItemStack stack) {
|
||||||
|
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_STORAGE)) {
|
||||||
|
NBTTagCompound storageTag = stack.getTagCompound().getCompoundTag(NBT_STORAGE);
|
||||||
|
|
||||||
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
stack.getTagCompound().setUniqueId(NetworkNodeStorage.NBT_ID, createItemDisk(world, ItemStorageType.getById(stack.getItemDamage()).getCapacity(), storageTag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void migrateFluidStorageBlock(NetworkNodeFluidStorage storage, NBTTagCompound tag) {
|
||||||
|
if (tag.hasKey(NBT_STORAGE)) {
|
||||||
|
NBTTagCompound storageTag = tag.getCompoundTag(NBT_STORAGE);
|
||||||
|
|
||||||
|
storage.setStorageId(createFluidDisk(storage.getWorld(), storage.getType().getCapacity(), storageTag));
|
||||||
|
storage.loadStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void migrateFluidStorageBlockItem(World world, ItemStack stack) {
|
||||||
|
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_STORAGE)) {
|
||||||
|
NBTTagCompound storageTag = stack.getTagCompound().getCompoundTag(NBT_STORAGE);
|
||||||
|
|
||||||
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
stack.getTagCompound().setUniqueId(NetworkNodeStorage.NBT_ID, createFluidDisk(world, FluidStorageType.getById(stack.getItemDamage()).getCapacity(), storageTag));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -99,6 +99,7 @@ public class BlockCable extends BlockNode {
|
|||||||
return getActualState(stateForRendering, world, pos);
|
return getActualState(stateForRendering, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate connection issue
|
||||||
public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos, BlockBase block, TileEntity tile, EnumFacing direction) {
|
public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos, BlockBase block, TileEntity tile, EnumFacing direction) {
|
||||||
if (!(tile instanceof TileNode)) {
|
if (!(tile instanceof TileNode)) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -6,8 +6,10 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -100,4 +102,13 @@ public class ItemBlockFluidStorage extends ItemBlockBase {
|
|||||||
private boolean isValid(ItemStack disk) {
|
private boolean isValid(ItemStack disk) {
|
||||||
return disk.hasTagCompound() && disk.getTagCompound().hasUniqueId(NetworkNodeFluidStorage.NBT_ID);
|
return disk.hasTagCompound() && disk.getTagCompound().hasUniqueId(NetworkNodeFluidStorage.NBT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
|
super.onUpdate(stack, world, entity, itemSlot, isSelected);
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
|
OneSixMigrationHelper.migrateFluidStorageBlockItem(world, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,10 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -100,4 +102,13 @@ public class ItemBlockStorage extends ItemBlockBase {
|
|||||||
private boolean isValid(ItemStack disk) {
|
private boolean isValid(ItemStack disk) {
|
||||||
return disk.hasTagCompound() && disk.getTagCompound().hasUniqueId(NetworkNodeStorage.NBT_ID);
|
return disk.hasTagCompound() && disk.getTagCompound().hasUniqueId(NetworkNodeStorage.NBT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
|
super.onUpdate(stack, world, entity, itemSlot, isSelected);
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
|
OneSixMigrationHelper.migrateItemStorageBlockItem(world, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -279,7 +279,7 @@ public class ProxyClient extends ProxyCommon {
|
|||||||
|
|
||||||
ModelLoader.setCustomStateMapper(RSBlocks.PORTABLE_GRID, new StateMap.Builder().ignore(BlockPortableGrid.TYPE).build());
|
ModelLoader.setCustomStateMapper(RSBlocks.PORTABLE_GRID, new StateMap.Builder().ignore(BlockPortableGrid.TYPE).build());
|
||||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.PORTABLE_GRID), stack -> {
|
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.PORTABLE_GRID), stack -> {
|
||||||
PortableGrid portableGrid = new PortableGrid(null, stack);
|
PortableGrid portableGrid = new PortableGrid(null, stack); // TODO: pass fullness?
|
||||||
|
|
||||||
return new ModelResourceLocation("refinedstorage:portable_grid", "connected=" + Boolean.toString(portableGrid.getEnergy() != 0 && !portableGrid.getDisk().getStackInSlot(0).isEmpty()) + ",direction=north,disk_state=" + TilePortableGrid.getDiskState(portableGrid));
|
return new ModelResourceLocation("refinedstorage:portable_grid", "connected=" + Boolean.toString(portableGrid.getEnergy() != 0 && !portableGrid.getDisk().getStackInSlot(0).isEmpty()) + ",direction=north,disk_state=" + TilePortableGrid.getDiskState(portableGrid));
|
||||||
});
|
});
|
||||||
|
@@ -8,13 +8,11 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.init.PotionTypes;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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.potion.PotionUtils;
|
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
@@ -38,8 +36,6 @@ import java.util.function.Function;
|
|||||||
|
|
||||||
public final class StackUtils {
|
public final class StackUtils {
|
||||||
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
||||||
public static final ItemStack EMPTY_BOTTLE = new ItemStack(Items.GLASS_BOTTLE);
|
|
||||||
public static final ItemStack WATER_BOTTLE = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
|
|
||||||
|
|
||||||
private static final String NBT_INVENTORY = "Inventory_%d";
|
private static final String NBT_INVENTORY = "Inventory_%d";
|
||||||
private static final String NBT_SLOT = "Slot";
|
private static final String NBT_SLOT = "Slot";
|
||||||
|
Reference in New Issue
Block a user