1.5 -> 1.6 migration: network node direction. #1816
This commit is contained in:
@@ -77,13 +77,17 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (INetworkNode node : all()) {
|
||||
NBTTagCompound nodeTag = new NBTTagCompound();
|
||||
try {
|
||||
NBTTagCompound nodeTag = new NBTTagCompound();
|
||||
|
||||
nodeTag.setString(NBT_NODE_ID, node.getId());
|
||||
nodeTag.setLong(NBT_NODE_POS, node.getPos().toLong());
|
||||
nodeTag.setTag(NBT_NODE_DATA, node.write(new NBTTagCompound()));
|
||||
nodeTag.setString(NBT_NODE_ID, node.getId());
|
||||
nodeTag.setLong(NBT_NODE_POS, node.getPos().toLong());
|
||||
nodeTag.setTag(NBT_NODE_DATA, node.write(new NBTTagCompound()));
|
||||
|
||||
list.appendTag(nodeTag);
|
||||
list.appendTag(nodeTag);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag(NBT_NODES, list);
|
||||
|
||||
@@ -76,8 +76,9 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
if (storage != null)
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +90,9 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
if (storageId != null) {
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,9 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
|
||||
@Override
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
if (storage != null) storages.add(storage);
|
||||
if (storage != null) {
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +90,9 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
if (storageId != null) {
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -182,4 +182,8 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
||||
public static boolean isValidOneSixPattern(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(ItemPattern.NBT_PROCESSING);
|
||||
}
|
||||
|
||||
// If we remove the OneSixMigrationHelper we know where to remove other migration hooks by removing this method.
|
||||
public static void removalHook() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
@@ -65,6 +66,18 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
getNode().setActive(tag.getBoolean(NBT_ACTIVE));
|
||||
}
|
||||
|
||||
private EnumFacing directionToMigrate;
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
|
||||
OneSixMigrationHelper.removalHook();
|
||||
if (tag.hasKey(NBT_DIRECTION)) {
|
||||
directionToMigrate = EnumFacing.getFront(tag.getInteger("Direction"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IItemHandler getDrops() {
|
||||
@@ -92,6 +105,15 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
manager.markForSaving();
|
||||
}
|
||||
|
||||
OneSixMigrationHelper.removalHook();
|
||||
if (directionToMigrate != null) {
|
||||
((NetworkNode) node).setDirection(directionToMigrate);
|
||||
|
||||
directionToMigrate = null;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
return (N) node;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user