diff --git a/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java b/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java index e215a6a5d..7960f035c 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java @@ -20,7 +20,6 @@ import forestry.core.tiles.TileForestry; public enum BlockArboricultureType implements IMachinePropertiesTESR { ARBCHEST(TileArboristChest.class, "ArbChest") { - @Nullable @Override public IBlockRenderer getRenderer() { return Proxies.render.getRenderChest("arbchest"); diff --git a/src/main/java/forestry/core/blocks/BlockBase.java b/src/main/java/forestry/core/blocks/BlockBase.java index 6f33fda34..42a4d5807 100644 --- a/src/main/java/forestry/core/blocks/BlockBase.java +++ b/src/main/java/forestry/core/blocks/BlockBase.java @@ -248,7 +248,9 @@ public class BlockBase extends BlockForestry { public void init() { for (MachineDefinition def : definitions) { - def.register(); + if (def != null) { + def.register(); + } } } diff --git a/src/main/java/forestry/core/config/Constants.java b/src/main/java/forestry/core/config/Constants.java index 0254c2b67..e5f424f92 100644 --- a/src/main/java/forestry/core/config/Constants.java +++ b/src/main/java/forestry/core/config/Constants.java @@ -48,8 +48,6 @@ public class Constants implements IForestryConstants { // Village Chest Gen hook public static final String CHEST_GEN_HOOK_NATURALIST_CHEST = "naturalistChest"; - public static final int DEFINITION_LEPICHEST_META = 0; - // Item Ids public static final int SLOTS_BACKPACK_DEFAULT = 15; diff --git a/src/main/java/forestry/core/config/ForestryBlock.java b/src/main/java/forestry/core/config/ForestryBlock.java deleted file mode 100755 index 966abf9e8..000000000 --- a/src/main/java/forestry/core/config/ForestryBlock.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.config; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.oredict.OreDictionary; - -import cpw.mods.fml.common.registry.GameRegistry; - -import forestry.core.utils.StringUtil; -import forestry.plugins.PluginManager; -import forestry.plugins.PluginManager.Stage; - -/** - * Allows direct access to Forestry's blocks. Will be populated during BaseMod.load(). - * - * All of this stuff is metadata sensitive which is not reflected here! - * - * Make sure to only reference it in modsLoaded() or later. - * - * @author SirSengir - */ -public enum ForestryBlock { - lepidopterology; - private Block block; - - public void registerBlock(Block block, Class itemClass, String name) { - if (PluginManager.getStage() != Stage.SETUP) { - throw new RuntimeException("Tried to register Block outside of Setup"); - } - this.block = block; - block.setBlockName("for." + name); - GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); - } - - public boolean isItemEqual(ItemStack stack) { - return stack != null && isBlockEqual(Block.getBlockFromItem(stack.getItem())); - } - - public boolean isBlockEqual(Block i) { - return i != null && Block.isEqualTo(block, i); - } - - public boolean isBlockEqual(World world, int x, int y, int z) { - return isBlockEqual(world.getBlock(x, y, z)); - } - - public Item item() { - return Item.getItemFromBlock(block); - } - - public Block block() { - return block; - } - - public ItemStack getWildcard() { - return getItemStack(1, OreDictionary.WILDCARD_VALUE); - } - - public ItemStack getItemStack() { - return getItemStack(1, 0); - } - - public ItemStack getItemStack(int qty) { - return getItemStack(qty, 0); - } - - public ItemStack getItemStack(int qty, int meta) { - if (block == null) { - return null; - } - return new ItemStack(block, qty, meta); - } - - public boolean setBlock(World world, int x, int y, int z, int meta) { - return world.setBlock(x, y, z, block, meta, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); - } -} diff --git a/src/main/java/forestry/core/items/EnumElectronTube.java b/src/main/java/forestry/core/items/EnumElectronTube.java index b54cae8e6..a0254aeb5 100644 --- a/src/main/java/forestry/core/items/EnumElectronTube.java +++ b/src/main/java/forestry/core/items/EnumElectronTube.java @@ -33,11 +33,11 @@ public enum EnumElectronTube implements ItemOverlay.IOverlayInfo { private final int primaryColor; private final int secondaryColor; - EnumElectronTube(Color primaryColor) { - this(primaryColor, Color.WHITE); + EnumElectronTube(Color secondaryColor) { + this(secondaryColor, Color.WHITE); } - EnumElectronTube(Color primaryColor, Color secondaryColor) { + EnumElectronTube(Color secondaryColor, Color primaryColor) { this.name = "ex-" + ordinal(); this.primaryColor = primaryColor.getRGB(); this.secondaryColor = secondaryColor.getRGB(); diff --git a/src/main/java/forestry/core/recipes/RecipeUtil.java b/src/main/java/forestry/core/recipes/RecipeUtil.java index 01b16a15c..e1ba4b7cd 100644 --- a/src/main/java/forestry/core/recipes/RecipeUtil.java +++ b/src/main/java/forestry/core/recipes/RecipeUtil.java @@ -31,7 +31,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.recipes.IDescriptiveRecipe; import forestry.api.recipes.RecipeManagers; -import forestry.core.config.ForestryBlock; import forestry.core.fluids.Fluids; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; @@ -210,31 +209,26 @@ public abstract class RecipeUtil { return null; } - private static void cleanRecipe(Object... obj) { - for (int i = 0; i < obj.length; i++) { - if (obj[i] instanceof ForestryBlock) { - obj[i] = ((ForestryBlock) obj[i]).block(); - } - } - } - public static void addRecipe(Item item, Object... obj) { addRecipe(new ItemStack(item), obj); } @SuppressWarnings("unchecked") public static void addRecipe(ItemStack itemstack, Object... obj) { - cleanRecipe(obj); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(itemstack, obj)); } + @SuppressWarnings("unchecked") + public static void addPriorityRecipe(ItemStack itemStack, Object... obj) { + CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(itemStack, obj)); + } + public static void addShapelessRecipe(Item item, Object... obj) { addShapelessRecipe(new ItemStack(item), obj); } @SuppressWarnings("unchecked") public static void addShapelessRecipe(ItemStack itemstack, Object... obj) { - cleanRecipe(obj); CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(itemstack, obj)); } diff --git a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java index 5f16e2bc5..99c5157ac 100644 --- a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java @@ -10,34 +10,22 @@ ******************************************************************************/ package forestry.core.recipes; -import java.util.HashMap; - -import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; import forestry.api.recipes.IDescriptiveRecipe; -import forestry.core.config.ForestryBlock; - -public class ShapedRecipeCustom implements IDescriptiveRecipe { +public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveRecipe { private final int width; private final int height; - private final Object[] ingredients; - private final ItemStack product; - - public ShapedRecipeCustom(int width, int height, Object[] ingredients, ItemStack product) { + public ShapedRecipeCustom(int width, int height, ItemStack product, Object... ingredients) { + super(product, ingredients); this.width = width; this.height = height; - this.ingredients = ingredients; - this.product = product; } @Override @@ -50,14 +38,9 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { return height; } - @Override - public ItemStack getRecipeOutput() { - return product.copy(); - } - @Override public Object[] getIngredients() { - return ingredients; + return getInput(); } @Override @@ -65,96 +48,30 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { return false; } - @Override - public boolean matches(InventoryCrafting inventoryCrafting, World world) { - return RecipeUtil.matches(this, inventoryCrafting); - } - @Override @Deprecated public boolean matches(IInventory inventoryCrafting, World world) { - return RecipeUtil.matches(this, inventoryCrafting); - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - return getRecipeOutput().copy(); - } - - @Override - public int getRecipeSize() { - return width * height; + return false; } public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) { - - String s = ""; int index = 0; int columns = 0; int rows = 0; if (materials[index] instanceof String[]) { - String as[] = (String[]) materials[index++]; + String as[] = (String[]) materials[index]; for (String pattern : as) { rows++; columns = pattern.length(); - s = (new StringBuilder()).append(s).append(pattern).toString(); } - } else { while (materials[index] instanceof String) { String pattern = (String) materials[index++]; rows++; columns = pattern.length(); - s = (new StringBuilder()).append(s).append(pattern).toString(); } } - HashMap hashmap = new HashMap<>(); - for (; index < materials.length; index += 2) { - - Character character = (Character) materials[index]; - - // Item - if (materials[index + 1] instanceof Item) { - hashmap.put(character, new ItemStack((Item) materials[index + 1])); - } else if (materials[index + 1] instanceof ForestryBlock) { - hashmap.put(character, ((ForestryBlock) materials[index + 1]).getItemStack()); - } else if (materials[index + 1] instanceof Block) { - hashmap.put(character, new ItemStack((Block) materials[index + 1], 1, OreDictionary.WILDCARD_VALUE)); - } else if (materials[index + 1] instanceof ItemStack) { - hashmap.put(character, materials[index + 1]); - } else if (materials[index + 1] instanceof String) { - hashmap.put(character, OreDictionary.getOres((String) materials[index + 1])); - } else { - throw new RuntimeException("Invalid Recipe Defined!"); - } - - } - - Object ingredients[] = new Object[columns * rows]; - for (int l = 0; l < columns * rows; l++) { - char c = s.charAt(l); - if (hashmap.containsKey(c)) { - ingredients[l] = hashmap.get(c); - } else { - ingredients[l] = null; - } - } - - return new ShapedRecipeCustom(columns, rows, ingredients, product); - } - - @SuppressWarnings("unchecked") - public static ShapedRecipeCustom buildRecipe(ItemStack product, Object... materials) { - ShapedRecipeCustom recipe = createShapedRecipe(product, materials); - CraftingManager.getInstance().getRecipeList().add(recipe); - return recipe; - } - - @SuppressWarnings("unchecked") - public static ShapedRecipeCustom buildPriorityRecipe(ItemStack product, Object... materials) { - ShapedRecipeCustom recipe = createShapedRecipe(product, materials); - CraftingManager.getInstance().getRecipeList().add(0, recipe); - return recipe; + return new ShapedRecipeCustom(columns, rows, product, materials); } } diff --git a/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java deleted file mode 100644 index d9d892277..000000000 --- a/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java +++ /dev/null @@ -1,87 +0,0 @@ -package forestry.core.recipes; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; - -import net.minecraftforge.oredict.OreDictionary; - -public class ShapelessRecipeCustom implements IRecipe { - - @SuppressWarnings("unchecked") - public static ShapelessRecipeCustom buildRecipe(ItemStack product, ItemStack... ingredients) { - ShapelessRecipeCustom recipe = new ShapelessRecipeCustom(product, ingredients); - CraftingManager.getInstance().getRecipeList().add(recipe); - return recipe; - } - - @SuppressWarnings("unchecked") - public static ShapelessRecipeCustom buildPriorityRecipe(ItemStack product, ItemStack... ingredients) { - ShapelessRecipeCustom recipe = new ShapelessRecipeCustom(product, ingredients); - CraftingManager.getInstance().getRecipeList().add(0, recipe); - return recipe; - } - - private final List ingredients; - private final ItemStack product; - - private ShapelessRecipeCustom(ItemStack product, ItemStack... ingredients) { - this.ingredients = Arrays.asList(ingredients); - this.product = product; - } - - @Override - public boolean matches(InventoryCrafting inventoryCrafting, World world) { - ArrayList arraylist = new ArrayList<>(this.ingredients); - - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - ItemStack itemstack = inventoryCrafting.getStackInRowAndColumn(j, i); - - if (itemstack != null) { - boolean flag = false; - - for (ItemStack itemstack1 : arraylist) { - if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack.getItemDamage() == itemstack1.getItemDamage())) { - flag = true; - arraylist.remove(itemstack1); - break; - } - } - - if (!flag) { - return false; - } - } - } - } - - return arraylist.isEmpty(); - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - return product.copy(); - } - - @Override - public int getRecipeSize() { - return ingredients.size(); - } - - public List getIngredients() { - return ingredients; - } - - @Override - public ItemStack getRecipeOutput() { - return product.copy(); - } - -} diff --git a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java deleted file mode 100644 index cd89bc484..000000000 --- a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.recipes.nei; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; - -import forestry.core.recipes.ShapedRecipeCustom; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; - -public class NEIHandlerShapedCustom extends RecipeHandlerBase { - - public class CachedShapedCustomRecipe extends CachedBaseRecipe { - public List inputs = new ArrayList<>(); - public PositionedStack output; - - public CachedShapedCustomRecipe(ShapedRecipeCustom recipe) { - if (recipe.getIngredients() != null && recipe.getIngredients().length > 0) { - this.setIngredients(recipe.getWidth(), recipe.getHeight(), recipe.getIngredients()); - } - if (recipe.getRecipeOutput() != null) { - ItemStack output = recipe.getRecipeOutput(); - this.output = new PositionedStack(output, 119, 24); - } - } - - public void setIngredients(int width, int height, Object[] items) { - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - if (items.length <= y * width + x) { - continue; - } - - Object item = items[y * width + x]; - if (item == null) { - continue; - } else if (item instanceof ItemStack[] && ((ItemStack[]) item).length == 0) { - continue; - } else if (item instanceof List && ((List) item).size() == 0) { - continue; - } - - PositionedStack stack = new PositionedStack(item, 25 + x * 18, 6 + y * 18); - stack.setMaxSize(1); - this.inputs.add(stack); - } - } - } - - @Override - public List getIngredients() { - return this.getCycledIngredients(NEIHandlerShapedCustom.this.cycleticks / 20, this.inputs); - } - - @Override - public PositionedStack getResult() { - return this.output; - } - - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - if (recipe instanceof ShapedRecipeCustom && NEIServerUtils.areStacksSameTypeCrafting(((ShapedRecipeCustom) recipe).getRecipeOutput(), result)) { - CachedShapedCustomRecipe crecipe = new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe); - this.arecipes.add(crecipe); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - if (recipe instanceof ShapedRecipeCustom) { - CachedShapedCustomRecipe crecipe = new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe); - if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingredient)) { - this.arecipes.add(crecipe); - } - } - } - } - - @Override - public String getRecipeID() { - return "crafting"; - } - - @Override - public String getOverlayIdentifier() { - return "crafting"; - } - - @Override - public String getRecipeName() { - return NEIUtils.translate("handler.forestry.shaped"); - } - - @Override - public String getGuiTexture() { - return "minecraft:textures/gui/container/crafting_table.png"; - } - -} diff --git a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java deleted file mode 100644 index 3d7268735..000000000 --- a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.recipes.nei; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; - -import forestry.core.recipes.ShapelessRecipeCustom; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; - -public class NEIHandlerShapelessCustom extends RecipeHandlerBase { - private static final int[][] OUTPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}}; - - public class CachedShapelessCustomRecipe extends CachedBaseRecipe { - public List inputs = new ArrayList<>(); - public PositionedStack output; - - public CachedShapelessCustomRecipe(ShapelessRecipeCustom recipe) { - if (recipe.getIngredients() != null && recipe.getIngredients().size() > 0) { - this.setIngredients(recipe.getIngredients()); - } - if (recipe.getRecipeOutput() != null) { - ItemStack output = recipe.getRecipeOutput(); - this.output = new PositionedStack(output, 119, 24); - } - } - - public void setIngredients(List items) { - for (int i = 0; i < items.size(); i++) { - ItemStack item = items.get(i); - if (item == null) { - continue; - } - - PositionedStack stack = new PositionedStack(item, 25 + OUTPUTS[i][0] * 18, 6 + OUTPUTS[i][1] * 18); - stack.setMaxSize(1); - this.inputs.add(stack); - } - } - - @Override - public List getIngredients() { - return this.getCycledIngredients(NEIHandlerShapelessCustom.this.cycleticks / 20, this.inputs); - } - - @Override - public PositionedStack getResult() { - return this.output; - } - - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - if (recipe instanceof ShapelessRecipeCustom && NEIServerUtils.areStacksSameTypeCrafting(((ShapelessRecipeCustom) recipe).getRecipeOutput(), result)) { - CachedShapelessCustomRecipe crecipe = new CachedShapelessCustomRecipe((ShapelessRecipeCustom) recipe); - this.arecipes.add(crecipe); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - if (recipe instanceof ShapelessRecipeCustom) { - CachedShapelessCustomRecipe crecipe = new CachedShapelessCustomRecipe((ShapelessRecipeCustom) recipe); - if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingredient)) { - this.arecipes.add(crecipe); - } - } - } - } - - @Override - public String getRecipeID() { - return "crafting"; - } - - @Override - public String getOverlayIdentifier() { - return "crafting"; - } - - @Override - public String getRecipeName() { - return NEIUtils.translate("handler.forestry.shapeless"); - } - - @Override - public String getGuiTexture() { - return "minecraft:textures/gui/container/crafting_table.png"; - } -} diff --git a/src/main/java/forestry/core/recipes/nei/NEIIntegrationConfig.java b/src/main/java/forestry/core/recipes/nei/NEIIntegrationConfig.java index 9bab96391..7d0bc0c03 100644 --- a/src/main/java/forestry/core/recipes/nei/NEIIntegrationConfig.java +++ b/src/main/java/forestry/core/recipes/nei/NEIIntegrationConfig.java @@ -38,8 +38,6 @@ public class NEIIntegrationConfig implements IConfigureNEI { public void loadConfig() { Log.info("Loading: " + getName()); - registerHandler(new NEIHandlerShapedCustom()); - registerHandler(new NEIHandlerShapelessCustom()); registerHandler(new NEIHandlerBottler()); registerHandler(new NEIHandlerCarpenter()); registerHandler(new NEIHandlerCentrifuge()); diff --git a/src/main/java/forestry/core/tiles/MachineDefinition.java b/src/main/java/forestry/core/tiles/MachineDefinition.java index 63c4ca3b4..3a7023369 100644 --- a/src/main/java/forestry/core/tiles/MachineDefinition.java +++ b/src/main/java/forestry/core/tiles/MachineDefinition.java @@ -52,10 +52,6 @@ public class MachineDefinition { private float minX, minY, minZ, maxX, maxY, maxZ; - public MachineDefinition(int meta, String teIdent, Class teClass) { - this(meta, teIdent, teClass, null); - } - public MachineDefinition(IMachineProperties properties) { this(properties.getMeta(), properties.getTeIdent(), properties.getTeClass(), null); } diff --git a/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java index 1f2ca2ad0..4bb4359f0 100644 --- a/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java +++ b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java @@ -17,7 +17,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import forestry.core.config.Constants; -import forestry.core.config.ForestryBlock; import forestry.core.tiles.TileForestry; public class BlockTypeTileForestry implements IBlockType { @@ -25,10 +24,6 @@ public class BlockTypeTileForestry implements IBlockType { private final int meta; private ForgeDirection direction; - public BlockTypeTileForestry(ForestryBlock forestryBlock, int meta) { - this(forestryBlock.block(), meta); - } - public BlockTypeTileForestry(Block block, int meta) { this.block = block; this.meta = meta; diff --git a/src/main/java/forestry/energy/tiles/EngineDefinition.java b/src/main/java/forestry/energy/tiles/EngineDefinition.java index ea972b5a1..c48733871 100644 --- a/src/main/java/forestry/energy/tiles/EngineDefinition.java +++ b/src/main/java/forestry/energy/tiles/EngineDefinition.java @@ -13,6 +13,7 @@ package forestry.energy.tiles; import net.minecraft.world.IBlockAccess; import forestry.core.blocks.IMachineProperties; +import forestry.core.blocks.IMachinePropertiesTESR; import forestry.core.render.IBlockRenderer; import forestry.core.tiles.MachineDefinition; import forestry.core.tiles.TileEngine; @@ -21,14 +22,10 @@ import forestry.core.tiles.TileUtil; public class EngineDefinition extends MachineDefinition { - public EngineDefinition(IMachineProperties properties) { + public EngineDefinition(IMachinePropertiesTESR properties) { super(properties); } - public EngineDefinition(int meta, String teIdent, Class teClass, IBlockRenderer renderer) { - super(meta, teIdent, teClass, renderer); - } - @Override public boolean isSolidOnSide(IBlockAccess world, int x, int y, int z, int side) { TileEngine tile = TileUtil.getTile(world, x, y, z, TileEngine.class); diff --git a/src/main/java/forestry/factory/blocks/BlockFactoryTesrType.java b/src/main/java/forestry/factory/blocks/BlockFactoryTesrType.java index e97a13ecb..f9bf618f8 100644 --- a/src/main/java/forestry/factory/blocks/BlockFactoryTesrType.java +++ b/src/main/java/forestry/factory/blocks/BlockFactoryTesrType.java @@ -36,19 +36,24 @@ public enum BlockFactoryTesrType implements IMachinePropertiesTESR { MOISTENER(TileMoistener.class), SQUEEZER(TileSqueezer.class), STILL(TileStill.class), - RAINMAKER(TileMillRainmaker.class); + RAINMAKER(TileMillRainmaker.class) { + @Override + public IBlockRenderer getRenderer() { + return Proxies.render.getRenderMill(Constants.TEXTURE_PATH_BLOCKS + "/rainmaker_"); + } + }; public static final BlockFactoryTesrType[] VALUES = values(); private final String teIdent; private final Class teClass; - private final IBlockRenderer renderer; + private final String name; BlockFactoryTesrType(Class teClass) { String name = toString().toLowerCase(Locale.ENGLISH); this.teIdent = "forestry." + WordUtils.capitalize(name); this.teClass = teClass; - this.renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_"); + this.name = name; } @Override @@ -68,6 +73,6 @@ public enum BlockFactoryTesrType implements IMachinePropertiesTESR { @Override public IBlockRenderer getRenderer() { - return renderer; + return Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_"); } } diff --git a/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterology.java b/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterology.java new file mode 100644 index 000000000..f7fc83c9b --- /dev/null +++ b/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterology.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.lepidopterology.blocks; + +import forestry.api.core.Tabs; +import forestry.core.blocks.BlockBase; + +public class BlockLepidopterology extends BlockBase { + public BlockLepidopterology() { + super(true); + setCreativeTab(Tabs.tabLepidopterology); + } +} diff --git a/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterologyType.java b/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterologyType.java new file mode 100644 index 000000000..ba06df2bb --- /dev/null +++ b/src/main/java/forestry/lepidopterology/blocks/BlockLepidopterologyType.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.lepidopterology.blocks; + +import forestry.core.blocks.IMachinePropertiesTESR; +import forestry.core.proxy.Proxies; +import forestry.core.render.IBlockRenderer; +import forestry.core.tiles.TileForestry; +import forestry.lepidopterology.tiles.TileLepidopteristChest; + +public enum BlockLepidopterologyType implements IMachinePropertiesTESR { + LEPICHEST(TileLepidopteristChest.class, "LepiChest") { + @Override + public IBlockRenderer getRenderer() { + return Proxies.render.getRenderChest("lepichest"); + } + }; + + public static final BlockLepidopterologyType[] VALUES = values(); + + private final String teIdent; + private final Class teClass; + + BlockLepidopterologyType(Class teClass, String teName) { + this.teIdent = "forestry." + teName; + this.teClass = teClass; + } + + @Override + public int getMeta() { + return ordinal(); + } + + @Override + public String getTeIdent() { + return teIdent; + } + + @Override + public Class getTeClass() { + return teClass; + } +} diff --git a/src/main/java/forestry/lepidopterology/blocks/BlockRegistryLepidopterology.java b/src/main/java/forestry/lepidopterology/blocks/BlockRegistryLepidopterology.java new file mode 100644 index 000000000..cddbeddda --- /dev/null +++ b/src/main/java/forestry/lepidopterology/blocks/BlockRegistryLepidopterology.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.lepidopterology.blocks; + +import forestry.core.blocks.BlockRegistry; +import forestry.core.items.ItemBlockForestry; + +public class BlockRegistryLepidopterology extends BlockRegistry { + public final BlockLepidopterology lepidopterology; + + public BlockRegistryLepidopterology() { + lepidopterology = registerBlock(new BlockLepidopterology(), ItemBlockForestry.class, "lepidopterology"); + } +} diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 369a0b4c8..6b007756f 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -71,8 +71,6 @@ import forestry.core.items.ItemFruit.EnumFruit; import forestry.core.network.IPacketRegistry; import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; -import forestry.core.recipes.ShapedRecipeCustom; -import forestry.core.recipes.ShapelessRecipeCustom; import forestry.core.tiles.MachineDefinition; import forestry.factory.recipes.FabricatorRecipe; @@ -217,41 +215,41 @@ public class PluginArboriculture extends ForestryPlugin { planks.stackSize = 4; logs.stackSize = 1; - ShapelessRecipeCustom.buildRecipe(planks.copy(), logs.copy()); + RecipeUtil.addShapelessRecipe(planks.copy(), logs.copy()); fireproofPlanks.stackSize = 4; fireproofLogs.stackSize = 1; - ShapelessRecipeCustom.buildRecipe(fireproofPlanks.copy(), fireproofLogs.copy()); + RecipeUtil.addShapelessRecipe(fireproofPlanks.copy(), fireproofLogs.copy()); slabs.stackSize = 6; planks.stackSize = 1; - ShapedRecipeCustom.buildPriorityRecipe(slabs.copy(), + RecipeUtil.addPriorityRecipe(slabs.copy(), "###", '#', planks.copy()); fireproofSlabs.stackSize = 6; fireproofPlanks.stackSize = 1; - ShapedRecipeCustom.buildPriorityRecipe(fireproofSlabs.copy(), + RecipeUtil.addPriorityRecipe(fireproofSlabs.copy(), "###", '#', fireproofPlanks.copy()); fences.stackSize = 3; planks.stackSize = 1; - ShapedRecipeCustom.buildRecipe(fences.copy(), + RecipeUtil.addRecipe(fences.copy(), "#X#", "#X#", '#', planks.copy(), 'X', "stickWood"); fireproofFences.stackSize = 3; fireproofPlanks.stackSize = 1; - ShapedRecipeCustom.buildRecipe(fireproofFences.copy(), + RecipeUtil.addRecipe(fireproofFences.copy(), "#X#", "#X#", '#', fireproofPlanks.copy(), 'X', "stickWood"); stairs.stackSize = 4; planks.stackSize = 1; - ShapedRecipeCustom.buildPriorityRecipe(stairs.copy(), + RecipeUtil.addPriorityRecipe(stairs.copy(), "# ", "## ", "###", @@ -259,7 +257,7 @@ public class PluginArboriculture extends ForestryPlugin { fireproofStairs.stackSize = 4; fireproofPlanks.stackSize = 1; - ShapedRecipeCustom.buildPriorityRecipe(fireproofStairs.copy(), + RecipeUtil.addPriorityRecipe(fireproofStairs.copy(), "# ", "## ", "###", diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index eb15ba1a2..9393731f4 100644 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -57,7 +57,6 @@ import forestry.core.network.PacketRegistryCore; import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; import forestry.core.recipes.ShapedRecipeCustom; -import forestry.core.recipes.ShapelessRecipeCustom; import forestry.core.tiles.MachineDefinition; import forestry.core.utils.ClimateUtil; import forestry.core.utils.ForestryModEnvWarningCallable; @@ -117,9 +116,6 @@ public class PluginCore extends ForestryPlugin { ForestryModEnvWarningCallable.register(); AlleleHelper.instance.init(); - - RecipeSorter.register("forestry:shapedrecipecustom", ShapedRecipeCustom.class, RecipeSorter.Category.SHAPED, "before:minecraft:shaped"); - RecipeSorter.register("forestry:shapelessrecipecustom", ShapelessRecipeCustom.class, RecipeSorter.Category.SHAPELESS, "before:minecraft:shapeless"); } @Override diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 3bb684061..4438ae032 100644 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -289,7 +289,7 @@ public class PluginFarming extends ForestryPlugin { block.saveToCompound(compound); basic.setTagCompound((NBTTagCompound) compound.copy()); - ShapedRecipeCustom.buildRecipe(basic.copy(), + RecipeUtil.addRecipe(basic.copy(), "I#I", "WCW", '#', block.getBase(), diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index 4245f7fe2..1bb61e7cf 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -23,23 +23,20 @@ import cpw.mods.fml.common.SidedProxy; import forestry.Forestry; import forestry.api.arboriculture.TreeManager; -import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; import forestry.api.lepidopterology.ButterflyManager; import forestry.api.recipes.RecipeManagers; import forestry.core.GuiHandlerBase; -import forestry.core.blocks.BlockBase; import forestry.core.config.Constants; -import forestry.core.config.ForestryBlock; import forestry.core.config.LocalizedConfiguration; import forestry.core.fluids.Fluids; -import forestry.core.items.ItemBlockForestry; -import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; import forestry.core.tiles.MachineDefinition; import forestry.core.utils.EntityUtil; import forestry.lepidopterology.ButterflySpawner; import forestry.lepidopterology.GuiHandlerLepidopterology; +import forestry.lepidopterology.blocks.BlockLepidopterologyType; +import forestry.lepidopterology.blocks.BlockRegistryLepidopterology; import forestry.lepidopterology.commands.CommandButterfly; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.genetics.AlleleButterflyEffect; @@ -51,7 +48,6 @@ import forestry.lepidopterology.genetics.MothDefinition; import forestry.lepidopterology.items.ItemRegistryLepidopterology; import forestry.lepidopterology.proxy.ProxyLepidopterology; import forestry.lepidopterology.recipes.MatingRecipe; -import forestry.lepidopterology.tiles.TileLepidopteristChest; @Plugin(pluginID = "Lepidopterology", name = "Lepidopterology", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.lepidopterology.description") public class PluginLepidopterology extends ForestryPlugin { @@ -64,6 +60,7 @@ public class PluginLepidopterology extends ForestryPlugin { private static boolean allowPollination = true; public static ItemRegistryLepidopterology items; + public static BlockRegistryLepidopterology blocks; @Override protected void setupAPI() { @@ -78,9 +75,7 @@ public class PluginLepidopterology extends ForestryPlugin { @Override protected void registerItemsAndBlocks() { items = new ItemRegistryLepidopterology(); - - ForestryBlock.lepidopterology.registerBlock(new BlockBase(true), ItemBlockForestry.class, "lepidopterology"); - ForestryBlock.lepidopterology.block().setCreativeTab(Tabs.tabLepidopterology); + blocks = new BlockRegistryLepidopterology(); } @Override @@ -88,10 +83,9 @@ public class PluginLepidopterology extends ForestryPlugin { ButterflyBranchDefinition.createAlleles(); AlleleButterflyEffect.createAlleles(); - BlockBase lepidopterology = ((BlockBase) ForestryBlock.lepidopterology.block()); - MachineDefinition definitionChest = new MachineDefinition(Constants.DEFINITION_LEPICHEST_META, "forestry.LepiChest", TileLepidopteristChest.class, Proxies.render.getRenderChest("lepichest")) + MachineDefinition definitionChest = new MachineDefinition(BlockLepidopterologyType.LEPICHEST) .setBoundingBox(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); - lepidopterology.addDefinition(definitionChest); + blocks.lepidopterology.addDefinition(definitionChest); } @Override @@ -114,7 +108,7 @@ public class PluginLepidopterology extends ForestryPlugin { MothDefinition.initMoths(); ButterflyDefinition.initButterflies(); - ((BlockBase) ForestryBlock.lepidopterology.block()).init(); + blocks.lepidopterology.init(); TreeManager.treeRoot.registerLeafTickHandler(new ButterflySpawner()); @@ -140,7 +134,7 @@ public class PluginLepidopterology extends ForestryPlugin { "X#X", "X#X", "RDR", '#', "paneGlass", 'X', "ingotBronze", 'R', "dustRedstone", 'D', "gemDiamond"); - RecipeUtil.addRecipe(ForestryBlock.lepidopterology.getItemStack(1, Constants.DEFINITION_LEPICHEST_META), + RecipeUtil.addRecipe(blocks.lepidopterology.get(BlockLepidopterologyType.LEPICHEST), " # ", "XYX", "XXX", diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 40befdeec..cebd4e7e4 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -60,7 +60,6 @@ import forestry.core.GuiHandlerBase; import forestry.core.IPickupHandler; import forestry.core.IResupplyHandler; import forestry.core.config.Constants; -import forestry.core.config.ForestryBlock; import forestry.core.config.LocalizedConfiguration; import forestry.core.fluids.Fluids; import forestry.core.items.ItemCrated; @@ -68,6 +67,8 @@ import forestry.core.recipes.RecipeUtil; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.StringUtil; +import forestry.lepidopterology.blocks.BlockLepidopterologyType; +import forestry.lepidopterology.blocks.BlockRegistryLepidopterology; import forestry.storage.BackpackDefinition; import forestry.storage.BackpackDefinition.BackpackDefinitionApiarist; import forestry.storage.BackpackDefinition.BackpackDefinitionLepidopterist; @@ -502,8 +503,9 @@ public class PluginStorage extends ForestryPlugin { addBackpackRecipe(items.apiaristBackpack, "stickWood", beeBlocks.apicultureChest); } - if (items.lepidopteristBackpack != null) { - ItemStack chest = ForestryBlock.lepidopterology.getItemStack(1, Constants.DEFINITION_LEPICHEST_META); + BlockRegistryLepidopterology butterflyBlocks = PluginLepidopterology.blocks; + if (items.lepidopteristBackpack != null && butterflyBlocks != null) { + ItemStack chest = butterflyBlocks.lepidopterology.get(BlockLepidopterologyType.LEPICHEST); addBackpackRecipe(items.lepidopteristBackpack, "stickWood", chest); }