diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 984316d65..2cc1132ca 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -45,12 +45,14 @@ import forestry.arboriculture.worldgen.BlockTypeLog; import forestry.arboriculture.worldgen.BlockTypeVanillaStairs; import forestry.arboriculture.worldgen.BlockTypeWood; import forestry.arboriculture.worldgen.BlockTypeWoodStairs; +import forestry.core.blocks.BlockCore; import forestry.core.config.Constants; import forestry.core.config.ForestryBlock; import forestry.core.worldgen.BlockType; import forestry.core.worldgen.BlockTypeTileForestry; import forestry.core.worldgen.IBlockType; import forestry.plugins.PluginApiculture; +import forestry.plugins.PluginCore; import forestry.plugins.PluginManager; public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { @@ -180,7 +182,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { // Escritoire if (random.nextInt(2) == 0) { - IBlockType escritoireBlock = new BlockTypeTileForestry(ForestryBlock.core, Constants.DEFINITION_ESCRITOIRE_META); + IBlockType escritoireBlock = new BlockTypeTileForestry(PluginCore.blocks.core, BlockCore.Type.ESCRITOIRE.ordinal()); escritoireBlock.setDirection(getRotatedDirection(ForgeDirection.EAST)); placeBlockAtCurrentPosition(world, escritoireBlock, 1, 1, 3, structBoundingBox); } diff --git a/src/main/java/forestry/core/blocks/BlockCore.java b/src/main/java/forestry/core/blocks/BlockCore.java new file mode 100644 index 000000000..5585120a6 --- /dev/null +++ b/src/main/java/forestry/core/blocks/BlockCore.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; + +public class BlockCore extends BlockBase { + public enum Type { + ANALYZER, + ESCRITOIRE; + } + + public BlockCore(Material material, boolean hasTESR) { + super(material, hasTESR); + } + + public ItemStack get(Type type, int amount) { + return new ItemStack(this, amount, type.ordinal()); + } +} diff --git a/src/main/java/forestry/core/blocks/BlockRegistry.java b/src/main/java/forestry/core/blocks/BlockRegistry.java new file mode 100644 index 000000000..87ab4d101 --- /dev/null +++ b/src/main/java/forestry/core/blocks/BlockRegistry.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.blocks; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.core.utils.StringUtil; +import forestry.plugins.PluginManager; + +public abstract class BlockRegistry { + public static T registerBlock(T block, Class itemClass, String name) { + if (PluginManager.getStage() != PluginManager.Stage.SETUP) { + throw new RuntimeException("Tried to register Block outside of Setup"); + } + block.setBlockName("for." + name); + GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); + return block; + } +} diff --git a/src/main/java/forestry/core/blocks/BlockRegistryCore.java b/src/main/java/forestry/core/blocks/BlockRegistryCore.java new file mode 100644 index 000000000..9464e5c53 --- /dev/null +++ b/src/main/java/forestry/core/blocks/BlockRegistryCore.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.core.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; + +import net.minecraftforge.oredict.OreDictionary; + +import forestry.core.items.ItemBlockForestry; +import forestry.core.items.ItemBlockTyped; + +public class BlockRegistryCore extends BlockRegistry { + public final BlockCore core; + public final BlockSoil soil; + public final BlockResourceOre resources; + public final BlockResourceStorage resourceStorage; + + public BlockRegistryCore() { + core = registerBlock(new BlockCore(Material.iron, true), ItemBlockForestry.class, "core"); + + soil = registerBlock(new BlockSoil(), ItemBlockTyped.class, "soil"); + soil.setHarvestLevel("shovel", 0, 0); + soil.setHarvestLevel("shovel", 0, 1); + + resources = registerBlock(new BlockResourceOre(), ItemBlockForestry.class, "resources"); + resources.setHarvestLevel("pickaxe", 1); + OreDictionary.registerOre("oreApatite", resources.get(BlockResourceOre.ResourceType.APATITE, 1)); + OreDictionary.registerOre("oreCopper", resources.get(BlockResourceOre.ResourceType.COPPER, 1)); + OreDictionary.registerOre("oreTin", resources.get(BlockResourceOre.ResourceType.TIN, 1)); + + resourceStorage = registerBlock(new BlockResourceStorage(), ItemBlockForestry.class, "resourceStorage"); + resourceStorage.setHarvestLevel("pickaxe", 0); + OreDictionary.registerOre("blockApatite", resourceStorage.get(BlockResourceStorage.ResourceType.APATITE, 1)); + OreDictionary.registerOre("blockCopper", resourceStorage.get(BlockResourceStorage.ResourceType.COPPER, 1)); + OreDictionary.registerOre("blockTin", resourceStorage.get(BlockResourceStorage.ResourceType.TIN, 1)); + OreDictionary.registerOre("blockBronze", resourceStorage.get(BlockResourceStorage.ResourceType.BRONZE, 1)); + + // register some common oreDict names for our recipes + OreDictionary.registerOre("chestWood", Blocks.chest); + OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); + } +} diff --git a/src/main/java/forestry/core/blocks/BlockResourceOre.java b/src/main/java/forestry/core/blocks/BlockResourceOre.java index ec0d9ebdc..88a39b054 100644 --- a/src/main/java/forestry/core/blocks/BlockResourceOre.java +++ b/src/main/java/forestry/core/blocks/BlockResourceOre.java @@ -31,6 +31,17 @@ import forestry.core.render.TextureManager; import forestry.plugins.PluginCore; public class BlockResourceOre extends Block { + public enum ResourceType { + APATITE, + COPPER, + TIN; + + public static final ResourceType[] VALUES = values(); + + @SideOnly(Side.CLIENT) + public IIcon icon; + } + public BlockResourceOre() { super(Material.rock); setHardness(3F); @@ -51,7 +62,7 @@ public class BlockResourceOre extends Block { public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList drops = new ArrayList<>(); - if (metadata == 0) { + if (metadata == ResourceType.APATITE.ordinal()) { int fortuneModifier = world.rand.nextInt(fortune + 2) - 1; if (fortuneModifier < 0) { fortuneModifier = 0; @@ -82,39 +93,32 @@ public class BlockResourceOre extends Block { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - itemList.add(new ItemStack(this, 1, 0)); - itemList.add(new ItemStack(this, 1, 1)); - itemList.add(new ItemStack(this, 1, 2)); - } - - /* ICONS */ - @SideOnly(Side.CLIENT) - private IIcon iconApatite; - @SideOnly(Side.CLIENT) - private IIcon iconCopper; - @SideOnly(Side.CLIENT) - private IIcon iconTin; - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) { - iconApatite = TextureManager.registerTex(register, "ores/apatite"); - iconCopper = TextureManager.registerTex(register, "ores/copper"); - iconTin = TextureManager.registerTex(register, "ores/tin"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int i, int j) { - if (j == 0) { - return iconApatite; - } else if (j == 1) { - return iconCopper; - } else if (j == 2) { - return iconTin; - } else { - return null; + for (ResourceType resourceType : ResourceType.values()) { + ItemStack stack = get(resourceType, 1); + itemList.add(stack); } } + /* ICONS */ + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + ResourceType.APATITE.icon = TextureManager.registerTex(register, "ores/apatite"); + ResourceType.COPPER.icon = TextureManager.registerTex(register, "ores/copper"); + ResourceType.TIN.icon = TextureManager.registerTex(register, "ores/tin"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int i, int meta) { + if (meta < 0 || meta >= ResourceType.VALUES.length) { + return null; + } + + return ResourceType.VALUES[meta].icon; + } + + public ItemStack get(ResourceType type, int amount) { + return new ItemStack(this, amount, type.ordinal()); + } } diff --git a/src/main/java/forestry/core/blocks/BlockResourceStorage.java b/src/main/java/forestry/core/blocks/BlockResourceStorage.java index 690025d16..3cafed86b 100644 --- a/src/main/java/forestry/core/blocks/BlockResourceStorage.java +++ b/src/main/java/forestry/core/blocks/BlockResourceStorage.java @@ -17,30 +17,32 @@ import forestry.core.CreativeTabForestry; import forestry.core.render.TextureManager; public class BlockResourceStorage extends Block { - + public enum ResourceType { + APATITE, + COPPER, + TIN, + BRONZE; + + public static final ResourceType[] VALUES = values(); + + @SideOnly(Side.CLIENT) + public IIcon icon; + } + public BlockResourceStorage() { super(Material.iron); setHardness(3F); setResistance(5F); setCreativeTab(CreativeTabForestry.tabForestry); } - - @SideOnly(Side.CLIENT) - private IIcon iconApatite; - @SideOnly(Side.CLIENT) - private IIcon iconCopper; - @SideOnly(Side.CLIENT) - private IIcon iconTin; - @SideOnly(Side.CLIENT) - private IIcon iconBronze; @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs creativeTabs, List itemList) { - itemList.add(new ItemStack(this, 1, 0)); - itemList.add(new ItemStack(this, 1, 1)); - itemList.add(new ItemStack(this, 1, 2)); - itemList.add(new ItemStack(this, 1, 3)); + for (ResourceType resourceType : ResourceType.values()) { + ItemStack stack = get(resourceType, 1); + itemList.add(stack); + } } @Override @@ -51,27 +53,23 @@ public class BlockResourceStorage extends Block { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) { - iconApatite = TextureManager.registerTex(register, "storage/apatite"); - iconCopper = TextureManager.registerTex(register, "storage/copper"); - iconTin = TextureManager.registerTex(register, "storage/tin"); - iconBronze = TextureManager.registerTex(register, "storage/bronze"); + ResourceType.APATITE.icon = TextureManager.registerTex(register, "storage/apatite"); + ResourceType.COPPER.icon = TextureManager.registerTex(register, "storage/copper"); + ResourceType.TIN.icon = TextureManager.registerTex(register, "storage/tin"); + ResourceType.BRONZE.icon = TextureManager.registerTex(register, "storage/bronze"); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int meta) { - IIcon icon; - if (meta == 0) { - icon = iconApatite; - } else if (meta == 1) { - icon = iconCopper; - } else if (meta == 2) { - icon = iconTin; - } else { - icon = iconBronze; + if (meta < 0 || meta >= ResourceType.VALUES.length) { + return null; } - - return icon; + + return ResourceType.VALUES[meta].icon; } + public ItemStack get(ResourceType type, int amount) { + return new ItemStack(this, amount, type.ordinal()); + } } diff --git a/src/main/java/forestry/core/blocks/BlockSoil.java b/src/main/java/forestry/core/blocks/BlockSoil.java index 46591a050..1df5af42d 100644 --- a/src/main/java/forestry/core/blocks/BlockSoil.java +++ b/src/main/java/forestry/core/blocks/BlockSoil.java @@ -273,4 +273,7 @@ public class BlockSoil extends Block implements IItemTyped { return null; } + public ItemStack get(SoilType soilType, int amount) { + return new ItemStack(this, amount, soilType.ordinal()); + } } diff --git a/src/main/java/forestry/core/config/Constants.java b/src/main/java/forestry/core/config/Constants.java index c0f07844c..a93aac80d 100644 --- a/src/main/java/forestry/core/config/Constants.java +++ b/src/main/java/forestry/core/config/Constants.java @@ -51,9 +51,6 @@ public class Constants implements IForestryConstants { public static final String CHEST_GEN_HOOK_NATURALIST_CHEST = "naturalistChest"; // Definition IDs - public static final int DEFINITION_ANALYZER_META = 0; - public static final int DEFINITION_ESCRITOIRE_META = 1; - public static final int DEFINITION_APIARY_META = 0; public static final int DEFINITION_APIARISTCHEST_LEGACY_META = 1; public static final int DEFINITION_BEEHOUSE_META = 2; diff --git a/src/main/java/forestry/core/config/ForestryBlock.java b/src/main/java/forestry/core/config/ForestryBlock.java index 184dafa3f..916524e72 100755 --- a/src/main/java/forestry/core/config/ForestryBlock.java +++ b/src/main/java/forestry/core/config/ForestryBlock.java @@ -34,16 +34,6 @@ import forestry.plugins.PluginManager.Stage; * @author SirSengir */ public enum ForestryBlock { - - /** - * 0 - Humus 1 - Bog Earth - */ - soil, - /** - * 0 - Apatite Ore 1 - Copper Ore 2 - Tin Ore - */ - resources, - resourceStorage, /** * 0 - Legacy 1 - Forest Hive 2 - Meadows Hive */ @@ -69,7 +59,6 @@ public enum ForestryBlock { arboriculture, alveary, farm, - core, apiculture, apicultureChest, mail, diff --git a/src/main/java/forestry/core/config/GameMode.java b/src/main/java/forestry/core/config/GameMode.java index 8e55f9d65..f88d2e6e5 100644 --- a/src/main/java/forestry/core/config/GameMode.java +++ b/src/main/java/forestry/core/config/GameMode.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack; import forestry.Forestry; import forestry.api.core.IGameMode; +import forestry.core.blocks.BlockSoil; import forestry.core.utils.Log; import forestry.plugins.PluginCore; import forestry.plugins.PluginFluids; @@ -43,11 +44,11 @@ public class GameMode implements IGameMode { private final ItemStack recipeCompostOutputWheat = PluginCore.items.fertilizerBio.getItemStack(4); private final ItemStack recipeCompostOutputAsh = PluginCore.items.fertilizerBio.getItemStack(1); - private final ItemStack recipeHumusOutputFertilizer = ForestryBlock.soil.getItemStack(8); - private final ItemStack recipeHumusOutputCompost = ForestryBlock.soil.getItemStack(8); + private final ItemStack recipeHumusOutputFertilizer = PluginCore.blocks.soil.get(BlockSoil.SoilType.HUMUS, 8); + private final ItemStack recipeHumusOutputCompost = PluginCore.blocks.soil.get(BlockSoil.SoilType.HUMUS, 8); - private final ItemStack recipeBogEarthOutputBucket = ForestryBlock.soil.getItemStack(6, 1); - private final ItemStack recipeBogEarthOutputCans = ForestryBlock.soil.getItemStack(8, 1); + private final ItemStack recipeBogEarthOutputBucket = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 6); + private final ItemStack recipeBogEarthOutputCans = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 8); private final ItemStack recipeCanOutput = PluginFluids.items.canEmpty.getItemStack(12); private final ItemStack recipeCapsuleOutput = PluginFluids.items.waxCapsuleEmpty.getItemStack(4); diff --git a/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java index 460941546..1f2ca2ad0 100644 --- a/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java +++ b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java @@ -26,7 +26,11 @@ public class BlockTypeTileForestry implements IBlockType { private ForgeDirection direction; public BlockTypeTileForestry(ForestryBlock forestryBlock, int meta) { - this.block = forestryBlock.block(); + this(forestryBlock.block(), meta); + } + + public BlockTypeTileForestry(Block block, int meta) { + this.block = block; this.meta = meta; } diff --git a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java index 17f156e9b..1f5d14f7f 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java +++ b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java @@ -19,7 +19,6 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import forestry.core.config.Constants; -import forestry.core.config.ForestryBlock; public class WorldGenMinableMeta extends WorldGenerator { @@ -27,8 +26,8 @@ public class WorldGenMinableMeta extends WorldGenerator { private final int mineableBlockMeta; private final int numberOfBlocks; - public WorldGenMinableMeta(ForestryBlock block, int meta, int numberOfBlocks) { - mineableBlock = block.block(); + public WorldGenMinableMeta(Block block, int meta, int numberOfBlocks) { + mineableBlock = block; mineableBlockMeta = meta; this.numberOfBlocks = numberOfBlocks; } diff --git a/src/main/java/forestry/core/worldgen/WorldGenerator.java b/src/main/java/forestry/core/worldgen/WorldGenerator.java index 365dfb73d..f95632995 100644 --- a/src/main/java/forestry/core/worldgen/WorldGenerator.java +++ b/src/main/java/forestry/core/worldgen/WorldGenerator.java @@ -21,8 +21,9 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent; import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import forestry.core.blocks.BlockResourceOre; import forestry.core.config.Config; -import forestry.core.config.ForestryBlock; +import forestry.plugins.PluginCore; import forestry.plugins.PluginManager; public class WorldGenerator implements IWorldGenerator { @@ -55,9 +56,9 @@ public class WorldGenerator implements IWorldGenerator { private void generateWorld(Random random, int chunkX, int chunkZ, World world) { if (apatiteGenerator == null) { - apatiteGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 0, 36); - copperGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 1, 6); - tinGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 2, 6); + apatiteGenerator = new WorldGenMinableMeta(PluginCore.blocks.resources, BlockResourceOre.ResourceType.APATITE.ordinal(), 36); + copperGenerator = new WorldGenMinableMeta(PluginCore.blocks.resources, BlockResourceOre.ResourceType.COPPER.ordinal(), 6); + tinGenerator = new WorldGenMinableMeta(PluginCore.blocks.resources, BlockResourceOre.ResourceType.TIN.ordinal(), 6); } // shift to world coordinates diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index eb2391884..b6cbe9217 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -34,10 +34,10 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.blocks.BlockSoil; -import forestry.core.config.ForestryBlock; import forestry.core.render.SpriteSheet; import forestry.core.utils.vect.Vect; import forestry.core.utils.vect.VectUtil; +import forestry.plugins.PluginCore; public class FarmLogicArboreal extends FarmLogicHomogeneous { @@ -46,7 +46,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { } public FarmLogicArboreal(IFarmHousing housing) { - super(housing, new ItemStack(Blocks.dirt), ForestryBlock.soil.getItemStack(1, 0), Farmables.farmables.get("farmArboreal")); + super(housing, new ItemStack(Blocks.dirt), PluginCore.blocks.soil.get(BlockSoil.SoilType.HUMUS, 1), Farmables.farmables.get("farmArboreal")); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 7eb88f285..c877b7eff 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -25,15 +25,15 @@ import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.blocks.BlockSoil; -import forestry.core.config.ForestryBlock; import forestry.core.utils.vect.Vect; import forestry.core.utils.vect.VectUtil; import forestry.plugins.PluginCore; public class FarmLogicPeat extends FarmLogicWatered { + private static final ItemStack bogEarth = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 1); public FarmLogicPeat(IFarmHousing housing) { - super(housing, ForestryBlock.soil.getItemStack(1, 1), ForestryBlock.soil.getItemStack(1, 1)); + super(housing, bogEarth, bogEarth); } @Override diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 78ac3c528..eabdd89e2 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -113,6 +113,7 @@ import forestry.apiculture.worldgen.HiveRegistry; import forestry.core.GuiHandlerBase; import forestry.core.ISaveEventHandler; import forestry.core.blocks.BlockBase; +import forestry.core.blocks.BlockCore; import forestry.core.config.Config; import forestry.core.config.Constants; import forestry.core.config.ForestryBlock; @@ -768,7 +769,7 @@ public class PluginApiculture extends ForestryPlugin { } // ANALYZER - PluginCore.definitionAnalyzer.recipes.add(ShapedRecipeCustom.createShapedRecipe(new ItemStack(ForestryBlock.core.block(), 1, Constants.DEFINITION_ANALYZER_META), + PluginCore.definitionAnalyzer.recipes.add(ShapedRecipeCustom.createShapedRecipe(PluginCore.blocks.core.get(BlockCore.Type.ANALYZER, 1), "XTX", " Y ", "X X", diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 25eb32f31..36c05d279 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -73,6 +73,7 @@ import forestry.arboriculture.tiles.TileSapling; import forestry.arboriculture.tiles.TileWood; import forestry.core.GuiHandlerBase; import forestry.core.blocks.BlockBase; +import forestry.core.blocks.BlockCoreType; import forestry.core.config.Config; import forestry.core.config.Constants; import forestry.core.config.ForestryBlock; @@ -383,7 +384,7 @@ public class PluginArboriculture extends ForestryPlugin { '#', "stickWood"); // ANALYZER - PluginCore.definitionAnalyzer.recipes.add(ShapedRecipeCustom.createShapedRecipe(new ItemStack(ForestryBlock.core.block(), 1, Constants.DEFINITION_ANALYZER_META), + PluginCore.definitionAnalyzer.recipes.add(ShapedRecipeCustom.createShapedRecipe(PluginCore.blocks.core.get(BlockCore.Type.ANALYZER, 1), "XTX", " Y ", "X X", diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index 9a938d245..f9147680b 100644 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -12,7 +12,6 @@ package forestry.plugins; import java.util.ArrayList; -import net.minecraft.block.material.Material; import net.minecraft.command.ICommand; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -34,7 +33,8 @@ import forestry.core.IPickupHandler; import forestry.core.ISaveEventHandler; import forestry.core.PickupHandlerCore; import forestry.core.SaveEventHandlerCore; -import forestry.core.blocks.BlockBase; +import forestry.core.blocks.BlockCore; +import forestry.core.blocks.BlockRegistryCore; import forestry.core.blocks.BlockResourceOre; import forestry.core.blocks.BlockResourceStorage; import forestry.core.blocks.BlockSoil; @@ -45,14 +45,11 @@ import forestry.core.commands.CommandVersion; import forestry.core.commands.RootCommand; import forestry.core.config.Config; import forestry.core.config.Constants; -import forestry.core.config.ForestryBlock; import forestry.core.fluids.Fluids; import forestry.core.genetics.alleles.AlleleFactory; import forestry.core.genetics.alleles.AlleleHelper; import forestry.core.genetics.alleles.AlleleRegistry; import forestry.core.items.EnumContainerType; -import forestry.core.items.ItemBlockForestry; -import forestry.core.items.ItemBlockTyped; import forestry.core.items.ItemRegistryCore; import forestry.core.multiblock.MultiblockLogicFactory; import forestry.core.network.IPacketRegistry; @@ -74,6 +71,7 @@ public class PluginCore extends ForestryPlugin { public static final RootCommand rootCommand = new RootCommand(); public static ItemRegistryCore items; + public static BlockRegistryCore blocks; static MachineDefinition definitionAnalyzer; @Override @@ -98,28 +96,7 @@ public class PluginCore extends ForestryPlugin { @Override protected void registerItemsAndBlocks() { items = new ItemRegistryCore(); - - ForestryBlock.core.registerBlock(new BlockBase(Material.iron, true), ItemBlockForestry.class, "core"); - - ForestryBlock.soil.registerBlock(new BlockSoil(), ItemBlockTyped.class, "soil"); - ForestryBlock.soil.block().setHarvestLevel("shovel", 0, 0); - ForestryBlock.soil.block().setHarvestLevel("shovel", 0, 1); - - ForestryBlock.resources.registerBlock(new BlockResourceOre(), ItemBlockForestry.class, "resources"); - ForestryBlock.resources.block().setHarvestLevel("pickaxe", 1); - OreDictionary.registerOre("oreApatite", ForestryBlock.resources.getItemStack(1, 0)); - OreDictionary.registerOre("oreCopper", ForestryBlock.resources.getItemStack(1, 1)); - OreDictionary.registerOre("oreTin", ForestryBlock.resources.getItemStack(1, 2)); - - ForestryBlock.resourceStorage.registerBlock(new BlockResourceStorage(), ItemBlockForestry.class, "resourceStorage"); - ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0); - OreDictionary.registerOre("blockApatite", ForestryBlock.resourceStorage.getItemStack(1, 0)); - OreDictionary.registerOre("blockCopper", ForestryBlock.resourceStorage.getItemStack(1, 1)); - OreDictionary.registerOre("blockTin", ForestryBlock.resourceStorage.getItemStack(1, 2)); - OreDictionary.registerOre("blockBronze", ForestryBlock.resourceStorage.getItemStack(1, 3)); - - OreDictionary.registerOre("chestWood", Blocks.chest); - OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); + blocks = new BlockRegistryCore(); } @Override @@ -129,10 +106,10 @@ public class PluginCore extends ForestryPlugin { rootCommand.addChildCommand(new CommandVersion()); rootCommand.addChildCommand(new CommandPlugins()); - definitionEscritoire = ((BlockBase) ForestryBlock.core.block()).addDefinition(new MachineDefinition(Constants.DEFINITION_ESCRITOIRE_META, "forestry.Escritoire", TileEscritoire.class, + definitionEscritoire = blocks.core.addDefinition(new MachineDefinition(BlockCore.Type.ESCRITOIRE.ordinal(), "forestry.Escritoire", TileEscritoire.class, Proxies.render.getRenderEscritoire())); - definitionAnalyzer = ((BlockBase) ForestryBlock.core.block()).addDefinition(new MachineDefinition(Constants.DEFINITION_ANALYZER_META, "forestry.Analyzer", TileAnalyzer.class, + definitionAnalyzer = blocks.core.addDefinition(new MachineDefinition(BlockCore.Type.ANALYZER.ordinal(), "forestry.Analyzer", TileAnalyzer.class, PluginApiculture.proxy.getRendererAnalyzer(Constants.TEXTURE_PATH_BLOCKS + "/analyzer_"))); } @@ -189,8 +166,8 @@ public class PluginCore extends ForestryPlugin { crateRegistry.registerCrateUsingOreDict(items.ingotBronze, "cratedBronze"); // forestry blocks - crateRegistry.registerCrate(ForestryBlock.soil.getItemStack(1, 0), "cratedHumus"); - crateRegistry.registerCrate(ForestryBlock.soil.getItemStack(1, 1), "cratedBogearth"); + crateRegistry.registerCrate(blocks.soil.get(BlockSoil.SoilType.HUMUS, 1), "cratedHumus"); + crateRegistry.registerCrate(blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 1), "cratedBogearth"); // vanilla items crateRegistry.registerCrate(Items.wheat, "cratedWheat"); @@ -242,9 +219,9 @@ public class PluginCore extends ForestryPlugin { protected void registerRecipes() { /* SMELTING RECIPES */ - RecipeUtil.addSmelting(ForestryBlock.resources.getItemStack(1, 0), items.apatite, 0.5f); - RecipeUtil.addSmelting(ForestryBlock.resources.getItemStack(1, 1), items.ingotCopper, 0.5f); - RecipeUtil.addSmelting(ForestryBlock.resources.getItemStack(1, 2), items.ingotTin, 0.5f); + RecipeUtil.addSmelting(blocks.resources.get(BlockResourceOre.ResourceType.APATITE, 1), items.apatite, 0.5f); + RecipeUtil.addSmelting(blocks.resources.get(BlockResourceOre.ResourceType.COPPER, 1), items.ingotCopper, 0.5f); + RecipeUtil.addSmelting(blocks.resources.get(BlockResourceOre.ResourceType.TIN, 1), items.ingotTin, 0.5f); RecipeUtil.addSmelting(new ItemStack(items.peat), items.ash, 0.0f); /* BRONZE INGOTS */ @@ -325,16 +302,16 @@ public class PluginCore extends ForestryPlugin { RecipeUtil.addRecipe(items.pipette, " #", " X ", "X ", 'X', "paneGlass", '#', new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)); // Storage Blocks - RecipeUtil.addRecipe(ForestryBlock.resourceStorage.getItemStack(1, 0), "###", "###", "###", '#', "gemApatite"); + RecipeUtil.addRecipe(blocks.resourceStorage.get(BlockResourceStorage.ResourceType.APATITE, 1), "###", "###", "###", '#', "gemApatite"); RecipeUtil.addShapelessRecipe(new ItemStack(items.apatite, 9), "blockApatite"); - RecipeUtil.addRecipe(ForestryBlock.resourceStorage.getItemStack(1, 1), "###", "###", "###", '#', "ingotCopper"); + RecipeUtil.addRecipe(blocks.resourceStorage.get(BlockResourceStorage.ResourceType.COPPER, 1), "###", "###", "###", '#', "ingotCopper"); RecipeUtil.addShapelessRecipe(new ItemStack(items.ingotCopper, 9), "blockCopper"); - RecipeUtil.addRecipe(ForestryBlock.resourceStorage.getItemStack(1, 2), "###", "###", "###", '#', "ingotTin"); + RecipeUtil.addRecipe(blocks.resourceStorage.get(BlockResourceStorage.ResourceType.TIN, 1), "###", "###", "###", '#', "ingotTin"); RecipeUtil.addShapelessRecipe(new ItemStack(items.ingotTin, 9), "blockTin"); - RecipeUtil.addRecipe(ForestryBlock.resourceStorage.getItemStack(1, 3), "###", "###", "###", '#', "ingotBronze"); + RecipeUtil.addRecipe(blocks.resourceStorage.get(BlockResourceStorage.ResourceType.BRONZE, 1), "###", "###", "###", '#', "ingotBronze"); RecipeUtil.addShapelessRecipe(new ItemStack(items.ingotBronze, 9), "blockBronze"); } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index b63085753..c5176dd7e 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -35,6 +35,8 @@ import forestry.api.recipes.RecipeManagers; import forestry.apiculture.items.ItemRegistryApiculture; import forestry.core.GuiHandlerBase; import forestry.core.blocks.BlockBase; +import forestry.core.blocks.BlockCore; +import forestry.core.blocks.BlockSoil; import forestry.core.circuits.Circuit; import forestry.core.circuits.CircuitLayout; import forestry.core.circuits.EnumCircuitBoardType; @@ -463,7 +465,7 @@ public class PluginFactory extends ForestryPlugin { "###", '#', "logWood"); RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.getFluid(500), null, - ForestryBlock.core.getItemStack(1, Constants.DEFINITION_ESCRITOIRE_META), + PluginCore.blocks.core.get(BlockCore.Type.ESCRITOIRE, 1), "# ", "###", "# #", @@ -485,14 +487,14 @@ public class PluginFactory extends ForestryPlugin { "#", '#', "pulpWood"); RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, - ForestryBlock.soil.getItemStack(9), + PluginCore.blocks.soil.get(BlockSoil.SoilType.HUMUS, 9), "###", "#X#", "###", '#', Blocks.dirt, 'X', PluginCore.items.mulch); RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, - ForestryBlock.soil.getItemStack(8, 1), + PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 8), "#X#", "XYX", "#X#", '#', Blocks.dirt,