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.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);
}
}

View file

@ -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("<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("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>();

View file

@ -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<ItemStack> stacks = OreDictionary.getOres(recipe.output, false);
for(ItemStack stack : stacks){
if(output.isItemEqual(stack)){
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 recipe;
}
}
}
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){
ArrayList<ReconstructorRecipeHandler.Recipe> 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<ReconstructorRecipeHandler.Recipe> 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<ReconstructorRecipeHandler.Recipe> 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<ItemStack> 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

View file

@ -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]));
}
}
}

View file

@ -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){

View file

@ -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<Recipe> getRecipes(ItemStack input){
ArrayList<Recipe> possibleRecipes = new ArrayList<Recipe>();
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};
}
}

View file

@ -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<ReconstructorRecipeHandler.Recipe> 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<ReconstructorRecipeHandler.Recipe> 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;
}
}

View file

@ -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");
}