mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Made color lens more modular by adding a way to colorize items to the API.
API Version bumped to 9.
This commit is contained in:
parent
727fb1fc24
commit
06ede0c822
8 changed files with 118 additions and 42 deletions
|
@ -12,27 +12,28 @@ package de.ellpeck.actuallyadditions.api;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn;
|
import de.ellpeck.actuallyadditions.api.recipe.*;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient;
|
import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ActuallyAdditionsAPI{
|
public class ActuallyAdditionsAPI{
|
||||||
|
|
||||||
public static final String MOD_ID = "actuallyadditions";
|
public static final String MOD_ID = "actuallyadditions";
|
||||||
public static final String API_ID = MOD_ID+"api";
|
public static final String API_ID = MOD_ID+"api";
|
||||||
public static final String API_VERSION = "8";
|
public static final String API_VERSION = "9";
|
||||||
|
|
||||||
public static List<CrusherRecipe> crusherRecipes = new ArrayList<CrusherRecipe>();
|
public static List<CrusherRecipe> crusherRecipes = new ArrayList<CrusherRecipe>();
|
||||||
public static List<BallOfFurReturn> ballOfFurReturnItems = new ArrayList<BallOfFurReturn>();
|
public static List<BallOfFurReturn> ballOfFurReturnItems = new ArrayList<BallOfFurReturn>();
|
||||||
public static List<TreasureChestLoot> treasureChestLoot = new ArrayList<TreasureChestLoot>();
|
public static List<TreasureChestLoot> treasureChestLoot = new ArrayList<TreasureChestLoot>();
|
||||||
public static List<LensNoneRecipe> reconstructorLensNoneRecipes = new ArrayList<LensNoneRecipe>();
|
public static List<LensNoneRecipe> reconstructorLensNoneRecipes = new ArrayList<LensNoneRecipe>();
|
||||||
|
public static Map<Item, IColorLensChanger> reconstructorLensColorChangers = new HashMap<Item, IColorLensChanger>();
|
||||||
public static List<CoffeeIngredient> coffeeMachineIngredients = new ArrayList<CoffeeIngredient>();
|
public static List<CoffeeIngredient> coffeeMachineIngredients = new ArrayList<CoffeeIngredient>();
|
||||||
|
|
||||||
public static List<IBookletEntry> bookletEntries = new ArrayList<IBookletEntry>();
|
public static List<IBookletEntry> bookletEntries = new ArrayList<IBookletEntry>();
|
||||||
|
@ -159,6 +160,19 @@ public class ActuallyAdditionsAPI{
|
||||||
reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse));
|
reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an item and the way it is modified to the Atomic Reconstructor's color lens.
|
||||||
|
* This also works for blocks, but they have to be in their item form.
|
||||||
|
* The way it is modified is an instance of IColorLensChanger. When modifying the item,
|
||||||
|
* its modifyItem() method will be called with a stack containing the item.
|
||||||
|
*
|
||||||
|
* @param item The item (or block's item) to add
|
||||||
|
* @param changer The change mechanism
|
||||||
|
*/
|
||||||
|
public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer){
|
||||||
|
reconstructorLensColorChangers.put(item, changer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ingredient to the Coffee Machine ingredient list
|
* Adds an ingredient to the Coffee Machine ingredient list
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package de.ellpeck.actuallyadditions.api.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes an item's color by changing its metadata.
|
||||||
|
* Much like dye and wool, 0 is white and 15 is black and it will cycle around.
|
||||||
|
*/
|
||||||
|
public class ColorLensChangerByDyeMeta implements IColorLensChanger{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack modifyItem(ItemStack stack){
|
||||||
|
ItemStack newStack = stack.copy();
|
||||||
|
int meta = newStack.getItemDamage();
|
||||||
|
if(meta >= 15){
|
||||||
|
newStack.setItemDamage(0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newStack.setItemDamage(meta+1);
|
||||||
|
}
|
||||||
|
return newStack;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package de.ellpeck.actuallyadditions.api.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for the Atomic Reconstructor's Color Lens changing algorythm.
|
||||||
|
* When registering a new item to be changed, it needs an IColorLensChanger which
|
||||||
|
* is the method with which the item will be changed.
|
||||||
|
*
|
||||||
|
* See ColorLensChangerByDyeMeta for reference.
|
||||||
|
*/
|
||||||
|
public interface IColorLensChanger{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifies the given item.
|
||||||
|
* Will only be called with stacks containing items that are registered with
|
||||||
|
* this IColorLensChanger.
|
||||||
|
*
|
||||||
|
* @param stack the stack to modify
|
||||||
|
* @return the modified stack. Please make sure to return a modified COPY of the input stack.
|
||||||
|
*/
|
||||||
|
ItemStack modifyItem(ItemStack stack);
|
||||||
|
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitForeignPaxels;
|
import de.ellpeck.actuallyadditions.mod.items.InitForeignPaxels;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.lens.LensNoneRecipeHandler;
|
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
|
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
|
||||||
import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials;
|
import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.*;
|
import de.ellpeck.actuallyadditions.mod.misc.*;
|
||||||
|
@ -105,7 +105,7 @@ public class ActuallyAdditions{
|
||||||
ItemCrafting.initMashedFoodRecipes();
|
ItemCrafting.initMashedFoodRecipes();
|
||||||
HairyBallHandler.init();
|
HairyBallHandler.init();
|
||||||
TreasureChestHandler.init();
|
TreasureChestHandler.init();
|
||||||
LensNoneRecipeHandler.init();
|
LensRecipeHandler.init();
|
||||||
InitForeignPaxels.init();
|
InitForeignPaxels.init();
|
||||||
|
|
||||||
InitBooklet.postInit();
|
InitBooklet.postInit();
|
||||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.booklet;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||||
|
@ -26,7 +25,7 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.gen.OreGen;
|
import de.ellpeck.actuallyadditions.mod.gen.OreGen;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.lens.LensNoneRecipeHandler;
|
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
|
@ -60,14 +59,14 @@ public class InitBooklet{
|
||||||
//Getting Started
|
//Getting Started
|
||||||
chapterIntro = new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
|
chapterIntro = new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
|
||||||
new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook));
|
new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook));
|
||||||
new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setPageStacksWildcard(), new PageCrafting(7, MiscCrafting.recipesCrystals).setNoText(), new PageCrafting(8, MiscCrafting.recipesCrystalBlocks).setNoText(), new PageReconstructor(9, LensNoneRecipeHandler.mainPageRecipes).setNoText()).setSpecial();
|
new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setPageStacksWildcard(), new PageCrafting(7, MiscCrafting.recipesCrystals).setNoText(), new PageCrafting(8, MiscCrafting.recipesCrystalBlocks).setNoText(), new PageReconstructor(9, LensRecipeHandler.mainPageRecipes).setNoText()).setSpecial();
|
||||||
new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).addTextReplacement("<rf>", TileEntityCoalGenerator.PRODUCE).setPageStacksWildcard());
|
new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).addTextReplacement("<rf>", TileEntityCoalGenerator.PRODUCE).setPageStacksWildcard());
|
||||||
new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText()).setImportant();
|
new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText()).setImportant();
|
||||||
new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1));
|
new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1));
|
||||||
|
|
||||||
//Miscellaneous
|
//Miscellaneous
|
||||||
new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(3, LensNoneRecipeHandler.recipeColorLens), new PageReconstructor(4, LensNoneRecipeHandler.recipeExplosionLens), new PageReconstructor(5, LensNoneRecipeHandler.recipeDamageLens), new PageReconstructor(6, LensNoneRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(7, LensNoneRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(8, LensNoneRecipeHandler.recipeNetherWart).setNoText()).setImportant();
|
new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeColorLens), new PageReconstructor(4, LensRecipeHandler.recipeExplosionLens), new PageReconstructor(5, LensRecipeHandler.recipeDamageLens), new PageReconstructor(6, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(7, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(8, LensRecipeHandler.recipeNetherWart).setNoText()).setImportant();
|
||||||
new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTestifiBucksGreenWall), new PageTextOnly(1), new PageReconstructor(2, LensNoneRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensNoneRecipeHandler.recipeGreenWall).setNoText());
|
new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTestifiBucksGreenWall), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText());
|
||||||
new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", OreGen.QUARTZ_MIN).addTextReplacement("<highest>", OreGen.QUARTZ_MAX), 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", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", OreGen.QUARTZ_MIN).addTextReplacement("<highest>", OreGen.QUARTZ_MAX), 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("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText().setPageStacksWildcard()).setSpecial();
|
new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText().setPageStacksWildcard()).setSpecial();
|
||||||
new BookletChapter("coalStuff", ActuallyAdditionsAPI.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", ActuallyAdditionsAPI.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());
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
|
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
|
@ -21,25 +23,19 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class LensColor extends Lens{
|
public class LensColor extends Lens{
|
||||||
|
|
||||||
public static final int ENERGY_USE = 200;
|
public static final int ENERGY_USE = 200;
|
||||||
public static final Object[] CONVERTABLE_BLOCKS = new Object[]{
|
|
||||||
Items.DYE,
|
|
||||||
Blocks.WOOL,
|
|
||||||
Blocks.STAINED_GLASS,
|
|
||||||
Blocks.STAINED_GLASS_PANE,
|
|
||||||
Blocks.STAINED_HARDENED_CLAY,
|
|
||||||
Blocks.CARPET,
|
|
||||||
InitBlocks.blockColoredLamp,
|
|
||||||
InitBlocks.blockColoredLampOn
|
|
||||||
};
|
|
||||||
//Thanks to xdjackiexd for this, as I couldn't be bothered
|
//Thanks to xdjackiexd for this, as I couldn't be bothered
|
||||||
private static final float[][] POSSIBLE_COLORS = {
|
private static final float[][] POSSIBLE_COLORS = {
|
||||||
{158F, 43F, 39F}, //Red
|
{158F, 43F, 39F}, //Red
|
||||||
|
@ -60,30 +56,21 @@ public class LensColor extends Lens{
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
|
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
if(hitBlock != null){
|
if(hitBlock != null){
|
||||||
if(Util.arrayContains(CONVERTABLE_BLOCKS, PosUtil.getBlock(hitBlock, tile.getWorldObject())) >= 0 && tile.getEnergy() >= ENERGY_USE){
|
if(tile.getEnergy() >= ENERGY_USE){
|
||||||
int meta = PosUtil.getMetadata(hitBlock, tile.getWorldObject());
|
int meta = PosUtil.getMetadata(hitBlock, tile.getWorldObject());
|
||||||
if(meta >= 15){
|
ItemStack returnStack = this.tryConvert(new ItemStack(PosUtil.getBlock(hitBlock, tile.getWorldObject()), 1, meta));
|
||||||
PosUtil.setMetadata(hitBlock, tile.getWorldObject(), 0, 2);
|
if(returnStack != null && returnStack.getItem() instanceof ItemBlock){
|
||||||
|
PosUtil.setBlock(hitBlock, tile.getWorldObject(), Block.getBlockFromItem(returnStack.getItem()), returnStack.getItemDamage(), 2);
|
||||||
|
|
||||||
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
PosUtil.setMetadata(hitBlock, tile.getWorldObject(), meta+1, 2);
|
|
||||||
}
|
|
||||||
tile.extractEnergy(ENERGY_USE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1));
|
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1));
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
if(!item.isDead && item.getEntityItem() != null && tile.getEnergy() >= ENERGY_USE){
|
if(!item.isDead && item.getEntityItem() != null && tile.getEnergy() >= ENERGY_USE){
|
||||||
if(Util.arrayContains(CONVERTABLE_BLOCKS, item.getEntityItem().getItem()) >= 0 || Util.arrayContains(CONVERTABLE_BLOCKS, Block.getBlockFromItem(item.getEntityItem().getItem())) >= 0){
|
ItemStack newStack = this.tryConvert(item.getEntityItem());
|
||||||
ItemStack newStack = item.getEntityItem().copy();
|
if(newStack != null){
|
||||||
int meta = newStack.getItemDamage();
|
|
||||||
if(meta >= 15){
|
|
||||||
newStack.setItemDamage(0);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
newStack.setItemDamage(meta+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.setDead();
|
item.setDead();
|
||||||
|
|
||||||
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
|
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
|
||||||
|
@ -97,6 +84,21 @@ public class LensColor extends Lens{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemStack tryConvert(ItemStack stack){
|
||||||
|
if(stack != null){
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if(item != null){
|
||||||
|
for(Map.Entry<Item, IColorLensChanger> changer : ActuallyAdditionsAPI.reconstructorLensColorChangers.entrySet()){
|
||||||
|
if(item == changer.getKey()){
|
||||||
|
return changer.getValue().modifyItem(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] getColor(){
|
public float[] getColor(){
|
||||||
float[] colors = POSSIBLE_COLORS[Util.RANDOM.nextInt(POSSIBLE_COLORS.length)];
|
float[] colors = POSSIBLE_COLORS[Util.RANDOM.nextInt(POSSIBLE_COLORS.length)];
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class LensNone extends Lens{
|
||||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
||||||
for(int reachY = -range; reachY < range+1; reachY++){
|
for(int reachY = -range; reachY < range+1; reachY++){
|
||||||
BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
||||||
List<LensNoneRecipe> recipes = LensNoneRecipeHandler.getRecipesFor(new ItemStack(PosUtil.getBlock(pos, tile.getWorldObject()), 1, PosUtil.getMetadata(pos, tile.getWorldObject())));
|
List<LensNoneRecipe> recipes = LensRecipeHandler.getRecipesFor(new ItemStack(PosUtil.getBlock(pos, tile.getWorldObject()), 1, PosUtil.getMetadata(pos, tile.getWorldObject())));
|
||||||
for(LensNoneRecipe recipe : recipes){
|
for(LensNoneRecipe recipe : recipes){
|
||||||
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
||||||
List<ItemStack> outputs = recipe.getOutputs();
|
List<ItemStack> outputs = recipe.getOutputs();
|
||||||
|
@ -70,7 +70,7 @@ public class LensNone extends Lens{
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
ItemStack stack = item.getEntityItem();
|
ItemStack stack = item.getEntityItem();
|
||||||
if(!item.isDead && stack != null){
|
if(!item.isDead && stack != null){
|
||||||
List<LensNoneRecipe> recipes = LensNoneRecipeHandler.getRecipesFor(stack);
|
List<LensNoneRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
|
||||||
for(LensNoneRecipe recipe : recipes){
|
for(LensNoneRecipe recipe : recipes){
|
||||||
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
||||||
List<ItemStack> outputs = recipe.getOutputs();
|
List<ItemStack> outputs = recipe.getOutputs();
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
|
import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta;
|
||||||
|
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigCrafting;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigCrafting;
|
||||||
|
@ -21,11 +23,12 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class LensNoneRecipeHandler{
|
public class LensRecipeHandler{
|
||||||
|
|
||||||
public static ArrayList<LensNoneRecipe> mainPageRecipes = new ArrayList<LensNoneRecipe>();
|
public static ArrayList<LensNoneRecipe> mainPageRecipes = new ArrayList<LensNoneRecipe>();
|
||||||
public static LensNoneRecipe recipeColorLens;
|
public static LensNoneRecipe recipeColorLens;
|
||||||
|
@ -96,6 +99,17 @@ public class LensNoneRecipeHandler{
|
||||||
recipeWhiteWall = RecipeUtil.lastReconstructorRecipe();
|
recipeWhiteWall = RecipeUtil.lastReconstructorRecipe();
|
||||||
ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
|
ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
|
||||||
recipeGreenWall = RecipeUtil.lastReconstructorRecipe();
|
recipeGreenWall = RecipeUtil.lastReconstructorRecipe();
|
||||||
|
|
||||||
|
IColorLensChanger changer = new ColorLensChangerByDyeMeta();
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Items.DYE, changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.WOOL), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS_PANE), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_HARDENED_CLAY), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.CARPET), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLamp), changer);
|
||||||
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<LensNoneRecipe> getRecipesFor(ItemStack input){
|
public static ArrayList<LensNoneRecipe> getRecipesFor(ItemStack input){
|
Loading…
Reference in a new issue