From c2da2a5a6792d9971dfc62f5809e9fdc9f862dde Mon Sep 17 00:00:00 2001 From: austinv11 Date: Mon, 20 Jul 2015 19:09:34 -0400 Subject: [PATCH] Disables the use of antennas in peripheral containers It is way too complex to fix this properly Closes #91 --- build.gradle | 5 +-- .../recipe/ContainerRecipe.java | 33 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 9c688767..66b66829 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,9 @@ repositories { apply plugin: 'forge' -ext.buildNumber = System.getenv("BUILD_ID") ?: "dev" -version = "1.3.0-$buildNumber" +//ext.buildNumber = System.getenv("BUILD_ID") ?: "dev" +//version = "1.3.0-$buildNumber" +version = "1.3.0" group= "com.austinv11.peripheralsplusplus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Peripherals++" diff --git a/src/main/java/com/austinv11/peripheralsplusplus/recipe/ContainerRecipe.java b/src/main/java/com/austinv11/peripheralsplusplus/recipe/ContainerRecipe.java index b6b5b43b..dbaae6d3 100644 --- a/src/main/java/com/austinv11/peripheralsplusplus/recipe/ContainerRecipe.java +++ b/src/main/java/com/austinv11/peripheralsplusplus/recipe/ContainerRecipe.java @@ -2,6 +2,7 @@ import com.austinv11.collectiveframework.minecraft.utils.Colors; import com.austinv11.collectiveframework.minecraft.utils.NBTHelper; +import com.austinv11.collectiveframework.utils.ArrayUtils; import com.austinv11.peripheralsplusplus.blocks.BlockPeripheralContainer; import com.austinv11.peripheralsplusplus.init.ModBlocks; import com.austinv11.peripheralsplusplus.reference.Config; @@ -23,24 +24,28 @@ public class ContainerRecipe implements IRecipe { + private static Block[] blacklist = new Block[]{ModBlocks.antenna}; + @Override - public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { + public boolean matches(InventoryCrafting craftingInventory, World world) { boolean hasContainer = false; boolean hasPeripheral = false; int numOfPeripherals = 0; int numOfContained = 0; ItemStack container = new ItemStack(ModBlocks.peripheralContainer); - for (int i = 0; i < p_77569_1_.getSizeInventory(); i++) - if (p_77569_1_.getStackInSlot(i) != null) { - if (!(p_77569_1_.getStackInSlot(i).getItem() instanceof ItemBlock)) + for (int i = 0; i < craftingInventory.getSizeInventory(); i++) + if (craftingInventory.getStackInSlot(i) != null) { + if (!(craftingInventory.getStackInSlot(i).getItem() instanceof ItemBlock)) return false; else { - Block block = Block.getBlockFromItem(p_77569_1_.getStackInSlot(i).getItem()); + Block block = Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()); if (block instanceof BlockPeripheralContainer && hasContainer) return false; else if (block instanceof BlockPeripheralContainer) { hasContainer = true; - container = p_77569_1_.getStackInSlot(i); + container = craftingInventory.getStackInSlot(i); + } else if (ArrayUtils.indexOf(blacklist, block) == -1) { + return false; } else if (block instanceof IPeripheralProvider) { hasPeripheral = true; numOfPeripherals++; @@ -52,17 +57,17 @@ else if (block instanceof BlockPeripheralContainer) { } @Override - public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) { + public ItemStack getCraftingResult(InventoryCrafting craftingInventory) { HashMap map = new HashMap(); ItemStack base = new ItemStack(ModBlocks.peripheralContainer); - for (int i = 0; i < p_77572_1_.getSizeInventory(); i++) - if (p_77572_1_.getStackInSlot(i) != null) - if (Block.getBlockFromItem(p_77572_1_.getStackInSlot(i).getItem()) instanceof IPeripheralProvider && !(Block.getBlockFromItem(p_77572_1_.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer)) { - TileEntity ent = Block.getBlockFromItem(p_77572_1_.getStackInSlot(i).getItem()).createTileEntity(null, 0); + for (int i = 0; i < craftingInventory.getSizeInventory(); i++) + if (craftingInventory.getStackInSlot(i) != null) + if (Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof IPeripheralProvider && !(Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer)) { + TileEntity ent = Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()).createTileEntity(null, 0); if (ent != null && ent instanceof IPeripheral) - map.put(Block.getIdFromBlock(Block.getBlockFromItem(p_77572_1_.getStackInSlot(i).getItem())), (IPeripheral)ent); - }else if (Block.getBlockFromItem(p_77572_1_.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer) - base.stackTagCompound = p_77572_1_.getStackInSlot(i).stackTagCompound == null ? null : (NBTTagCompound) p_77572_1_.getStackInSlot(i).stackTagCompound.copy(); + map.put(Block.getIdFromBlock(Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem())), (IPeripheral)ent); + }else if (Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer) + base.stackTagCompound = craftingInventory.getStackInSlot(i).stackTagCompound == null ? null : (NBTTagCompound) craftingInventory.getStackInSlot(i).stackTagCompound.copy(); List text = new ArrayList(); if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags() || !base.stackTagCompound.hasKey("ids")) { NBTHelper.setIntArray(base, "ids", setToArray(map.keySet()));