From be808d4ff880e74145a4e08ea50c80b669dd3706 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sun, 18 Sep 2016 19:24:55 +0200 Subject: [PATCH] Updated changelog, removed manipulator toggle constant, fixed sidebutton offset, added recipe for manipulator, small formatting fixes --- CHANGELOG.md | 1 + CREDITS.md | 1 + .../block/BlockDiskManipulator.java | 1 + .../gui/sidebutton/SideButtonIOMode.java | 7 +- .../refinedstorage/proxy/ClientProxy.java | 4 +- .../refinedstorage/proxy/CommonProxy.java | 22 ++-- .../tile/TileDiskManipulator.java | 110 +++++++++++++----- .../assets/refinedstorage/textures/icons.png | Bin 3091 -> 3093 bytes 8 files changed, 103 insertions(+), 43 deletions(-) mode change 100644 => 100755 src/main/java/refinedstorage/gui/sidebutton/SideButtonIOMode.java mode change 100644 => 100755 src/main/java/refinedstorage/tile/TileDiskManipulator.java 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 8e42d3281c57bb7947fca6733d93f2fda8d98cb6..13a5e28bdc5736958049640f6a09bb72e9fdc34e 100755 GIT binary patch delta 1797 zcmV+g2m1Jv7?l{XR0ImP000iQ0nW&|rITI+AR{oX3JSmg00(+WL_t(|UhSRxdlN+% zg(FQXsjXT|DGfy|Ad{g4Cx4r!@z>0m_j$;fZ<}Avn@OH7S(cp25IRawXAY^E69IUJ z#a#jCV~z%MF-LPM-PvIQs63|y90f)|s&urToyEcx*4P22_1?Yqc@QxB_FHKK(a+nK zwRV86z4s3Dv{=9wK}G<6-nOi{1ElwBcbTle1zyDhL_cp^*4_b9ynhdABYYimM0RdF zTI_)EOeDfac;-PYKz43BTJ3c{%;#dfZfo!gF9I{>(QHW zzYZMGfApjC*d1UE)W7~ibs7O<6>Xp|HlSaB8}1YBfU!h>?06^E+oR{C@qj^UDt%JQylHt9Ygm&_DR@$KU=|yY}A5 z$cPpovx;T{0pnY@-nTU-RCZRF2?T7}vIS-Dm1U?fivc|o2pAr|gnvXBTpAt@RWvIz z6A0M6Ik;diBEB394TUP6m7WO%Y}#aAaKqqWsOqzlnSVgQ#*M+n3x=cB4>Oy1rOjzE!{mfB^Rm)cJ8>} ztn7VM>NAIc?ZMxF{QBq4(fzWP#wszB?0_Rjc5nOfyVJe0)QwerCJ~?+{prhxB}`-e zU}qiyqx*Y5`9|LNwy}z48UdrS-?x3VBYw#hW)=bRdWYfe&v!-wM)ynVnM8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