From 9dc5085fba533dca3259d53c138ccdcb7924980b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 5 Oct 2015 11:27:53 +0200 Subject: [PATCH] Fixed items getting added to inventories, added horse armor -> raw materials crafting, leaf generator redstone control --- .../booklet/InitBooklet.java | 4 +- .../booklet/page/PageCrusherRecipe.java | 2 +- .../config/values/ConfigCrafting.java | 1 + .../crafting/CrusherCrafting.java | 13 +++++ .../actuallyadditions/ore/InitOreDict.java | 5 +- .../tile/TileEntityLeafGenerator.java | 50 ++++++++++--------- .../actuallyadditions/util/WorldUtil.java | 39 +++++++++++---- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 8 files changed, 77 insertions(+), 39 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 0338bb85d..ab8d25f67 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -73,7 +73,7 @@ public class InitBooklet{ //RF Using Blocks new BookletChapterCoffee("coffeeMachine", entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()).addTextReplacement("", ConfigIntValues.COFFEE_MACHINE_WATER_USED.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PageCrafting(3, BlockCrafting.recipeCoffeeMachine).setNoText(), new PageCrafting(4, ItemCrafting.recipeCup).setNoText()); - new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText()); + new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeSugar).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(7, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); new BookletChapter("furnaceDouble", entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).addTextReplacement("", ConfigIntValues.FURNACE_ENERGY_USED.getValue())); new BookletChapter("miner", entryFunctionalRF, new ItemStack(InitBlocks.blockOreMagnet), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue()).addTextReplacement("", ConfigIntValues.ORE_MAGNET_OIL_USE.getValue()).addTextReplacement("", ConfigIntValues.ORE_MAGNET_RANGE.getValue()), new PageCrafting(2, BlockCrafting.recipeMiner).setNoText(), new PageCrafting(3, BlockCrafting.recipeCasing).setNoText()); new BookletChapter("lavaFactory", entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeLavaFactory).setNoText()); @@ -89,7 +89,7 @@ public class InitBooklet{ //No RF Using Items new BookletChapter("wings", entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()); - new BookletChapter("foods", entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipePizza).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrusherRecipe(18, CrusherCrafting.recipeSugar).setNoText()); + new BookletChapter("foods", entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipePizza).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText()); new BookletChapter("leafBlower", entryItemsNonRF, new ItemStack(InitItems.itemLeafBlowerAdvanced), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()); ArrayList aiotPages = new ArrayList(); aiotPages.add(new PageTextOnly(aiotPages.size()+1)); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 4a1bbf1ed..ef33d9cfc 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -108,7 +108,7 @@ public class PageCrusherRecipe extends BookletPage{ @Override public void updateScreen(int ticksElapsed){ - if(ticksElapsed%5 == 0){ + if(ticksElapsed%10 == 0){ if(this.inputPos+1 < this.recipe.getRecipeInputs().size()){ this.inputPos++; } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java index 7f8279a86..141da5ec0 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java @@ -141,6 +141,7 @@ public enum ConfigCrafting{ RICE_SUGAR("Rice -> Sugar", ConfigCategories.CRUSHER_RECIPES, "Crusher"), NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), IRON("Iron Ore -> Iron Dust + Gold Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + HORSE_ARMORS("Horse Armor -> Raw Materials", ConfigCategories.CRUSHER_RECIPES, "Crusher"), TELE_STAFF("Tele Staff", ConfigCategories.ITEMS_CRAFTING), CASING("Casing", ConfigCategories.BLOCKS_CRAFTING), diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java index 7dddc2d1b..db98cd795 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java @@ -18,6 +18,9 @@ import ellpeck.actuallyadditions.util.Util; public class CrusherCrafting{ public static CrusherRecipeRegistry.CrusherRecipe recipeSugar; + public static CrusherRecipeRegistry.CrusherRecipe recipeIronHorseArmor; + public static CrusherRecipeRegistry.CrusherRecipe recipeGoldHorseArmor; + public static CrusherRecipeRegistry.CrusherRecipe recipeDiamondHorseArmor; public static void init(){ ModUtil.LOGGER.info("Initializing Crusher Recipes..."); @@ -61,6 +64,16 @@ public class CrusherCrafting{ if(ConfigCrafting.IRON.isEnabled()){ CrusherRecipeRegistry.addRecipe("oreIron", "dustIron", 2, "dustGold", 1, 20); } + if(ConfigCrafting.HORSE_ARMORS.isEnabled()){ + CrusherRecipeRegistry.addRecipe("armorHorseIron", "dustIron", 8); + recipeIronHorseArmor = Util.GetRecipes.lastCrusherRecipe(); + + CrusherRecipeRegistry.addRecipe("armorHorseGold", "dustGold", 8); + recipeGoldHorseArmor = Util.GetRecipes.lastCrusherRecipe(); + + CrusherRecipeRegistry.addRecipe("armorHorseDiamond", "dustDiamond", 8); + recipeDiamondHorseArmor = Util.GetRecipes.lastCrusherRecipe(); + } CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6)); CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget")); diff --git a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java index 685a7094f..4cd6ef781 100644 --- a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java +++ b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java @@ -32,10 +32,13 @@ public class InitOreDict{ //Vanilla Ores addOre(Blocks.obsidian, "obsidian"); - addOre(new ItemStack(Items.coal), "coal"); + addOre(Items.coal, "coal"); addOre(Items.flint, "flint"); addOre(Blocks.gravel, "gravel"); addOre(Items.sugar, "sugar"); + addOre(Items.diamond_horse_armor, "armorHorseDiamond"); + addOre(Items.golden_horse_armor, "armorHorseGold"); + addOre(Items.iron_horse_armor, "armorHorseIron"); //My Ores addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron"); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java index e15571f9f..61eedfa31 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java @@ -44,42 +44,44 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr @SuppressWarnings("unchecked") public void updateEntity(){ if(!worldObj.isRemote){ + if(!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)){ - if(this.nextUseCounter >= ConfigIntValues.LEAF_GENERATOR_COOLDOWN_TIME.getValue()){ - this.nextUseCounter = 0; + if(this.nextUseCounter >= ConfigIntValues.LEAF_GENERATOR_COOLDOWN_TIME.getValue()){ + this.nextUseCounter = 0; - int energyProducedPerLeaf = ConfigIntValues.LEAF_GENERATOR_ENERGY_PRODUCED.getValue(); - if(energyProducedPerLeaf <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ - ArrayList breakPositions = new ArrayList(); + int energyProducedPerLeaf = ConfigIntValues.LEAF_GENERATOR_ENERGY_PRODUCED.getValue(); + if(energyProducedPerLeaf <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ + ArrayList breakPositions = new ArrayList(); - int range = ConfigIntValues.LEAF_GENERATOR_RANGE.getValue(); - for(int reachX = -range; reachX < range+1; reachX++){ - for(int reachZ = -range; reachZ < range+1; reachZ++){ - for(int reachY = -range; reachY < range+1; reachY++){ - Block block = this.worldObj.getBlock(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ); - if(block != null && block.isLeaves(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)){ - breakPositions.add(new WorldPos(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)); + int range = ConfigIntValues.LEAF_GENERATOR_RANGE.getValue(); + for(int reachX = -range; reachX < range+1; reachX++){ + for(int reachZ = -range; reachZ < range+1; reachZ++){ + for(int reachY = -range; reachY < range+1; reachY++){ + Block block = this.worldObj.getBlock(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ); + if(block != null && block.isLeaves(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)){ + breakPositions.add(new WorldPos(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)); + } } } } - } - if(!breakPositions.isEmpty()){ - Collections.shuffle(breakPositions); - WorldPos theCoord = breakPositions.get(0); + if(!breakPositions.isEmpty()){ + Collections.shuffle(breakPositions); + WorldPos theCoord = breakPositions.get(0); - Block theBlock = this.worldObj.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ()); - int meta = this.worldObj.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ()); - this.worldObj.playAuxSFX(2001, theCoord.getX(), theCoord.getY(), theCoord.getZ(), Block.getIdFromBlock(theBlock)+(meta << 12)); + Block theBlock = this.worldObj.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ()); + int meta = this.worldObj.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ()); + this.worldObj.playAuxSFX(2001, theCoord.getX(), theCoord.getY(), theCoord.getZ(), Block.getIdFromBlock(theBlock)+(meta << 12)); - this.worldObj.setBlockToAir(theCoord.getX(), theCoord.getY(), theCoord.getZ()); + this.worldObj.setBlockToAir(theCoord.getX(), theCoord.getY(), theCoord.getZ()); - this.storage.receiveEnergy(energyProducedPerLeaf, false); + this.storage.receiveEnergy(energyProducedPerLeaf, false); + } } } - } - else{ - this.nextUseCounter++; + else{ + this.nextUseCounter++; + } } if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index 4926782ea..262762286 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -247,20 +247,39 @@ public class WorldUtil{ return blocks; } + /** + * Add an ArrayList of ItemStacks to an Array of slots + * @param slots The slots to try to put the items into + * @param stacks The stacks to be put into the slots (Items don't actually get removed from there!) + * @param actuallyDo Do it or just test if it works? + * @return Does it work? + */ public static boolean addToInventory(ItemStack[] slots, ArrayList stacks, boolean actuallyDo){ + ItemStack[] testSlots = new ItemStack[slots.length]; + for(int i = 0; i < testSlots.length; i++){ + if(slots[i] != null){ + testSlots[i] = slots[i].copy(); + } + } + int working = 0; - for(ItemStack stack : stacks){ - for(int i = 0; i < slots.length; i++){ - if(slots[i] == null || (slots[i].isItemEqual(stack) && slots[i].stackSize <= stack.getMaxStackSize()-stack.stackSize)){ - working++; - if(actuallyDo){ - if(slots[i] == null){ - slots[i] = stack.copy(); - } - else{ - slots[i].stackSize += stack.stackSize; + for(ItemStack stackToPutIn : stacks){ + for(int i = 0; i < testSlots.length; i++){ + if(stackToPutIn != null && (testSlots[i] == null || (testSlots[i].isItemEqual(stackToPutIn) && testSlots[i].getMaxStackSize() >= testSlots[i].stackSize+stackToPutIn.stackSize))){ + if(testSlots[i] == null){ + if(actuallyDo){ + slots[i] = stackToPutIn.copy(); } + testSlots[i] = stackToPutIn.copy(); } + else{ + if(actuallyDo){ + slots[i].stackSize+=stackToPutIn.stackSize; + } + testSlots[i].stackSize+=stackToPutIn.stackSize; + } + working++; + break; } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 3688773f0..319799713 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -475,7 +475,7 @@ booklet.actuallyadditions.chapter.coffeeMachine.text.5=Milk is an impor booklet.actuallyadditions.chapter.coffeeMachine.text.6=The fact that you're reading this means that you either have HarvestCraft installed, or that you're looking at the lang file. This does the same thing as Milk, but for veggie guys. booklet.actuallyadditions.chapter.crusher.name=Crusher and Double Crusher -booklet.actuallyadditions.chapter.crusher.text.1=The Crusher turns every ore, ingot and gem into its corresponding dust using RF/t. When you put in Ores however, they will yield 2 pieces of dust. The Double Crusher basically does the same, however it can crush two ores at a time and uses RF/t. He's my crush +booklet.actuallyadditions.chapter.crusher.text.1=The Crusher turns every ore, ingot and gem into its corresponding dust using RF/t. When you put in Ores however, they will yield 2 pieces of dust. The Double Crusher basically does the same, however it can crush two ores at a time and uses RF/t. On the following pages, you can see some additional useful recipes for inside the crusher. He's my crush booklet.actuallyadditions.chapter.furnaceDouble.name=Double Furnace booklet.actuallyadditions.chapter.furnaceDouble.text.1=The Double Furnace works like a furnace, however, it uses RF/t and can smelt two items at a time.