Finished Lenses

This commit is contained in:
Ellpeck 2015-11-22 20:23:54 +01:00
parent 4d910cea70
commit 6787f2f44a
9 changed files with 102 additions and 58 deletions

View file

@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.items.IReconstructorLens;
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor; import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
import ellpeck.actuallyadditions.util.IActAddItemOrBlock; import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@ -128,4 +129,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct
} }
return true; 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);
}
} }

View file

@ -62,7 +62,7 @@ public class InitBooklet{
//Miscellaneous //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("<lowest>", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("<highest>", 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("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("<highest>", 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("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()); 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<BookletPage> lampPages = new ArrayList<BookletPage>(); ArrayList<BookletPage> lampPages = new ArrayList<BookletPage>();

View file

@ -57,6 +57,10 @@ public class PageReconstructor extends BookletPage{
else{ else{
String strg = "Atomic Reconstructor"; String strg = "Atomic Reconstructor";
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0); 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(); 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}; 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){ for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){
List<ItemStack> stacks = OreDictionary.getOres(recipe.output, false); List<ItemStack> stacks = OreDictionary.getOres(recipe.output, false);
for(ItemStack stack : stacks){ for(ItemStack stack : stacks){
if(output.isItemEqual(stack)){ if(output.isItemEqual(stack)){
List<ItemStack> inputs = OreDictionary.getOres(recipe.input, false); return recipe;
if(inputs != null && !inputs.isEmpty() && inputs.get(0) != null){
ItemStack input = inputs.get(0).copy();
input.stackSize = 1;
return input;
}
} }
} }
} }
return null; return null;
} }
private ItemStack getInputForOutput(ItemStack output){
ReconstructorRecipeHandler.Recipe recipe = this.getRecipeForOutput(output);
if(recipe != null){
List<ItemStack> 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;
}
} }

View file

@ -60,7 +60,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl
if(outputId.equals(NAME) && getClass() == AtomicReconstructorRecipeHandler.class){ if(outputId.equals(NAME) && getClass() == AtomicReconstructorRecipeHandler.class){
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes; ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
for(ReconstructorRecipeHandler.Recipe recipe : 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{ else{
@ -73,7 +73,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes; ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
for(ReconstructorRecipeHandler.Recipe recipe : recipes){ for(ReconstructorRecipeHandler.Recipe recipe : recipes){
if(ItemUtil.contains(OreDictionary.getOres(recipe.output, false), result, true)){ 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<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes; ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
for(ReconstructorRecipeHandler.Recipe recipe : recipes){ for(ReconstructorRecipeHandler.Recipe recipe : recipes){
if(ItemUtil.contains(OreDictionary.getOres(recipe.input, false), ingredient, true)){ 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); theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
arecipes.add(theRecipe); arecipes.add(theRecipe);
} }
@ -117,6 +117,12 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl
if(Minecraft.getMinecraft().currentScreen != null){ if(Minecraft.getMinecraft().currentScreen != null){
BookletPage.renderItem(Minecraft.getMinecraft().currentScreen, new ItemStack(InitBlocks.blockAtomicReconstructor), 32+34, 19, 1.0F); 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 @Override
@ -128,8 +134,9 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl
public PositionedStack result; public PositionedStack result;
public PositionedStack input; public PositionedStack input;
public String lens;
public CachedReconstructorRecipe(String input, String result){ public CachedReconstructorRecipe(String input, String result, String lens){
List<ItemStack> outputs = OreDictionary.getOres(result, false); List<ItemStack> outputs = OreDictionary.getOres(result, false);
for(ItemStack ore : outputs){ for(ItemStack ore : outputs){
ore.stackSize = 1; ore.stackSize = 1;
@ -141,6 +148,7 @@ public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler impl
this.result = new PositionedStack(outputs, 67+32, 19); this.result = new PositionedStack(outputs, 67+32, 19);
this.input = new PositionedStack(inputs, 5+32, 19); this.input = new PositionedStack(inputs, 5+32, 19);
this.lens = lens;
} }
@Override @Override

View file

@ -85,7 +85,8 @@ public class PacketAtomicReconstructor implements IMessage{
for(int times = 0; times < 5; times++){ for(int times = 0; times < 5; times++){
for(double i = 0; i <= 1; i += 1/(distance*8)){ for(double i = 0; i <= 1; i += 1/(distance*8)){
ReconstructorRecipeHandler.LensType type = ReconstructorRecipeHandler.LensType.values()[message.lensTypeOrdinal]; 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]));
} }
} }
} }

View file

@ -107,6 +107,7 @@ public class InitOreDict{
addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack"); addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
addOre(InitBlocks.blockTestifiBucksWhiteWall, "blockWhiteBrick"); addOre(InitBlocks.blockTestifiBucksWhiteWall, "blockWhiteBrick");
addOre(InitBlocks.blockTestifiBucksGreenWall, "blockGreenBrick");
} }
private static void addOre(ItemStack stack, String name){ private static void addOre(ItemStack stack, String name){

View file

@ -11,6 +11,7 @@
package ellpeck.actuallyadditions.recipe; package ellpeck.actuallyadditions.recipe;
import ellpeck.actuallyadditions.config.values.ConfigCrafting; import ellpeck.actuallyadditions.config.values.ConfigCrafting;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -42,6 +43,7 @@ public class ReconstructorRecipeHandler{
if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){ if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){
addRecipe("sand", "soulSand", 20000); addRecipe("sand", "soulSand", 20000);
addRecipe("blockQuartz", "blockWhiteBrick", 10); 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)); recipes.add(new Recipe(input, output, energyUse, type));
} }
public static Recipe getRecipe(ItemStack input){ public static ArrayList<Recipe> getRecipes(ItemStack input){
ArrayList<Recipe> possibleRecipes = new ArrayList<Recipe>();
for(Recipe recipe : recipes){ for(Recipe recipe : recipes){
int[] ids = OreDictionary.getOreIDs(input); int[] ids = OreDictionary.getOreIDs(input);
for(int id : ids){ for(int id : ids){
if(Objects.equals(OreDictionary.getOreName(id), recipe.input)){ if(Objects.equals(OreDictionary.getOreName(id), recipe.input)){
return recipe; possibleRecipes.add(recipe);
} }
} }
} }
return null; return possibleRecipes;
} }
public static class Recipe{ public static class Recipe{
@ -90,28 +93,21 @@ public class ReconstructorRecipeHandler{
public enum LensType{ public enum LensType{
NONE, NONE("No Lens"),
COLOR; COLOR("Color Lens");
public float getR(){ public String name;
if(this == COLOR){
return Util.RANDOM.nextFloat(); LensType(String name){
} this.name = name;
return 27F/255F;
} }
public float getG(){ public float[] getColor(){
if(this == COLOR){ 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; return new float[]{27F/255F, 109F/255F, 1F};
}
public float getB(){
if(this == COLOR){
return Util.RANDOM.nextFloat();
}
return 1F;
} }
} }

View file

@ -75,19 +75,22 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
for(int reachY = -range; reachY < range+1; reachY++){ for(int reachY = -range; reachY < range+1; reachY++){
if(this.storage.getEnergyStored() >= baseUse){ if(this.storage.getEnergyStored() >= baseUse){
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ); 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())); ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.getRecipes(new ItemStack(pos.getBlock(), 1, pos.getMetadata()));
if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ for(ReconstructorRecipeHandler.Recipe recipe : recipes){
ItemStack output = recipe.getFirstOutput(); if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){
if(output != null){ ItemStack output = recipe.getFirstOutput();
if(output.getItem() instanceof ItemBlock){ if(output != null){
this.worldObj.playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12)); if(output.getItem() instanceof ItemBlock){
pos.setBlock(Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2); 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){ if(this.storage.getEnergyStored() >= baseUse){
ItemStack stack = item.getEntityItem(); ItemStack stack = item.getEntityItem();
if(stack != null){ if(stack != null){
ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(stack); ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.getRecipes(stack);
if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){ for(ReconstructorRecipeHandler.Recipe recipe : recipes){
ItemStack output = recipe.getFirstOutput(); if(recipe != null && this.storage.getEnergyStored() >= baseUse+recipe.energyUse && recipe.type == currentLens){
if(output != null){ ItemStack output = recipe.getFirstOutput();
ItemStack outputCopy = output.copy(); if(output != null){
outputCopy.stackSize = stack.stackSize; ItemStack outputCopy = output.copy();
item.setEntityItemStack(outputCopy); 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){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return true; return true;
} }
@Override
public int getInventoryStackLimit(){
return 1;
}
} }

View file

@ -37,6 +37,24 @@ public class AssetUtil{
public static int smileyCloudRenderId; public static int smileyCloudRenderId;
public static int laserRelayRenderId; 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){ public static ResourceLocation getGuiLocation(String file){
return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png"); return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png");
} }