diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java index 9facabc0b..fea963907 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockAtomicReconstructor.java @@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.items.IReconstructorLens; import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor; import ellpeck.actuallyadditions.util.IActAddItemOrBlock; import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -128,4 +129,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct } return true; } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index cd55c3168..7da01f2e3 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -62,7 +62,7 @@ public class InitBooklet{ //Miscellaneous new BookletChapter("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText()); - new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, new ItemStack(Blocks.soul_sand)).setNoText(), new PageReconstructor(3, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall))).setImportant(); + new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, new ItemStack(Blocks.soul_sand)).setNoText(), new PageReconstructor(3, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)), new PageReconstructor(4, new ItemStack(InitBlocks.blockTestifiBucksGreenWall)).setNoText()).setImportant(); new BookletChapter("cloud", entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText()).setSpecial(); new BookletChapter("coalStuff", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText()); ArrayList lampPages = new ArrayList(); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java index 695bf6a5d..ddd89deb7 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java @@ -57,6 +57,10 @@ public class PageReconstructor extends BookletPage{ else{ String strg = "Atomic Reconstructor"; gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0); + + //Lens + strg = this.getRecipeForOutput(this.result).type.name; + gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+75, 0); } String text = gui.currentPage.getText(); @@ -94,20 +98,28 @@ public class PageReconstructor extends BookletPage{ return this.result == null ? new ItemStack[0] : new ItemStack[]{this.result}; } - private ItemStack getInputForOutput(ItemStack output){ + private ReconstructorRecipeHandler.Recipe getRecipeForOutput(ItemStack output){ for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){ List stacks = OreDictionary.getOres(recipe.output, false); for(ItemStack stack : stacks){ if(output.isItemEqual(stack)){ - List inputs = OreDictionary.getOres(recipe.input, false); - if(inputs != null && !inputs.isEmpty() && inputs.get(0) != null){ - ItemStack input = inputs.get(0).copy(); - input.stackSize = 1; - return input; - } + return recipe; } } } return null; } + + private ItemStack getInputForOutput(ItemStack output){ + ReconstructorRecipeHandler.Recipe recipe = this.getRecipeForOutput(output); + if(recipe != null){ + List inputs = OreDictionary.getOres(recipe.input, false); + if(inputs != null && !inputs.isEmpty() && inputs.get(0) != null){ + ItemStack input = inputs.get(0).copy(); + input.stackSize = 1; + return input; + } + } + return null; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/nei/AtomicReconstructorRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/AtomicReconstructorRecipeHandler.java index 809f01525..42d3a46c8 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/AtomicReconstructorRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/AtomicReconstructorRecipeHandler.java @@ -60,7 +60,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl if(outputId.equals(NAME) && getClass() == AtomicReconstructorRecipeHandler.class){ ArrayList recipes = ReconstructorRecipeHandler.recipes; for(ReconstructorRecipeHandler.Recipe recipe : recipes){ - arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output)); + arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.name)); } } else{ @@ -73,7 +73,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl ArrayList recipes = ReconstructorRecipeHandler.recipes; for(ReconstructorRecipeHandler.Recipe recipe : recipes){ if(ItemUtil.contains(OreDictionary.getOres(recipe.output, false), result, true)){ - arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output)); + arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.name)); } } } @@ -83,7 +83,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl ArrayList recipes = ReconstructorRecipeHandler.recipes; for(ReconstructorRecipeHandler.Recipe recipe : recipes){ if(ItemUtil.contains(OreDictionary.getOres(recipe.input, false), ingredient, true)){ - CachedReconstructorRecipe theRecipe = new CachedReconstructorRecipe(recipe.input, recipe.output); + CachedReconstructorRecipe theRecipe = new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.name); theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); arecipes.add(theRecipe); } @@ -117,6 +117,12 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl if(Minecraft.getMinecraft().currentScreen != null){ BookletPage.renderItem(Minecraft.getMinecraft().currentScreen, new ItemStack(InitBlocks.blockAtomicReconstructor), 32+34, 19, 1.0F); } + + CachedReconstructorRecipe cache = (CachedReconstructorRecipe)this.arecipes.get(recipe); + if(cache != null && cache.lens != null){ + GuiDraw.drawString(cache.lens, 10, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } @Override @@ -128,8 +134,9 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl public PositionedStack result; public PositionedStack input; + public String lens; - public CachedReconstructorRecipe(String input, String result){ + public CachedReconstructorRecipe(String input, String result, String lens){ List outputs = OreDictionary.getOres(result, false); for(ItemStack ore : outputs){ ore.stackSize = 1; @@ -141,6 +148,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl this.result = new PositionedStack(outputs, 67+32, 19); this.input = new PositionedStack(inputs, 5+32, 19); + this.lens = lens; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/network/PacketAtomicReconstructor.java index 5d0895f07..4d3e6de98 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketAtomicReconstructor.java @@ -85,7 +85,8 @@ public class PacketAtomicReconstructor implements IMessage{ for(int times = 0; times < 5; times++){ for(double i = 0; i <= 1; i += 1/(distance*8)){ ReconstructorRecipeHandler.LensType type = ReconstructorRecipeHandler.LensType.values()[message.lensTypeOrdinal]; - Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(world, (difX*i)+message.endX+0.5, (difY*i)+message.endY+0.5, (difZ*i)+message.endZ+0.5, 2F, type.getR(), type.getG(), type.getB())); + float[] color = type.getColor(); + Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(world, (difX*i)+message.endX+0.5, (difY*i)+message.endY+0.5, (difZ*i)+message.endZ+0.5, 2F, color[0], color[1], color[2])); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java index c38b7d41c..696545d53 100644 --- a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java +++ b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java @@ -107,6 +107,7 @@ public class InitOreDict{ addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack"); addOre(InitBlocks.blockTestifiBucksWhiteWall, "blockWhiteBrick"); + addOre(InitBlocks.blockTestifiBucksGreenWall, "blockGreenBrick"); } private static void addOre(ItemStack stack, String name){ diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java index 45cad468c..8d0ce622b 100644 --- a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java @@ -11,6 +11,7 @@ package ellpeck.actuallyadditions.recipe; import ellpeck.actuallyadditions.config.values.ConfigCrafting; +import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -42,6 +43,7 @@ public class ReconstructorRecipeHandler{ if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){ addRecipe("sand", "soulSand", 20000); addRecipe("blockQuartz", "blockWhiteBrick", 10); + addRecipe("blockQuartz", "blockGreenBrick", 10, LensType.COLOR); } } @@ -53,16 +55,17 @@ public class ReconstructorRecipeHandler{ recipes.add(new Recipe(input, output, energyUse, type)); } - public static Recipe getRecipe(ItemStack input){ + public static ArrayList getRecipes(ItemStack input){ + ArrayList possibleRecipes = new ArrayList(); for(Recipe recipe : recipes){ int[] ids = OreDictionary.getOreIDs(input); for(int id : ids){ if(Objects.equals(OreDictionary.getOreName(id), recipe.input)){ - return recipe; + possibleRecipes.add(recipe); } } } - return null; + return possibleRecipes; } public static class Recipe{ @@ -90,28 +93,21 @@ public class ReconstructorRecipeHandler{ public enum LensType{ - NONE, - COLOR; + NONE("No Lens"), + COLOR("Color Lens"); - public float getR(){ - if(this == COLOR){ - return Util.RANDOM.nextFloat(); - } - return 27F/255F; + public String name; + + LensType(String name){ + this.name = name; } - public float getG(){ + public float[] getColor(){ if(this == COLOR){ - return Util.RANDOM.nextFloat(); + float[] colors = AssetUtil.RGB_WOOL_COLORS[Util.RANDOM.nextInt(AssetUtil.RGB_WOOL_COLORS.length)]; + return new float[]{colors[0]/255F, colors[1]/255F, colors[2]/255F}; } - return 109F/255F; - } - - public float getB(){ - if(this == COLOR){ - return Util.RANDOM.nextFloat(); - } - return 1F; + return new float[]{27F/255F, 109F/255F, 1F}; } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java index e25b89aac..d69c5035f 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityAtomicReconstructor.java @@ -75,19 +75,22 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple for(int reachY = -range; reachY < range+1; reachY++){ 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(), 1, pos.getMetadata())); - if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ - ItemStack output = recipe.getFirstOutput(); - if(output != null){ - if(output.getItem() instanceof ItemBlock){ - this.worldObj.playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12)); - pos.setBlock(Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2); + ArrayList recipes = ReconstructorRecipeHandler.getRecipes(new ItemStack(pos.getBlock(), 1, pos.getMetadata())); + for(ReconstructorRecipeHandler.Recipe recipe : recipes){ + if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ + ItemStack output = recipe.getFirstOutput(); + if(output != null){ + if(output.getItem() instanceof ItemBlock){ + this.worldObj.playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12)); + pos.setBlock(Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2); + } + else{ + 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(baseUse+recipe.energyUse, false); + break; } - else{ - 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(baseUse+recipe.energyUse, false); } } } @@ -101,15 +104,18 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple if(this.storage.getEnergyStored() >= baseUse){ ItemStack stack = item.getEntityItem(); if(stack != null){ - ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(stack); - if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ - ItemStack output = recipe.getFirstOutput(); - if(output != null){ - ItemStack outputCopy = output.copy(); - outputCopy.stackSize = stack.stackSize; - item.setEntityItemStack(outputCopy); + ArrayList recipes = ReconstructorRecipeHandler.getRecipes(stack); + for(ReconstructorRecipeHandler.Recipe recipe : recipes){ + if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ + ItemStack output = recipe.getFirstOutput(); + if(output != null){ + ItemStack outputCopy = output.copy(); + outputCopy.stackSize = stack.stackSize; + item.setEntityItemStack(outputCopy); - this.storage.extractEnergy(baseUse+recipe.energyUse, false); + this.storage.extractEnergy(baseUse+recipe.energyUse, false); + break; + } } } } @@ -191,9 +197,4 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple public boolean canExtractItem(int slot, ItemStack stack, int side){ return true; } - - @Override - public int getInventoryStackLimit(){ - return 1; - } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java b/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java index d120f8123..0423a355e 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java @@ -37,6 +37,24 @@ public class AssetUtil{ public static int smileyCloudRenderId; public static int laserRelayRenderId; + /** + * Thanks to xdjackiexd for this, as I couldn't be bothered + */ + public static final float[][] RGB_WOOL_COLORS = { + {158F, 43F, 39F}, //Red + {234F, 126F, 53F}, //Orange + {194F, 181F, 28F}, //Yellow + {57F, 186F, 46F}, //Lime Green + {54F, 75F, 24F}, //Green + {99F, 135F, 210F}, //Light Blue + {38F, 113F, 145F}, //Cyan + {37F, 49F, 147F}, //Blue + {126F, 52F, 191F}, //Purple + {190F, 73F, 201F}, //Magenta + {217F, 129F, 153F}, //Pink + {86F, 51F, 28F}, //Brown + }; + public static ResourceLocation getGuiLocation(String file){ return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png"); }