From a1c852fba2565a580f117ef9b2982487e10ac98d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 20 Nov 2015 21:21:21 +0100 Subject: [PATCH] Atomic Reconstructor uses energy depending on recipe --- .../config/values/ConfigIntValues.java | 2 +- .../recipe/ReconstructorRecipeHandler.java | 32 ++++++++++--------- .../tile/TileEntityAtomicReconstructor.java | 16 +++++----- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java index c3219b867..ab95f3cbc 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java @@ -175,7 +175,7 @@ public enum ConfigIntValues{ RECONSTRUCTOR_DISTANCE("Atomic Reconstructor: Distance", ConfigCategories.MACHINE_VALUES, 10, 1, 50, "The max distance the Reconstructor goes forward to find blocks to convert"), RECONSTRCUTOR_RANGE("Atomic Reconstructor: Range", ConfigCategories.MACHINE_VALUES, 2, 1, 10, "The range of Converting blocks or items into other blocks or items"), - RECONSTRUCTOR_USE_PER_BLOCK("Atomic Reconstructor: Energy Use per Block", ConfigCategories.MACHINE_VALUES, 800, 0, 100000, "The amount of Energy the Reconstructor uses per Block converted"), + RECONSTRUCTOR_USE_PER_BLOCK("Atomic Reconstructor: Energy Use per Block", ConfigCategories.MACHINE_VALUES, 800, 0, 100000, "The base amount of Energy the Reconstructor uses per Block converted"), RECONSTRUCTOR_COOLDOWN_TIMER("Atomic Reconstrucor: Cooldown Timer", ConfigCategories.MACHINE_VALUES, 100, 0, 10000, "The amount of time the Reconstructor waits between shooting lasers"), TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"); diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java index 60447306c..88530e90a 100644 --- a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java @@ -22,23 +22,23 @@ public class ReconstructorRecipeHandler{ public static ArrayList recipes = new ArrayList(); public static void init(){ - addRecipe("blockRedstone", "blockCrystalRed"); - addRecipe("blockLapis", "blockCrystalBlue"); - addRecipe("blockDiamond", "blockCrystalLightBlue"); - addRecipe("blockEmerald", "blockCrystalGreen"); - addRecipe("blockCoal", "blockCrystalBlack"); - addRecipe("blockIron", "blockCrystalWhite"); + addRecipe("blockRedstone", "blockCrystalRed", 200); + addRecipe("blockLapis", "blockCrystalBlue", 200); + addRecipe("blockDiamond", "blockCrystalLightBlue", 600); + addRecipe("blockEmerald", "blockCrystalGreen", 1000); + addRecipe("blockCoal", "blockCrystalBlack", 400); + addRecipe("blockIron", "blockCrystalWhite", 300); - addRecipe("dustRedstone", "crystalRed"); - addRecipe("gemLapis", "crystalBlue"); - addRecipe("gemDiamond", "crystalLightBlue"); - addRecipe("gemEmerald", "crystalGreen"); - addRecipe("coal", "crystalBlack"); - addRecipe("ingotIron", "crystalWhite"); + addRecipe("dustRedstone", "crystalRed", 20); + addRecipe("gemLapis", "crystalBlue", 20); + addRecipe("gemDiamond", "crystalLightBlue", 60); + addRecipe("gemEmerald", "crystalGreen", 100); + addRecipe("coal", "crystalBlack", 40); + addRecipe("ingotIron", "crystalWhite", 30); } - public static void addRecipe(String input, String output){ - recipes.add(new Recipe(input, output)); + public static void addRecipe(String input, String output, int energyUse){ + recipes.add(new Recipe(input, output, energyUse)); } public static Recipe getRecipe(ItemStack input){ @@ -57,10 +57,12 @@ public class ReconstructorRecipeHandler{ public String input; public String output; + public int energyUse; - public Recipe(String input, String output){ + public Recipe(String input, String output, int energyUse){ this.input = input; this.output = output; + this.energyUse = energyUse; } public ItemStack getFirstOutput(){ diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java index 40a91dacb..7513f28a9 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java @@ -42,14 +42,14 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - int usePerBlock = ConfigIntValues.RECONSTRUCTOR_USE_PER_BLOCK.getValue(); - if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.storage.getEnergyStored() >= usePerBlock){ + int baseUse = ConfigIntValues.RECONSTRUCTOR_USE_PER_BLOCK.getValue(); + if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.storage.getEnergyStored() >= baseUse){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); //Extract energy for shooting the laser itself too! - this.storage.extractEnergy(usePerBlock*2, false); + this.storage.extractEnergy(baseUse, false); int distance = ConfigIntValues.RECONSTRUCTOR_DISTANCE.getValue(); for(int i = 0; i < distance; i++){ @@ -66,10 +66,10 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn for(int reachX = -range; reachX < range+1; reachX++){ for(int reachZ = -range; reachZ < range+1; reachZ++){ for(int reachY = -range; reachY < range+1; reachY++){ - if(this.storage.getEnergyStored() >= usePerBlock){ + if(this.storage.getEnergyStored() >= baseUse){ WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ); ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(new ItemStack(pos.getBlock(), pos.getMetadata())); - if(recipe != null){ + if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse){ ItemStack output = recipe.getFirstOutput(); if(output != null){ if(output.getItem() instanceof ItemBlock){ @@ -80,7 +80,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn EntityItem item = new EntityItem(worldObj, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy()); worldObj.spawnEntityInWorld(item); } - this.storage.extractEnergy(usePerBlock, false); + this.storage.extractEnergy(baseUse+recipe.energyUse, false); } } } @@ -91,7 +91,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn //Converting the Items ArrayList items = (ArrayList)worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(coordsBlock.getX()-range, coordsBlock.getY()-range, coordsBlock.getZ()-range, coordsBlock.getX()+range, coordsBlock.getY()+range, coordsBlock.getZ()+range)); for(EntityItem item : items){ - if(this.storage.getEnergyStored() >= usePerBlock){ + if(this.storage.getEnergyStored() >= baseUse){ ItemStack stack = item.getEntityItem(); if(stack != null){ ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(stack); @@ -102,7 +102,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn outputCopy.stackSize = stack.stackSize; item.setEntityItemStack(outputCopy); - this.storage.extractEnergy(usePerBlock, false); + this.storage.extractEnergy(baseUse, false); } } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 97d3c3728..af99fdeb2 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -596,7 +596,7 @@ booklet.actuallyadditions.chapter.blackLotus.text.1=Think of this: You need t booklet.actuallyadditions.chapter.blackLotus.text.2=No, not that one, Vaz booklet.actuallyadditions.chapter.crystals.name=Crystals and Reconstructor -booklet.actuallyadditions.chapter.crystals.text.1=For many Crafting Operations in Actually Additions, you will need Crystals or Crystal Blocks. These can be made using an Atomic Reconstructor. Just place one down facing in any direction and it will shoot out a red laser. When placing some of the blocks shown on the following pages in front of the laser, they will be converted into Crystals. During each conversion, it uses RF. +booklet.actuallyadditions.chapter.crystals.text.1=For many Crafting Operations in Actually Additions, you will need Crystals or Crystal Blocks. These can be made using an Atomic Reconstructor. Just place one down facing in any direction and it will shoot out a red laser. When placing some of the blocks shown on the following pages in front of the laser, they will be converted into Crystals. During the shooting of a laser and one conversion, it uses at least RF, but the rate varies depending on the converted block. booklet.actuallyadditions.chapter.crystals.text.2=The way this works is that the laser searches for a block, and when it finds one, it converts all blocks and items on the ground in that area into their Crystal forms (if they have one!). When trying to power the Reconstructor, at first you will notice that many power sources require crystals to be crafted. Not to worry, though, as you can use Coal Generators to create your first couple of crystals before you can upgrade to better sources. booklet.actuallyadditions.chapter.crystals.text.4=When you have crafted a couple of items, you might want to find a way to automate this. There is a very simple way to do accomplish this: Place the Atomic Reconstructor down facing into a Precision Dropper (to find it, look it up in the All Items and Search Entry!). Next, place a Ranged Collector in the area that has the converted items set as a whitelist. Now you can just chuck your raw materials into the Dropper to convert them!