diff --git a/CHANGELOG.md b/CHANGELOG.md index a3a87090a..e3c5e7e6f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed crafting a complex item causes the process to flow off the Crafting Monitor's GUI (raoulvdberge) - Fixed shift clicking from Grid when player inventory is full throwing items in the world (raoulvdberge) - Added support for ore dictionary substitutions in Crafting Patterns (raoulvdberge) +- Added Disk Manipulator (way2muchnoise) ### 1.0.4 - Fixed lag caused by Crafter (raoulvdberge) diff --git a/CREDITS.md b/CREDITS.md index 9b827d6e4..adf3b53c9 100755 --- a/CREDITS.md +++ b/CREDITS.md @@ -2,6 +2,7 @@ ## Programming - raoulvdberge +- way2muchnoise - tomevoll (providing small patches) - blay09 (Crafting Tweaks integration) diff --git a/src/main/java/refinedstorage/block/BlockDiskManipulator.java b/src/main/java/refinedstorage/block/BlockDiskManipulator.java index 0e98da118..86997191d 100755 --- a/src/main/java/refinedstorage/block/BlockDiskManipulator.java +++ b/src/main/java/refinedstorage/block/BlockDiskManipulator.java @@ -29,6 +29,7 @@ public class BlockDiskManipulator extends BlockNode { if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DISK_MANIPULATOR, world, pos.getX(), pos.getY(), pos.getZ()); } + return true; } diff --git a/src/main/java/refinedstorage/gui/sidebutton/SideButtonIOMode.java b/src/main/java/refinedstorage/gui/sidebutton/SideButtonIOMode.java old mode 100644 new mode 100755 index 1ffb643b4..128924568 --- a/src/main/java/refinedstorage/gui/sidebutton/SideButtonIOMode.java +++ b/src/main/java/refinedstorage/gui/sidebutton/SideButtonIOMode.java @@ -15,18 +15,17 @@ public class SideButtonIOMode extends SideButton { @Override public String getTooltip(GuiBase gui) { - return TextFormatting.GREEN + gui.t("sidebutton.refinedstorage:iomode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:iomode." + (parameter.getValue() == TileDiskManipulator.INSERT ? "insert" : "extract")); + return TextFormatting.GREEN + gui.t("sidebutton.refinedstorage:iomode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:iomode." + (parameter.getValue() == TileDiskManipulator.IO_MODE_INSERT ? "insert" : "extract")); } @Override public void draw(GuiBase gui, int x, int y) { gui.bindTexture("icons.png"); - - gui.drawTexture(x, y + 1, parameter.getValue() == TileDiskManipulator.EXTRACT ? 0 : 16, 160, 16, 16); + gui.drawTexture(x, y + 1, parameter.getValue() == TileDiskManipulator.IO_MODE_EXTRACT ? 0 : 16, 160, 16, 16); } @Override public void actionPerformed() { - TileDataManager.setParameter(parameter, parameter.getValue() == TileDiskManipulator.INSERT ? TileDiskManipulator.EXTRACT : TileDiskManipulator.INSERT); + TileDataManager.setParameter(parameter, parameter.getValue() == TileDiskManipulator.IO_MODE_INSERT ? TileDiskManipulator.IO_MODE_EXTRACT : TileDiskManipulator.IO_MODE_INSERT); } } diff --git a/src/main/java/refinedstorage/proxy/ClientProxy.java b/src/main/java/refinedstorage/proxy/ClientProxy.java index 354a55f52..cbd0c95a8 100755 --- a/src/main/java/refinedstorage/proxy/ClientProxy.java +++ b/src/main/java/refinedstorage/proxy/ClientProxy.java @@ -280,9 +280,7 @@ public class ClientProxy extends CommonProxy { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_STORAGE), EnumFluidStorageType.TYPE_256K.getId(), new ModelResourceLocation("refinedstorage:fluid_storage", "type=256k")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_STORAGE), EnumFluidStorageType.TYPE_512K.getId(), new ModelResourceLocation("refinedstorage:fluid_storage", "type=512k")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_STORAGE), EnumFluidStorageType.TYPE_CREATIVE.getId(), new ModelResourceLocation("refinedstorage:fluid_storage", "type=creative")); - if (ENABLE_DISK_MANIPULATOR) { - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.DISK_MANIPULATOR), 0, new ModelResourceLocation("refinedstorage:disk_manipulator", "inventory")); - } + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.DISK_MANIPULATOR), 0, new ModelResourceLocation("refinedstorage:disk_manipulator", "inventory")); ModelLoader.setCustomStateMapper(RefinedStorageBlocks.CONTROLLER, new StateMap.Builder().ignore(BlockController.TYPE).build()); diff --git a/src/main/java/refinedstorage/proxy/CommonProxy.java b/src/main/java/refinedstorage/proxy/CommonProxy.java index e924f184f..936b3d0ac 100755 --- a/src/main/java/refinedstorage/proxy/CommonProxy.java +++ b/src/main/java/refinedstorage/proxy/CommonProxy.java @@ -39,8 +39,6 @@ import java.util.ArrayList; import java.util.List; public class CommonProxy { - public static final boolean ENABLE_DISK_MANIPULATOR = true; - protected List cableTypes = new ArrayList<>(); public void preInit(FMLPreInitializationEvent e) { @@ -98,9 +96,7 @@ public class CommonProxy { registerTile(TileNetworkTransmitter.class, "network_transmitter"); registerTile(TileFluidInterface.class, "fluid_interface"); registerTile(TileFluidStorage.class, "fluid_storage"); - if (ENABLE_DISK_MANIPULATOR) { - registerTile(TileDiskManipulator.class, "disk_manipulator"); - } + registerTile(TileDiskManipulator.class, "disk_manipulator"); registerBlock(RefinedStorageBlocks.CONTROLLER); registerBlock(RefinedStorageBlocks.GRID); @@ -125,9 +121,7 @@ public class CommonProxy { registerBlock(RefinedStorageBlocks.MACHINE_CASING); registerBlock(RefinedStorageBlocks.NETWORK_TRANSMITTER); registerBlock(RefinedStorageBlocks.NETWORK_RECEIVER); - if (ENABLE_DISK_MANIPULATOR) { - registerBlock(RefinedStorageBlocks.DISK_MANIPULATOR); - } + registerBlock(RefinedStorageBlocks.DISK_MANIPULATOR); registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON); registerItem(RefinedStorageItems.STORAGE_DISK); @@ -629,6 +623,18 @@ public class CommonProxy { 'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION), 'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED) ); + + // Disk Manipulator + GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DISK_MANIPULATOR), + "ESE", + "CMD", + "ESE", + 'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON), + 'S', new ItemStack(RefinedStorageItems.STORAGE_HOUSING), + 'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION), + 'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING), + 'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION) + ); } public void init(FMLInitializationEvent e) { diff --git a/src/main/java/refinedstorage/tile/TileDiskManipulator.java b/src/main/java/refinedstorage/tile/TileDiskManipulator.java old mode 100644 new mode 100755 index b28903da3..bf3c5b2de --- a/src/main/java/refinedstorage/tile/TileDiskManipulator.java +++ b/src/main/java/refinedstorage/tile/TileDiskManipulator.java @@ -34,8 +34,10 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte public static final TileDataParameter MODE = IFilterable.createParameter(); public static final TileDataParameter TYPE = IType.createParameter(); - public static final int INSERT = 0, EXTRACT = 1; - public static final TileDataParameter IO_MODE = new TileDataParameter<>(DataSerializers.VARINT, INSERT, new ITileDataProducer() { + public static final int IO_MODE_INSERT = 0; + public static final int IO_MODE_EXTRACT = 1; + + public static final TileDataParameter IO_MODE = new TileDataParameter<>(DataSerializers.VARINT, IO_MODE_INSERT, new ITileDataProducer() { @Override public Integer getValue(TileDiskManipulator tile) { return tile.ioMode; @@ -56,19 +58,16 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte private int compare = 0; private int mode = IFilterable.WHITELIST; private int type = IType.ITEMS; - private int ioMode = INSERT; + private int ioMode = IO_MODE_INSERT; - private ItemStorage[] itemStorages; - private FluidStorage[] fluidStorages; + private ItemStorage[] itemStorages = new ItemStorage[6]; + private FluidStorage[] fluidStorages = new FluidStorage[6]; public TileDiskManipulator() { dataManager.addWatchedParameter(COMPARE); dataManager.addWatchedParameter(MODE); dataManager.addWatchedParameter(TYPE); dataManager.addWatchedParameter(IO_MODE); - - itemStorages = new ItemStorage[6]; - fluidStorages = new FluidStorage[6]; } private ItemHandlerBasic disks = new ItemHandlerBasic(12, this, IItemValidator.STORAGE_DISK) { @@ -166,22 +165,35 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte public void updateNode() { int slot = 0; if (type == IType.ITEMS) { - while (slot < itemStorages.length && itemStorages[slot] == null) slot++; - if (slot == itemStorages.length) return; - ItemStorage storage = itemStorages[slot]; - if (ioMode == INSERT) { - insertIntoNetwork(storage, slot); - } else if (ioMode == EXTRACT) { - extractFromNetwork(storage, slot); + while (slot < itemStorages.length && itemStorages[slot] == null) { + slot++; } - } else if (type == IType.FLUIDS) { - while (slot < fluidStorages.length && fluidStorages[slot] == null) slot++; - if (slot == fluidStorages.length) return; - FluidStorage storage = fluidStorages[slot]; - if (ioMode == INSERT) { + if (slot == itemStorages.length) { + return; + } + + ItemStorage storage = itemStorages[slot]; + + if (ioMode == IO_MODE_INSERT) { insertIntoNetwork(storage, slot); - } else if (ioMode == EXTRACT) { + } else if (ioMode == IO_MODE_EXTRACT) { + extractFromNetwork(storage, slot); + } + } else if (type == IType.FLUIDS) { + while (slot < fluidStorages.length && fluidStorages[slot] == null) { + slot++; + } + + if (slot == fluidStorages.length) { + return; + } + + FluidStorage storage = fluidStorages[slot]; + + if (ioMode == IO_MODE_INSERT) { + insertIntoNetwork(storage, slot); + } else if (ioMode == IO_MODE_EXTRACT) { extractFromNetwork(storage, slot); } } @@ -192,22 +204,29 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + ItemStack extracted = null; int i = 0; + do { ItemStack stack = null; + while (storage.getItems().size() > i && stack == null) { stack = storage.getItems().get(i++); } + if (stack != null) { extracted = storage.extractItem(stack, 1, compare); } } while (storage.getItems().size() > i && extracted == null); + if (extracted == null) { moveDriveToOutput(slot); return; } + ItemStack remainder = network.insertItem(extracted, extracted.stackSize, false); + if (remainder != null) { storage.insertItem(remainder, remainder.stackSize, false); } @@ -218,24 +237,31 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + ItemStack extracted = null; int i = 0; + if (IFilterable.isEmpty(itemFilters)) { ItemStack toExtract = null; ArrayList networkItems = new ArrayList<>(network.getItemStorage().getStacks()); - int iii = 0; - while ((toExtract == null || toExtract.stackSize == 0) && iii < networkItems.size()) { - toExtract = networkItems.get(iii++); + + int j = 0; + + while ((toExtract == null || toExtract.stackSize == 0) && j < networkItems.size()) { + toExtract = networkItems.get(j++); } + if (toExtract != null) { extracted = network.extractItem(toExtract, 1, compare); } } else { while (itemFilters.getSlots() > i && extracted == null) { ItemStack stack = null; + while (itemFilters.getSlots() > i && stack == null) { stack = itemFilters.getStackInSlot(i++); } + if (stack != null) { extracted = network.extractItem(stack, 1, compare); } @@ -246,7 +272,9 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + ItemStack remainder = storage.insertItem(extracted, extracted.stackSize, false); + if (remainder != null) { network.insertItem(remainder, remainder.stackSize, false); } @@ -257,22 +285,29 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + FluidStack extracted = null; int i = 0; + do { FluidStack stack = storage.getStacks().get(i); + while (stack == null && storage.getStacks().size() > i) { i++; } + if (stack != null) { extracted = storage.extractFluid(stack, 1, compare); } } while (extracted == null && storage.getStacks().size() > i); + if (extracted == null) { moveDriveToOutput(slot); return; } + FluidStack remainder = network.insertFluid(extracted, extracted.amount, false); + if (remainder != null) { storage.insertFluid(remainder, remainder.amount, false); } @@ -283,24 +318,31 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + FluidStack extracted = null; int i = 0; + if (IFilterable.isEmpty(itemFilters)) { FluidStack toExtract = null; ArrayList networkFluids = new ArrayList<>(network.getFluidStorage().getStacks()); + int j = 0; + while ((toExtract == null || toExtract.amount == 0) && j < networkFluids.size()) { toExtract = networkFluids.get(j++); } + if (toExtract != null) { extracted = network.extractFluid(toExtract, 1, compare); } } else { while (fluidFilters.getSlots() > i && extracted == null) { FluidStack stack = null; + while (fluidFilters.getSlots() > i && stack == null) { stack = fluidFilters.getFluidStackInSlot(i++); } + if (stack != null) { extracted = network.extractFluid(stack, 1, compare); } @@ -311,7 +353,9 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte moveDriveToOutput(slot); return; } + FluidStack remainder = storage.insertFluid(extracted, extracted.amount, false); + if (remainder != null) { network.insertFluid(remainder, remainder.amount, false); } @@ -321,22 +365,27 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte ItemStack disk = disks.getStackInSlot(slot); if (disk != null) { int i = 6; + while (disks.getStackInSlot(i) != null && i < 12) { i++; } + if (i == 12) { return; } + if (slot < 6) { if (itemStorages[slot] != null) { itemStorages[slot].writeToNBT(); itemStorages[slot] = null; } + if (fluidStorages[slot] != null) { fluidStorages[slot].writeToNBT(); fluidStorages[slot] = null; } } + disks.extractItem(slot, 1, false); disks.insertItem(i, disk, false); } @@ -442,11 +491,16 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte } public void onBreak() { - for (ItemStorage storage : itemStorages) - if (storage != null) + for (ItemStorage storage : itemStorages) { + if (storage != null) { storage.writeToNBT(); - for (FluidStorage storage : fluidStorages) - if (storage != null) + } + } + + for (FluidStorage storage : fluidStorages) { + if (storage != null) { storage.writeToNBT(); + } + } } } diff --git a/src/main/resources/assets/refinedstorage/textures/icons.png b/src/main/resources/assets/refinedstorage/textures/icons.png index 8e42d3281..13a5e28bd 100755 Binary files a/src/main/resources/assets/refinedstorage/textures/icons.png and b/src/main/resources/assets/refinedstorage/textures/icons.png differ