diff --git a/src/main/java/refinedstorage/api/network/NetworkMaster.java b/src/main/java/refinedstorage/api/network/NetworkMaster.java index 3fe672439..70de05f97 100755 --- a/src/main/java/refinedstorage/api/network/NetworkMaster.java +++ b/src/main/java/refinedstorage/api/network/NetworkMaster.java @@ -530,12 +530,12 @@ public class NetworkMaster { } } - if (!simulate) { + int sizePushed = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize; + + if (!simulate && sizePushed > 0) { syncItems(); syncItemsWithClients(); - int sizePushed = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize; - for (int i = 0; i < sizePushed; ++i) { if (!craftingTasks.empty()) { ICraftingTask top = craftingTasks.peek(); diff --git a/src/main/java/refinedstorage/api/storage/NBTStorage.java b/src/main/java/refinedstorage/api/storage/NBTStorage.java index 577c7e8b9..7f51cf786 100755 --- a/src/main/java/refinedstorage/api/storage/NBTStorage.java +++ b/src/main/java/refinedstorage/api/storage/NBTStorage.java @@ -11,6 +11,7 @@ import refinedstorage.RefinedStorageUtils; import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.FutureTask; /** * A implementation of {@link IStorage} that stores storage items in NBT. @@ -202,8 +203,6 @@ public abstract class NBTStorage implements IStorage { } public void onStorageChanged() { - writeToNBT(); - if (tile != null) { tile.markDirty(); } diff --git a/src/main/java/refinedstorage/autocrafting/CraftingTaskScheduler.java b/src/main/java/refinedstorage/autocrafting/CraftingTaskScheduler.java index 5c407dda3..411d5db9d 100755 --- a/src/main/java/refinedstorage/autocrafting/CraftingTaskScheduler.java +++ b/src/main/java/refinedstorage/autocrafting/CraftingTaskScheduler.java @@ -6,7 +6,7 @@ import refinedstorage.RefinedStorageUtils; import refinedstorage.api.network.NetworkMaster; public class CraftingTaskScheduler { - public static String NBT_SCHEDULED = "CraftingTaskScheduled"; + public static final String NBT_SCHEDULED = "CraftingTaskScheduled"; private ItemStack scheduledItem; diff --git a/src/main/java/refinedstorage/block/BlockStorage.java b/src/main/java/refinedstorage/block/BlockStorage.java index afff028e0..dde29493e 100755 --- a/src/main/java/refinedstorage/block/BlockStorage.java +++ b/src/main/java/refinedstorage/block/BlockStorage.java @@ -83,13 +83,17 @@ public class BlockStorage extends BlockSlave { @Override public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + TileStorage storage = (TileStorage) world.getTileEntity(pos); + + if (storage.getStorage() != null) { + storage.getStorage().writeToNBT(); + } + List drops = new ArrayList(); ItemStack stack = new ItemStack(RefinedStorageBlocks.STORAGE, 1, RefinedStorageBlocks.STORAGE.getMetaFromState(state)); - - NBTTagCompound tag = new NBTTagCompound(); - tag.setTag(TileStorage.NBT_STORAGE, ((TileStorage) world.getTileEntity(pos)).getStorageTag()); - stack.setTagCompound(tag); + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setTag(TileStorage.NBT_STORAGE, storage.getStorageTag()); drops.add(stack); diff --git a/src/main/java/refinedstorage/gui/GuiGrid.java b/src/main/java/refinedstorage/gui/GuiGrid.java index 1b9c4232e..5183f4469 100755 --- a/src/main/java/refinedstorage/gui/GuiGrid.java +++ b/src/main/java/refinedstorage/gui/GuiGrid.java @@ -73,6 +73,7 @@ public class GuiGrid extends GuiBase { super(container, 193, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 256 : 208); setScrollbar(new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 70 : 88)); + getScrollbar().setCanScroll(false); this.container = container; this.grid = grid; diff --git a/src/main/java/refinedstorage/tile/TileDiskDrive.java b/src/main/java/refinedstorage/tile/TileDiskDrive.java index c52198c8d..747b1ea12 100755 --- a/src/main/java/refinedstorage/tile/TileDiskDrive.java +++ b/src/main/java/refinedstorage/tile/TileDiskDrive.java @@ -62,6 +62,15 @@ public class TileDiskDrive extends TileSlave implements IStorageProvider, IStora storages[slot] = new Storage(disk); } } + + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (storages[slot] != null) { + storages[slot].writeToNBT(); + } + + return super.extractItem(slot, amount, simulate); + } }; private BasicItemHandler filters = new BasicItemHandler(9, this); @@ -121,6 +130,12 @@ public class TileDiskDrive extends TileSlave implements IStorageProvider, IStora public NBTTagCompound write(NBTTagCompound tag) { super.write(tag); + for (int i = 0; i < disks.getSlots(); ++i) { + if (storages[i] != null) { + storages[i].writeToNBT(); + } + } + RefinedStorageUtils.writeItems(disks, 0, tag); RefinedStorageUtils.writeItems(filters, 1, tag); diff --git a/src/main/java/refinedstorage/tile/TileExporter.java b/src/main/java/refinedstorage/tile/TileExporter.java index c9de04f7e..4768c9b1b 100755 --- a/src/main/java/refinedstorage/tile/TileExporter.java +++ b/src/main/java/refinedstorage/tile/TileExporter.java @@ -43,13 +43,13 @@ public class TileExporter extends TileSlave implements ICompareConfig { public void updateSlave() { IItemHandler handler = RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite()); + int size = RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1; + if (handler != null && ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) { for (int i = 0; i < filters.getSlots(); ++i) { ItemStack slot = filters.getStackInSlot(i); if (slot != null) { - int size = RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1; - ItemStack took = network.take(slot, size, compare); if (took != null) { diff --git a/src/main/java/refinedstorage/tile/TileStorage.java b/src/main/java/refinedstorage/tile/TileStorage.java index 9fda79af6..d6141308d 100755 --- a/src/main/java/refinedstorage/tile/TileStorage.java +++ b/src/main/java/refinedstorage/tile/TileStorage.java @@ -115,6 +115,11 @@ public class TileStorage extends TileSlave implements IStorageProvider, IStorage RefinedStorageUtils.writeItems(filters, 0, tag); tag.setInteger(NBT_PRIORITY, priority); + + if (storage != null) { + storage.writeToNBT(); + } + tag.setTag(NBT_STORAGE, storageTag); tag.setInteger(NBT_COMPARE, compare); tag.setInteger(NBT_MODE, mode); @@ -217,6 +222,10 @@ public class TileStorage extends TileSlave implements IStorageProvider, IStorage this.storageTag = storageTag; } + public NBTStorage getStorage() { + return storage; + } + @Override public int getPriority() { return priority;