diff --git a/buildcraft_resources/changelog/7.1.4 b/buildcraft_resources/changelog/7.1.4 index b8715582..040a7c35 100644 --- a/buildcraft_resources/changelog/7.1.4 +++ b/buildcraft_resources/changelog/7.1.4 @@ -1,6 +1,7 @@ Additions: * Config option to disable showing every facade in Creative/NEI (asie) +* Objects.cfg, a config file letting you enable/disable almost any block and item in BuildCraft individually! (asie) Improvements: diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 3458ab2f..cf94d2ca 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -120,6 +120,7 @@ import buildcraft.builders.schematics.SchematicSkull; import buildcraft.builders.schematics.SchematicStone; import buildcraft.builders.schematics.SchematicTripWireHook; import buildcraft.builders.statements.BuildersActionProvider; +import buildcraft.core.BCRegistry; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -493,45 +494,43 @@ public class BuildCraftBuilders extends BuildCraftMod { public void preInit(FMLPreInitializationEvent evt) { templateItem = new ItemBlueprintTemplate(); templateItem.setUnlocalizedName("templateItem"); - CoreProxy.proxy.registerItem(templateItem); + BCRegistry.INSTANCE.registerItem(templateItem, false); blueprintItem = new ItemBlueprintStandard(); blueprintItem.setUnlocalizedName("blueprintItem"); - CoreProxy.proxy.registerItem(blueprintItem); + BCRegistry.INSTANCE.registerItem(blueprintItem, false); quarryBlock = (BlockQuarry) CompatHooks.INSTANCE.getBlock(BlockQuarry.class); - CoreProxy.proxy.registerBlock(quarryBlock.setBlockName("machineBlock")); + BCRegistry.INSTANCE.registerBlock(quarryBlock.setBlockName("machineBlock"), false); fillerBlock = (BlockFiller) CompatHooks.INSTANCE.getBlock(BlockFiller.class); - CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock")); + BCRegistry.INSTANCE.registerBlock(fillerBlock.setBlockName("fillerBlock"), false); frameBlock = new BlockFrame(); - CoreProxy.proxy.registerBlock(frameBlock.setBlockName("frameBlock")); + BCRegistry.INSTANCE.registerBlock(frameBlock.setBlockName("frameBlock"), true); builderBlock = (BlockBuilder) CompatHooks.INSTANCE.getBlock(BlockBuilder.class); - CoreProxy.proxy.registerBlock(builderBlock.setBlockName("builderBlock")); + BCRegistry.INSTANCE.registerBlock(builderBlock.setBlockName("builderBlock"), false); architectBlock = (BlockArchitect) CompatHooks.INSTANCE.getBlock(BlockArchitect.class); - CoreProxy.proxy.registerBlock(architectBlock.setBlockName("architectBlock")); + BCRegistry.INSTANCE.registerBlock(architectBlock.setBlockName("architectBlock"), false); libraryBlock = (BlockBlueprintLibrary) CompatHooks.INSTANCE.getBlock(BlockBlueprintLibrary.class); - CoreProxy.proxy.registerBlock(libraryBlock.setBlockName("libraryBlock")); + BCRegistry.INSTANCE.registerBlock(libraryBlock.setBlockName("libraryBlock"), false); - CoreProxy.proxy.registerTileEntity(TileQuarry.class, "Machine"); - CoreProxy.proxy.registerTileEntity(TileMarker.class, "Marker"); - CoreProxy.proxy.registerTileEntity(TileFiller.class, "Filler"); - CoreProxy.proxy.registerTileEntity(TileBuilder.class, "net.minecraft.src.builders.TileBuilder"); - CoreProxy.proxy.registerTileEntity(TileArchitect.class, "net.minecraft.src.builders.TileTemplate"); - CoreProxy.proxy.registerTileEntity(TilePathMarker.class, "net.minecraft.src.builders.TilePathMarker"); - CoreProxy.proxy.registerTileEntity(TileBlueprintLibrary.class, "net.minecraft.src.builders.TileBlueprintLibrary"); + BCRegistry.INSTANCE.registerTileEntity(TileQuarry.class, "Machine"); + BCRegistry.INSTANCE.registerTileEntity(TileMarker.class, "Marker"); + BCRegistry.INSTANCE.registerTileEntity(TileFiller.class, "Filler"); + BCRegistry.INSTANCE.registerTileEntity(TileBuilder.class, "net.minecraft.src.builders.TileBuilder"); + BCRegistry.INSTANCE.registerTileEntity(TileArchitect.class, "net.minecraft.src.builders.TileTemplate"); + BCRegistry.INSTANCE.registerTileEntity(TilePathMarker.class, "net.minecraft.src.builders.TilePathMarker"); + BCRegistry.INSTANCE.registerTileEntity(TileBlueprintLibrary.class, "net.minecraft.src.builders.TileBlueprintLibrary"); - if (Loader.isModLoaded("BuildCraft|Robotics")) { - constructionMarkerBlock = (BlockConstructionMarker) CompatHooks.INSTANCE.getBlock(BlockConstructionMarker.class); - CoreProxy.proxy.registerBlock(constructionMarkerBlock.setBlockName("constructionMarkerBlock"), - ItemConstructionMarker.class); + constructionMarkerBlock = (BlockConstructionMarker) CompatHooks.INSTANCE.getBlock(BlockConstructionMarker.class); + BCRegistry.INSTANCE.registerBlock(constructionMarkerBlock.setBlockName("constructionMarkerBlock"), + ItemConstructionMarker.class, false); - CoreProxy.proxy.registerTileEntity(TileConstructionMarker.class, "net.minecraft.src.builders.TileConstructionMarker"); - } + BCRegistry.INSTANCE.registerTileEntity(TileConstructionMarker.class, "net.minecraft.src.builders.TileConstructionMarker"); SchematicRegistry.INSTANCE.readConfiguration(BuildCraftCore.mainConfiguration); @@ -546,7 +545,7 @@ public class BuildCraftBuilders extends BuildCraftMod { } public static void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe( + BCRegistry.INSTANCE.addCraftingRecipe( new ItemStack(quarryBlock), "ipi", "gig", @@ -557,31 +556,31 @@ public class BuildCraftBuilders extends BuildCraftMod { 'd', "gearDiamond", 'D', Items.diamond_pickaxe); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), "ppp", "pip", "ppp", 'i', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(templateItem, 1), "ppp", "pip", "ppp", 'i', "dyeBlack", 'p', Items.paper); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), "ppp", "pip", "ppp", 'i', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(blueprintItem, 1), "ppp", "pip", "ppp", 'i', "gemLapis", 'p', Items.paper); if (constructionMarkerBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(constructionMarkerBlock, 1), "l ", "r ", 'l', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(constructionMarkerBlock, 1), "l ", "r ", 'l', "gearGold", 'r', Blocks.redstone_torch); } - CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), "btb", "ycy", "gCg", 'b', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(fillerBlock, 1), "btb", "ycy", "gCg", 'b', "dyeBlack", 't', BuildCraftCore.markerBlock, 'y', "dyeYellow", 'c', Blocks.crafting_table, 'g', "gearGold", 'C', Blocks.chest); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), "btb", "ycy", "gCg", 'b', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(builderBlock, 1), "btb", "ycy", "gCg", 'b', "dyeBlack", 't', BuildCraftCore.markerBlock, 'y', "dyeYellow", 'c', Blocks.crafting_table, 'g', "gearDiamond", 'C', Blocks.chest); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), "btb", "ycy", "gCg", 'b', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(architectBlock, 1), "btb", "ycy", "gCg", 'b', "dyeBlack", 't', BuildCraftCore.markerBlock, 'y', "dyeYellow", 'c', Blocks.crafting_table, 'g', "gearDiamond", 'C', new ItemStack(blueprintItem, 1)); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), "igi", "bBb", "iri", 'B', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(libraryBlock, 1), "igi", "bBb", "iri", 'B', new ItemStack(blueprintItem), 'b', Blocks.bookshelf, 'i', "ingotIron", 'g', "gearIron", 'r', Items.redstone); } diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 2e8fd59a..cbace392 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -67,6 +67,7 @@ import buildcraft.api.tablet.TabletAPI; import buildcraft.api.tiles.IControllable; import buildcraft.core.AchievementManager; import buildcraft.core.BCCreativeTab; +import buildcraft.core.BCRegistry; import buildcraft.core.BlockBuildTool; import buildcraft.core.BlockEngine; import buildcraft.core.BlockMarker; @@ -283,6 +284,8 @@ public class BuildCraftCore extends BuildCraftMod { BuilderAPI.schematicRegistry = SchematicRegistry.INSTANCE; + BCRegistry.INSTANCE.setRegistryConfig(new File(evt.getModConfigurationDirectory(), "buildcraft/objects.cfg")); + mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.cfg")); mainConfigManager = new ConfigManager(mainConfiguration); mainConfiguration.load(); @@ -309,66 +312,71 @@ public class BuildCraftCore extends BuildCraftMod { reloadConfig(ConfigManager.RestartRequirement.GAME); wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem"); - CoreProxy.proxy.registerItem(wrenchItem); + BCRegistry.INSTANCE.registerItem(wrenchItem, false); mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation"); - CoreProxy.proxy.registerItem(mapLocationItem); + BCRegistry.INSTANCE.registerItem(mapLocationItem, false); listItem = (ItemList) (new ItemList()).setUnlocalizedName("list"); - CoreProxy.proxy.registerItem(listItem); + BCRegistry.INSTANCE.registerItem(listItem, false); debuggerItem = (new ItemDebugger()).setUnlocalizedName("debugger"); - CoreProxy.proxy.registerItem(debuggerItem); + BCRegistry.INSTANCE.registerItem(debuggerItem, false); if (BuildCraftCore.modifyWorld) { BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfigManager.get("worldgen.generateWaterSprings").getBoolean(); springBlock = new BlockSpring().setBlockName("eternalSpring"); - CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class); + BCRegistry.INSTANCE.registerBlock(springBlock, ItemSpring.class, false); } woodenGearItem = (new ItemGear()).setUnlocalizedName("woodenGearItem"); - CoreProxy.proxy.registerItem(woodenGearItem); - OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem)); + if (BCRegistry.INSTANCE.registerItem(woodenGearItem, false)) { + OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem)); + } stoneGearItem = (new ItemGear()).setUnlocalizedName("stoneGearItem"); - CoreProxy.proxy.registerItem(stoneGearItem); - OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem)); + if (BCRegistry.INSTANCE.registerItem(stoneGearItem, false)) { + OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem)); + } ironGearItem = (new ItemGear()).setUnlocalizedName("ironGearItem"); - CoreProxy.proxy.registerItem(ironGearItem); - OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem)); + if (BCRegistry.INSTANCE.registerItem(ironGearItem, false)) { + OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem)); + } goldGearItem = (new ItemGear()).setUnlocalizedName("goldGearItem"); - CoreProxy.proxy.registerItem(goldGearItem); - OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem)); + if (BCRegistry.INSTANCE.registerItem(goldGearItem, false)) { + OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem)); + } diamondGearItem = (new ItemGear()).setUnlocalizedName("diamondGearItem"); - CoreProxy.proxy.registerItem(diamondGearItem); - OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem)); + if (BCRegistry.INSTANCE.registerItem(diamondGearItem, false)) { + OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem)); + } paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush"); - CoreProxy.proxy.registerItem(paintbrushItem); + BCRegistry.INSTANCE.registerItem(paintbrushItem, false); if (DEVELOPER_MODE) { tabletItem = new ItemTablet(); tabletItem.setUnlocalizedName("tablet"); - CoreProxy.proxy.registerItem(tabletItem); + BCRegistry.INSTANCE.registerItem(tabletItem, false); } buildToolBlock = new BlockBuildTool(); buildToolBlock.setBlockName("buildToolBlock"); - CoreProxy.proxy.registerBlock(buildToolBlock); + BCRegistry.INSTANCE.registerBlock(buildToolBlock, true); engineBlock = (BlockEngine) CompatHooks.INSTANCE.getBlock(BlockEngine.class); - CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class); - engineBlock.registerTile((Class) CompatHooks.INSTANCE.getTile(TileEngineWood.class), "tile.engineWood", "buildcraftcore:engineWood"); - CoreProxy.proxy.registerTileEntity(TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood"); + BCRegistry.INSTANCE.registerBlock(engineBlock, ItemEngine.class, true); + engineBlock.registerTile((Class) CompatHooks.INSTANCE.getTile(TileEngineWood.class), 0, "tile.engineWood", "buildcraftcore:engineWood"); + BCRegistry.INSTANCE.registerTileEntity(TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood"); markerBlock = (BlockMarker) CompatHooks.INSTANCE.getBlock(BlockMarker.class); - CoreProxy.proxy.registerBlock(markerBlock.setBlockName("markerBlock")); + BCRegistry.INSTANCE.registerBlock(markerBlock.setBlockName("markerBlock"), false); pathMarkerBlock = (BlockPathMarker) CompatHooks.INSTANCE.getBlock(BlockPathMarker.class); - CoreProxy.proxy.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock")); + BCRegistry.INSTANCE.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock"), false); FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); @@ -477,6 +485,8 @@ public class BuildCraftCore extends BuildCraftMod { public void postInit(FMLPostInitializationEvent event) { BCLog.logger.info("BuildCraft's fake player: UUID = " + gameProfile.getId().toString() + ", name = '" + gameProfile.getName() + "'!"); + BCRegistry.INSTANCE.save(); + for (Object o : Block.blockRegistry) { Block block = (Block) o; @@ -625,35 +635,35 @@ public class BuildCraftCore extends BuildCraftMod { } public void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', "ingotIron", 'G', "gearStone"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', "ingotIron", 'G', "gearStone"); + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G', "gearWood"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', "ingotIron", 'G', "gearStone"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', "ingotGold", 'G', "gearIron"); - CoreProxy.proxy.addCraftingRecipe( + BCRegistry.INSTANCE.addCraftingRecipe( new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', "gemDiamond", 'G', "gearGold"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(mapLocationItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', "dyeYellow"); + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(mapLocationItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', "dyeYellow"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), "www", " g ", "GpG", 'w', "plankWood", 'g', "blockGlass", 'G', "gearWood", 'p', Blocks.piston); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), "l ", "r ", 'l', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(markerBlock, 1), "l ", "r ", 'l', new ItemStack(Items.dye, 1, 4), 'r', Blocks.redstone_torch); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), "l ", "r ", 'l', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), "l ", "r ", 'l', "dyeGreen", 'r', Blocks.redstone_torch); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(paintbrushItem), " iw", " gi", "s ", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(paintbrushItem), " iw", " gi", "s ", 's', "stickWood", 'g', "gearWood", 'w', new ItemStack(Blocks.wool, 1, 0), 'i', Items.string); ItemStack anyPaintbrush = new ItemStack(paintbrushItem, 1, OreDictionary.WILDCARD_VALUE); @@ -661,16 +671,16 @@ public class BuildCraftCore extends BuildCraftMod { for (int i = 0; i < 16; i++) { ItemStack outputStack = new ItemStack(paintbrushItem); NBTUtils.getItemData(outputStack).setByte("color", (byte) i); - CoreProxy.proxy.addShapelessRecipe(outputStack, anyPaintbrush, EnumColor.fromId(i).getDye()); + BCRegistry.INSTANCE.addShapelessRecipe(outputStack, anyPaintbrush, EnumColor.fromId(i).getDye()); } // Convert old lists to new lists - CoreProxy.proxy.addShapelessRecipe(new ItemStack(listItem, 1, 1), new ItemStack(listItem, 1, 0)); + BCRegistry.INSTANCE.addShapelessRecipe(new ItemStack(listItem, 1, 1), new ItemStack(listItem, 1, 0)); if (Loader.isModLoaded("BuildCraft|Silicon")) { CoreSiliconRecipes.loadSiliconRecipes(); } else { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(listItem, 1, 1), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(listItem, 1, 1), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', "dyeGreen"); } } diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 4053eb3d..8feb3ef2 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -51,6 +51,7 @@ import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.recipes.BuildcraftRecipeRegistry; import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.StatementManager; +import buildcraft.core.BCRegistry; import buildcraft.core.BlockSpring; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -207,7 +208,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (fluidOil.getBlock() == null) { blockOil = new BlockBuildCraftFluid(fluidOil, Material.water, MapColor.blackColor).setFlammability(0); blockOil.setBlockName("blockOil").setLightOpacity(8); - CoreProxy.proxy.registerBlock(blockOil); + BCRegistry.INSTANCE.registerBlock(blockOil, true); fluidOil.setBlock(blockOil); BuildCraftCore.mainConfigManager.register("general.oilCanBurn", true, "Should oil burn when lit on fire?", ConfigManager.RestartRequirement.NONE); @@ -227,7 +228,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (fluidFuel.getBlock() == null) { blockFuel = new BlockBuildCraftFluid(fluidFuel, Material.water, MapColor.yellowColor).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F); blockFuel.setBlockName("blockFuel").setLightOpacity(3); - CoreProxy.proxy.registerBlock(blockFuel); + BCRegistry.INSTANCE.registerBlock(blockFuel, true); fluidFuel.setBlock(blockFuel); } else { blockFuel = fluidFuel.getBlock(); @@ -237,7 +238,7 @@ public class BuildCraftEnergy extends BuildCraftMod { blockRedPlasma = new BlockBuildCraftFluid(fluidRedPlasma, Material.water, MapColor.redColor).setFlammable( false).setParticleColor(0.9F, 0, 0); blockRedPlasma.setBlockName("blockRedPlasma"); - CoreProxy.proxy.registerBlock(blockRedPlasma); + BCRegistry.INSTANCE.registerBlock(blockRedPlasma, true); fluidRedPlasma.setBlock(blockRedPlasma); } else { blockRedPlasma = fluidRedPlasma.getBlock(); @@ -248,14 +249,14 @@ public class BuildCraftEnergy extends BuildCraftMod { if (blockOil != null) { bucketOil = new ItemBucketBuildcraft(blockOil); bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Items.bucket); - CoreProxy.proxy.registerItem(bucketOil); + BCRegistry.INSTANCE.registerItem(bucketOil, true); FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Items.bucket)); } if (blockFuel != null) { bucketFuel = new ItemBucketBuildcraft(blockFuel); bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Items.bucket); - CoreProxy.proxy.registerItem(bucketFuel); + BCRegistry.INSTANCE.registerItem(bucketFuel, true); FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Items.bucket)); } @@ -263,7 +264,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (blockRedPlasma != null) { bucketRedPlasma = new ItemBucketBuildcraft(blockRedPlasma); bucketRedPlasma.setUnlocalizedName("bucketRedPlasma").setContainerItem(Items.bucket); - CoreProxy.proxy.registerItem(bucketRedPlasma); + BCRegistry.INSTANCE.registerItem(bucketRedPlasma, true); FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("redplasma", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketRedPlasma), new ItemStack(Items.bucket)); } } @@ -287,9 +288,9 @@ public class BuildCraftEnergy extends BuildCraftMod { BuildcraftFuelRegistry.coolant.addSolidCoolant(StackKey.stack(Blocks.ice), StackKey.fluid(FluidRegistry.WATER), 1.5f); BuildcraftFuelRegistry.coolant.addSolidCoolant(StackKey.stack(Blocks.packed_ice), StackKey.fluid(FluidRegistry.WATER), 2.0f); - BuildCraftCore.engineBlock.registerTile(TileEngineStone.class, "tile.engineStone", "buildcraftenergy:engineStone"); - BuildCraftCore.engineBlock.registerTile(TileEngineIron.class, "tile.engineIron", "buildcraftenergy:engineIron"); - BuildCraftCore.engineBlock.registerTile(TileEngineCreative.class, "tile.engineCreative", "buildcraftenergy:engineCreative"); + BuildCraftCore.engineBlock.registerTile(TileEngineStone.class, 1, "tile.engineStone", "buildcraftenergy:engineStone"); + BuildCraftCore.engineBlock.registerTile(TileEngineIron.class, 2, "tile.engineIron", "buildcraftenergy:engineIron"); + BuildCraftCore.engineBlock.registerTile(TileEngineCreative.class, 3, "tile.engineCreative", "buildcraftenergy:engineCreative"); InterModComms.registerHandler(new IMCHandlerEnergy()); @@ -411,10 +412,10 @@ public class BuildCraftEnergy extends BuildCraftMod { } public static void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(BuildCraftCore.engineBlock, 1, 1), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(BuildCraftCore.engineBlock, 1, 1), "www", " g ", "GpG", 'w', "cobblestone", 'g', "blockGlass", 'G', "gearStone", 'p', Blocks.piston); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(BuildCraftCore.engineBlock, 1, 2), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(BuildCraftCore.engineBlock, 1, 2), "www", " g ", "GpG", 'w', "ingotIron", 'g', "blockGlass", 'G', "gearIron", 'p', Blocks.piston); } diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index f7307199..a68061f6 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -34,6 +34,7 @@ import net.minecraftforge.common.MinecraftForge; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.blueprints.SchematicTile; +import buildcraft.core.BCRegistry; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -95,13 +96,13 @@ public class BuildCraftFactory extends BuildCraftMod { public void load(FMLInitializationEvent evt) { NetworkRegistry.INSTANCE.registerGuiHandler(instance, new FactoryGuiHandler()); - CoreProxy.proxy.registerTileEntity(TileMiningWell.class, "MiningWell"); - CoreProxy.proxy.registerTileEntity(TileAutoWorkbench.class, "AutoWorkbench"); - CoreProxy.proxy.registerTileEntity(TilePump.class, "net.minecraft.src.buildcraft.factory.TilePump"); - CoreProxy.proxy.registerTileEntity(TileFloodGate.class, "net.minecraft.src.buildcraft.factory.TileFloodGate"); - CoreProxy.proxy.registerTileEntity(TileTank.class, "net.minecraft.src.buildcraft.factory.TileTank"); - CoreProxy.proxy.registerTileEntity(TileRefinery.class, "net.minecraft.src.buildcraft.factory.Refinery"); - CoreProxy.proxy.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper"); + BCRegistry.INSTANCE.registerTileEntity(TileMiningWell.class, "MiningWell"); + BCRegistry.INSTANCE.registerTileEntity(TileAutoWorkbench.class, "AutoWorkbench"); + BCRegistry.INSTANCE.registerTileEntity(TilePump.class, "net.minecraft.src.buildcraft.factory.TilePump"); + BCRegistry.INSTANCE.registerTileEntity(TileFloodGate.class, "net.minecraft.src.buildcraft.factory.TileFloodGate"); + BCRegistry.INSTANCE.registerTileEntity(TileTank.class, "net.minecraft.src.buildcraft.factory.TileTank"); + BCRegistry.INSTANCE.registerTileEntity(TileRefinery.class, "net.minecraft.src.buildcraft.factory.Refinery"); + BCRegistry.INSTANCE.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper"); FactoryProxy.proxy.initializeTileEntities(); @@ -142,28 +143,28 @@ public class BuildCraftFactory extends BuildCraftMod { reloadConfig(ConfigManager.RestartRequirement.GAME); miningWellBlock = (BlockMiningWell) CompatHooks.INSTANCE.getBlock(BlockMiningWell.class); - CoreProxy.proxy.registerBlock(miningWellBlock.setBlockName("miningWellBlock")); - - plainPipeBlock = new BlockPlainPipe(); - CoreProxy.proxy.registerBlock(plainPipeBlock.setBlockName("plainPipeBlock")); + if (BCRegistry.INSTANCE.registerBlock(miningWellBlock.setBlockName("miningWellBlock"), false)) { + plainPipeBlock = new BlockPlainPipe(); + BCRegistry.INSTANCE.registerBlock(plainPipeBlock.setBlockName("plainPipeBlock"), true); + } autoWorkbenchBlock = (BlockAutoWorkbench) CompatHooks.INSTANCE.getBlock(BlockAutoWorkbench.class); - CoreProxy.proxy.registerBlock(autoWorkbenchBlock.setBlockName("autoWorkbenchBlock")); + BCRegistry.INSTANCE.registerBlock(autoWorkbenchBlock.setBlockName("autoWorkbenchBlock"), false); tankBlock = (BlockTank) CompatHooks.INSTANCE.getBlock(BlockTank.class); - CoreProxy.proxy.registerBlock(tankBlock.setBlockName("tankBlock")); + BCRegistry.INSTANCE.registerBlock(tankBlock.setBlockName("tankBlock"), false); pumpBlock = (BlockPump) CompatHooks.INSTANCE.getBlock(BlockPump.class); - CoreProxy.proxy.registerBlock(pumpBlock.setBlockName("pumpBlock")); + BCRegistry.INSTANCE.registerBlock(pumpBlock.setBlockName("pumpBlock"), false); floodGateBlock = (BlockFloodGate) CompatHooks.INSTANCE.getBlock(BlockFloodGate.class); - CoreProxy.proxy.registerBlock(floodGateBlock.setBlockName("floodGateBlock")); + BCRegistry.INSTANCE.registerBlock(floodGateBlock.setBlockName("floodGateBlock"), false); refineryBlock = (BlockRefinery) CompatHooks.INSTANCE.getBlock(BlockRefinery.class); - CoreProxy.proxy.registerBlock(refineryBlock.setBlockName("refineryBlock")); + BCRegistry.INSTANCE.registerBlock(refineryBlock.setBlockName("refineryBlock"), false); hopperBlock = (BlockHopper) CompatHooks.INSTANCE.getBlock(BlockHopper.class); - CoreProxy.proxy.registerBlock(hopperBlock.setBlockName("blockHopper")); + BCRegistry.INSTANCE.registerBlock(hopperBlock.setBlockName("blockHopper"), false); FactoryProxy.proxy.initializeEntityRenders(); @@ -173,7 +174,7 @@ public class BuildCraftFactory extends BuildCraftMod { public static void loadRecipes() { if (miningWellBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(miningWellBlock, 1), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(miningWellBlock, 1), "ipi", "igi", "iPi", @@ -184,7 +185,7 @@ public class BuildCraftFactory extends BuildCraftMod { } if (pumpBlock != null) { - CoreProxy.proxy.addCraftingRecipe( + BCRegistry.INSTANCE.addCraftingRecipe( new ItemStack(pumpBlock), "ipi", "igi", @@ -197,12 +198,12 @@ public class BuildCraftFactory extends BuildCraftMod { } if (autoWorkbenchBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(autoWorkbenchBlock), "gwg", 'w', "craftingTableWood", 'g', "gearStone"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(autoWorkbenchBlock), "g", "w", "g", @@ -212,7 +213,7 @@ public class BuildCraftFactory extends BuildCraftMod { if (tankBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(tankBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(tankBlock), "ggg", "g g", "ggg", @@ -220,7 +221,7 @@ public class BuildCraftFactory extends BuildCraftMod { } if (refineryBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(refineryBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(refineryBlock), "RTR", "TGT", 'T', tankBlock != null ? tankBlock : "blockGlass", @@ -229,18 +230,18 @@ public class BuildCraftFactory extends BuildCraftMod { } if (hopperBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(hopperBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(hopperBlock), "ICI", " G ", 'I', "ingotIron", 'C', "chestWood", 'G', "gearStone"); - CoreProxy.proxy.addShapelessRecipe(new ItemStack(hopperBlock), Blocks.hopper, "gearStone"); + BCRegistry.INSTANCE.addShapelessRecipe(new ItemStack(hopperBlock), Blocks.hopper, "gearStone"); } if (floodGateBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(floodGateBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(floodGateBlock), "IGI", "FTF", "IFI", diff --git a/common/buildcraft/BuildCraftRobotics.java b/common/buildcraft/BuildCraftRobotics.java index ae95883c..d3c8ad67 100644 --- a/common/buildcraft/BuildCraftRobotics.java +++ b/common/buildcraft/BuildCraftRobotics.java @@ -46,6 +46,7 @@ import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.StatementManager; import buildcraft.api.transport.PipeManager; import buildcraft.core.BCCreativeTab; +import buildcraft.core.BCRegistry; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -196,22 +197,22 @@ public class BuildCraftRobotics extends BuildCraftMod { reloadConfig(ConfigManager.RestartRequirement.GAME); robotItem = new ItemRobot().setUnlocalizedName("robot"); - CoreProxy.proxy.registerItem(robotItem); + BCRegistry.INSTANCE.registerItem(robotItem, false); robotStationItem = new ItemRobotStation().setUnlocalizedName("robotStation"); - CoreProxy.proxy.registerItem(robotStationItem); + BCRegistry.INSTANCE.registerItem(robotStationItem, false); redstoneBoard = new ItemRedstoneBoard(); redstoneBoard.setUnlocalizedName("redstone_board"); - CoreProxy.proxy.registerItem(redstoneBoard); + BCRegistry.INSTANCE.registerItem(redstoneBoard, false); zonePlanBlock = (BlockZonePlan) CompatHooks.INSTANCE.getBlock(BlockZonePlan.class); zonePlanBlock.setBlockName("zonePlan"); - CoreProxy.proxy.registerBlock(zonePlanBlock); + BCRegistry.INSTANCE.registerBlock(zonePlanBlock, false); requesterBlock = (BlockRequester) CompatHooks.INSTANCE.getBlock(BlockRequester.class); requesterBlock.setBlockName("requester"); - CoreProxy.proxy.registerBlock(requesterBlock); + BCRegistry.INSTANCE.registerBlock(requesterBlock, false); RedstoneBoardRegistry.instance = new ImplRedstoneBoardRegistry(); @@ -268,8 +269,8 @@ public class BuildCraftRobotics extends BuildCraftMod { PipeManager.registerPipePluggable(RobotStationPluggable.class, "robotStation"); EntityRegistry.registerModEntity(EntityRobot.class, "bcRobot", EntityIds.ROBOT, instance, 50, 1, true); - CoreProxy.proxy.registerTileEntity(TileZonePlan.class, "net.minecraft.src.buildcraft.commander.TileZonePlan"); - CoreProxy.proxy.registerTileEntity(TileRequester.class, "net.minecraft.src.buildcraft.commander.TileRequester"); + BCRegistry.INSTANCE.registerTileEntity(TileZonePlan.class, "net.minecraft.src.buildcraft.commander.TileZonePlan"); + BCRegistry.INSTANCE.registerTileEntity(TileRequester.class, "net.minecraft.src.buildcraft.commander.TileRequester"); RobotManager.registryProvider = new RobotRegistryProvider(); @@ -340,7 +341,7 @@ public class BuildCraftRobotics extends BuildCraftMod { } public static void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(robotItem), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(robotItem), "PPP", "PRP", "C C", @@ -348,14 +349,14 @@ public class BuildCraftRobotics extends BuildCraftMod { 'R', "crystalRedstone", 'C', ItemRedstoneChipset.Chipset.DIAMOND.getStack()); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(redstoneBoard), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(redstoneBoard), "PPP", "PRP", "PPP", 'R', "dustRedstone", 'P', Items.paper); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(zonePlanBlock, 1, 0), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(zonePlanBlock, 1, 0), "IRI", "GMG", "IDI", @@ -365,7 +366,7 @@ public class BuildCraftRobotics extends BuildCraftMod { 'D', "gearDiamond", 'I', "ingotIron"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(requesterBlock, 1, 0), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(requesterBlock, 1, 0), "IPI", "GCG", "IRI", @@ -375,7 +376,7 @@ public class BuildCraftRobotics extends BuildCraftMod { 'G', "gearIron", 'I', "ingotIron"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(robotStationItem), " ", " I ", "ICI", + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(robotStationItem), " ", " I ", "ICI", 'I', "ingotIron", 'C', ItemRedstoneChipset.Chipset.GOLD.getStack()); diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 2edeb8d9..febaad11 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -30,6 +30,7 @@ import net.minecraftforge.oredict.OreDictionary; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.core.BCRegistry; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -90,30 +91,30 @@ public class BuildCraftSilicon extends BuildCraftMod { laserBlock = (BlockLaser) CompatHooks.INSTANCE.getBlock(BlockLaser.class); laserBlock.setBlockName("laserBlock"); - CoreProxy.proxy.registerBlock(laserBlock); + BCRegistry.INSTANCE.registerBlock(laserBlock, false); assemblyTableBlock = (BlockLaserTable) CompatHooks.INSTANCE.getBlock(BlockLaserTable.class); assemblyTableBlock.setBlockName("laserTableBlock"); - CoreProxy.proxy.registerBlock(assemblyTableBlock, ItemLaserTable.class); + BCRegistry.INSTANCE.registerBlock(assemblyTableBlock, ItemLaserTable.class, false); packagerBlock = (BlockPackager) CompatHooks.INSTANCE.getBlock(BlockPackager.class); packagerBlock.setBlockName("packagerBlock"); - CoreProxy.proxy.registerBlock(packagerBlock); + BCRegistry.INSTANCE.registerBlock(packagerBlock, false); redstoneChipset = new ItemRedstoneChipset(); redstoneChipset.setUnlocalizedName("redstoneChipset"); - CoreProxy.proxy.registerItem(redstoneChipset); + BCRegistry.INSTANCE.registerItem(redstoneChipset, false); redstoneChipset.registerItemStacks(); packageItem = new ItemPackage(); packageItem.setUnlocalizedName("package"); - CoreProxy.proxy.registerItem(packageItem); + BCRegistry.INSTANCE.registerItem(packageItem, false); redstoneCrystal = (new ItemBuildCraft()).setUnlocalizedName("redstoneCrystal"); - CoreProxy.proxy.registerItem(redstoneCrystal); - - OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal)); // Deprecated - OreDictionary.registerOre("crystalRedstone", new ItemStack(redstoneCrystal)); + if (BCRegistry.INSTANCE.registerItem(redstoneCrystal, false)) { + OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal)); // Deprecated + OreDictionary.registerOre("crystalRedstone", new ItemStack(redstoneCrystal)); + } EntityRegistry.registerModEntity(EntityPackage.class, "bcPackageThrowable", EntityIds.PACKAGE_THROWABLE, instance, 48, 10, true); } @@ -125,19 +126,19 @@ public class BuildCraftSilicon extends BuildCraftMod { (DefaultProps.NET_CHANNEL_NAME + "-SILICON", new ChannelHandler(), new PacketHandlerSilicon()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new SiliconGuiHandler()); - CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser"); - CoreProxy.proxy.registerTileEntity(TileAssemblyTable.class, + BCRegistry.INSTANCE.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser"); + BCRegistry.INSTANCE.registerTileEntity(TileAssemblyTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyTable"); - CoreProxy.proxy.registerTileEntity(TileAdvancedCraftingTable.class, + BCRegistry.INSTANCE.registerTileEntity(TileAdvancedCraftingTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyAdvancedWorkbench"); - CoreProxy.proxy.registerTileEntity(TileIntegrationTable.class, + BCRegistry.INSTANCE.registerTileEntity(TileIntegrationTable.class, "net.minecraft.src.buildcraft.factory.TileIntegrationTable"); - CoreProxy.proxy.registerTileEntity(TileChargingTable.class, + BCRegistry.INSTANCE.registerTileEntity(TileChargingTable.class, "net.minecraft.src.buildcraft.factory.TileChargingTable"); - CoreProxy.proxy.registerTileEntity(TileProgrammingTable.class, + BCRegistry.INSTANCE.registerTileEntity(TileProgrammingTable.class, "net.minecraft.src.buildcraft.factory.TileProgrammingTable"); - CoreProxy.proxy.registerTileEntity(TilePackager.class, "buildcraft.TilePackager"); - CoreProxy.proxy.registerTileEntity(TileStampingTable.class, "buildcraft.TileStampingTable"); + BCRegistry.INSTANCE.registerTileEntity(TilePackager.class, "buildcraft.TilePackager"); + BCRegistry.INSTANCE.registerTileEntity(TileStampingTable.class, "buildcraft.TileStampingTable"); BuilderAPI.schematicRegistry.registerSchematicBlock(laserBlock, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true); @@ -164,7 +165,7 @@ public class BuildCraftSilicon extends BuildCraftMod { public static void loadRecipes() { // TABLES - CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(laserBlock), "ORR", "DDR", "ORR", @@ -172,7 +173,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'R', "dustRedstone", 'D', "gemDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(laserBlock), "RRO", "RDD", "RRO", @@ -180,7 +181,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'R', "dustRedstone", 'D', "gemDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(laserBlock), "RRR", "RDR", "ODO", @@ -188,7 +189,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'R', "dustRedstone", 'D', "gemDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(laserBlock), "ODO", "RDR", "RRR", @@ -196,7 +197,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'R', "dustRedstone", 'D', "gemDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), "ODO", "ORO", "OGO", @@ -205,7 +206,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'D', "gemDiamond", 'G', "gearDiamond"); - /* CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), + /* BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), "OWO", "OCO", "ORO", @@ -214,7 +215,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'C', Blocks.chest, 'R', new ItemStack(redstoneChipset, 1, 0)); */ - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 2), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 2), "OIO", "OCO", "OGO", @@ -223,7 +224,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'C', new ItemStack(redstoneChipset, 1, 0), 'G', "gearDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 3), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 3), "OIO", "OCO", "OGO", @@ -232,7 +233,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'C', new ItemStack(redstoneChipset, 1, 0), 'G', "gearGold"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 4), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 4), "OCO", "ORO", "OGO", @@ -241,7 +242,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'C', "gemEmerald", 'G', "gearDiamond"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 5), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 5), "OWO", "ORO", "OGO", @@ -250,7 +251,7 @@ public class BuildCraftSilicon extends BuildCraftMod { 'G', "gearGold", 'R', new ItemStack(redstoneChipset, 1, 0)); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(packagerBlock, 1, 0), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(packagerBlock, 1, 0), " I ", "ICI", " P ", diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 3c018514..d943759c 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -59,6 +59,7 @@ import buildcraft.api.statements.StatementManager; import buildcraft.api.transport.PipeManager; import buildcraft.api.transport.PipeWire; import buildcraft.core.BCCreativeTab; +import buildcraft.core.BCRegistry; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -330,14 +331,14 @@ public class BuildCraftTransport extends BuildCraftMod { } filteredBufferBlock = new BlockFilteredBuffer(); - CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock")); + BCRegistry.INSTANCE.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock"), false); pipeWaterproof = new ItemBuildCraft(); pipeWaterproof.setUnlocalizedName("pipeWaterproof"); - CoreProxy.proxy.registerItem(pipeWaterproof); + BCRegistry.INSTANCE.registerItem(pipeWaterproof, false); genericPipeBlock = (BlockGenericPipe) CompatHooks.INSTANCE.getBlock(BlockGenericPipe.class); - CoreProxy.proxy.registerBlock(genericPipeBlock.setBlockName("pipeBlock"), ItemBlock.class); + BCRegistry.INSTANCE.registerBlock(genericPipeBlock.setBlockName("pipeBlock"), ItemBlock.class, true); pipeItemsWood = buildPipe(PipeItemsWood.class, "plankWood", "blockGlassColorless", "plankWood"); pipeItemsEmerald = buildPipe(PipeItemsEmerald.class, "gemEmerald", "blockGlassColorless", "gemEmerald"); @@ -381,32 +382,32 @@ public class BuildCraftTransport extends BuildCraftMod { pipeStructureCobblestone = buildPipe(PipeStructureCobblestone.class, Blocks.cobblestone, Blocks.gravel, Blocks.cobblestone); pipeWire = new ItemPipeWire(); - CoreProxy.proxy.registerItem(pipeWire); + BCRegistry.INSTANCE.registerItem(pipeWire, false); PipeWire.item = pipeWire; pipeGate = new ItemGate(); pipeGate.setUnlocalizedName("pipeGate"); - CoreProxy.proxy.registerItem(pipeGate); + BCRegistry.INSTANCE.registerItem(pipeGate, false); facadeItem = new ItemFacade(); facadeItem.setUnlocalizedName("pipeFacade"); - CoreProxy.proxy.registerItem(facadeItem); + BCRegistry.INSTANCE.registerItem(facadeItem, false); FacadeAPI.facadeItem = facadeItem; plugItem = new ItemPlug(); plugItem.setUnlocalizedName("pipePlug"); - CoreProxy.proxy.registerItem(plugItem); + BCRegistry.INSTANCE.registerItem(plugItem, false); lensItem = new ItemLens(); lensItem.setUnlocalizedName("pipeLens"); - CoreProxy.proxy.registerItem(lensItem); + BCRegistry.INSTANCE.registerItem(lensItem, false); powerAdapterItem = new ItemPowerAdapter(); powerAdapterItem.setUnlocalizedName("pipePowerAdapter"); - CoreProxy.proxy.registerItem(powerAdapterItem); + BCRegistry.INSTANCE.registerItem(powerAdapterItem, false); gateCopier = new ItemGateCopier(); - CoreProxy.proxy.registerItem(gateCopier); + BCRegistry.INSTANCE.registerItem(gateCopier, false); for (PipeContents kind : PipeContents.values()) { triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind); @@ -657,16 +658,16 @@ public class BuildCraftTransport extends BuildCraftMod { // Add pipe recipes for (PipeRecipe pipe : pipeRecipes) { if (pipe.isShapeless) { - CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input); + BCRegistry.INSTANCE.addShapelessRecipe(pipe.result, pipe.input); } else { - CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input); + BCRegistry.INSTANCE.addCraftingRecipe(pipe.result, pipe.input); } } GameRegistry.addRecipe(new PipeColoringRecipe()); RecipeSorter.register("buildcraft:pipecoloring", PipeColoringRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1), + BCRegistry.INSTANCE.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1), "wdw", "wcw", "wpw", 'w', "plankWood", 'd', BuildCraftTransport.pipeItemsDiamond, 'c', "chestWood", 'p', Blocks.piston); @@ -722,9 +723,19 @@ public class BuildCraftTransport extends BuildCraftMod { public static Item buildPipe(Class> clas, BCCreativeTab creativeTab, Object... ingredients) { + if (!BCRegistry.INSTANCE.isEnabled("pipes", clas.getSimpleName())) { + return null; + } + ItemPipe res = BlockGenericPipe.registerPipe(clas, creativeTab); res.setUnlocalizedName(clas.getSimpleName()); + for (Object o : ingredients) { + if (o == null) { + return res; + } + } + // Add appropriate recipes to temporary list if (ingredients.length == 3) { for (int i = 0; i < 17; i++) { diff --git a/common/buildcraft/core/BCRegistry.java b/common/buildcraft/core/BCRegistry.java new file mode 100644 index 00000000..197d295a --- /dev/null +++ b/common/buildcraft/core/BCRegistry.java @@ -0,0 +1,90 @@ +package buildcraft.core; + +import java.io.File; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import buildcraft.core.lib.items.ItemBlockBuildCraft; + +public class BCRegistry { + public static final BCRegistry INSTANCE = new BCRegistry(); + private Configuration regCfg; + + private BCRegistry() { + + } + + public boolean isEnabled(String category, String name) { + return regCfg.get(category, name, true).getBoolean(); + } + + public void setRegistryConfig(File f) { + regCfg = new Configuration(f); + } + + public boolean registerBlock(Block block, boolean forced) { + return registerBlock(block, ItemBlockBuildCraft.class, forced); + } + + public boolean registerBlock(Block block, Class item, boolean forced) { + String name = block.getUnlocalizedName().replace("tile.", ""); + if (forced || regCfg.get("blocks", name, true).getBoolean()) { + GameRegistry.registerBlock(block, item, name); + return true; + } + return false; + } + + public boolean registerItem(Item item, boolean forced) { + String name = item.getUnlocalizedName().replace("item.", ""); + if (forced || regCfg.get("items", name, true).getBoolean()) { + GameRegistry.registerItem(item, name); + return true; + } + return false; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + public void registerTileEntity(Class clas, String ident) { + GameRegistry.registerTileEntity(CompatHooks.INSTANCE.getTile(clas), ident); + } + + public void addCraftingRecipe(ItemStack result, Object... recipe) { + for (Object o : recipe) { + if (o instanceof Block && Block.getIdFromBlock((Block) o) < 0) { + return; + } + if (o instanceof Item && Item.getIdFromItem((Item) o) < 0) { + return; + } + if (o instanceof ItemStack && ((ItemStack) o).getItem() == null) { + return; + } + } + GameRegistry.addRecipe(new ShapedOreRecipe(result, recipe)); + } + + public void addShapelessRecipe(ItemStack result, Object... recipe) { + for (Object o : recipe) { + if (o instanceof Block && Block.getIdFromBlock((Block) o) < 0) { + return; + } + if (o instanceof Item && Item.getIdFromItem((Item) o) < 0) { + return; + } + if (o instanceof ItemStack && ((ItemStack) o).getItem() == null) { + return; + } + } + GameRegistry.addRecipe(new ShapelessOreRecipe(result, recipe)); + } + + public void save() { + regCfg.save(); + } +} diff --git a/common/buildcraft/core/BlockEngine.java b/common/buildcraft/core/BlockEngine.java index 6fc301f4..cf638846 100644 --- a/common/buildcraft/core/BlockEngine.java +++ b/common/buildcraft/core/BlockEngine.java @@ -13,26 +13,26 @@ import buildcraft.core.lib.engines.BlockEngineBase; import buildcraft.core.lib.engines.TileEngineBase; public class BlockEngine extends BlockEngineBase { - private final ArrayList> engineTiles; - private final ArrayList names; - private final ArrayList texturePaths; + private final Class[] engineTiles; + private final String[] names; + private final String[] texturePaths; public BlockEngine() { super(); setBlockName("engineBlock"); - engineTiles = new ArrayList>(16); - names = new ArrayList(16); - texturePaths = new ArrayList(16); + engineTiles = new Class[16]; + names = new String[16]; + texturePaths = new String[16]; } @Override public String getTexturePrefix(int meta, boolean addPrefix) { - if (meta < texturePaths.size()) { + if (texturePaths[meta] != null) { if (addPrefix) { - return texturePaths.get(meta).replaceAll(":", ":textures/blocks/"); + return texturePaths[meta].replaceAll(":", ":textures/blocks/"); } else { - return texturePaths.get(meta); + return texturePaths[meta]; } } else { return null; @@ -41,19 +41,21 @@ public class BlockEngine extends BlockEngineBase { @Override public String getUnlocalizedName(int metadata) { - return names.get(metadata % names.size()); + return names[metadata] != null ? names[metadata] : "unknown"; } - public void registerTile(Class engineTile, String name, String texturePath) { - engineTiles.add(engineTile); - names.add(name); - texturePaths.add(texturePath); + public void registerTile(Class engineTile, int meta, String name, String texturePath) { + if (BCRegistry.INSTANCE.isEnabled("engines", name)) { + engineTiles[meta] = engineTile; + names[meta] = name; + texturePaths[meta] = texturePath; + } } @Override public TileEntity createTileEntity(World world, int metadata) { try { - return engineTiles.get(metadata % engineTiles.size()).newInstance(); + return (TileEntity) engineTiles[metadata].newInstance(); } catch (Exception e) { e.printStackTrace(); return null; @@ -63,12 +65,14 @@ public class BlockEngine extends BlockEngineBase { @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < engineTiles.size(); i++) { - itemList.add(new ItemStack(this, 1, i)); + for (int i = 0; i < 16; i++) { + if (engineTiles[i] != null) { + itemList.add(new ItemStack(this, 1, i)); + } } } - public int getEngineCount() { - return engineTiles.size(); + public boolean hasEngine(int meta) { + return engineTiles[meta] != null; } } diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index 3341a28d..292f5ea6 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -80,36 +80,10 @@ public class CoreProxy implements ICoreProxy { public void initializeEntityRendering() { } - /* REGISTRATION */ - public void registerBlock(Block block) { - registerBlock(block, ItemBlockBuildCraft.class); - } - - public void registerBlock(Block block, Class item) { - GameRegistry.registerBlock(block, item, block.getUnlocalizedName().replace("tile.", "")); - } - - public void registerItem(Item item) { - GameRegistry.registerItem(item, item.getUnlocalizedName().replace("item.", "")); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public void registerTileEntity(Class clas, String ident) { - GameRegistry.registerTileEntity(CompatHooks.INSTANCE.getTile(clas), ident); - } - public void onCraftingPickup(World world, EntityPlayer player, ItemStack stack) { stack.onCrafting(world, player, stack.stackSize); } - public void addCraftingRecipe(ItemStack result, Object... recipe) { - GameRegistry.addRecipe(new ShapedOreRecipe(result, recipe)); - } - - public void addShapelessRecipe(ItemStack result, Object... recipe) { - GameRegistry.addRecipe(new ShapelessOreRecipe(result, recipe)); - } - public String playerName() { return ""; } diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java index 5e0f49a1..2c75a136 100644 --- a/common/buildcraft/core/proxy/CoreProxyClient.java +++ b/common/buildcraft/core/proxy/CoreProxyClient.java @@ -98,11 +98,13 @@ public class CoreProxyClient extends CoreProxy { ClientRegistry.bindTileEntitySpecialRenderer(TilePathMarker.class, new RenderPathMarker()); ClientRegistry.bindTileEntitySpecialRenderer(TileEngineBase.class, new RenderEngine()); - for (int i = 0; i < BuildCraftCore.engineBlock.getEngineCount(); i++) { - TileEngineBase engineTile = (TileEngineBase) BuildCraftCore.engineBlock.createTileEntity(null, i); - engineTile.blockType = BuildCraftCore.engineBlock; - engineTile.blockMetadata = i; - RenderingEntityBlocks.blockByEntityRenders.put(new RenderingEntityBlocks.EntityRenderIndex(BuildCraftCore.engineBlock, i), new RenderEngine(engineTile)); + for (int i = 0; i < 16; i++) { + if (BuildCraftCore.engineBlock.hasEngine(i)) { + TileEngineBase engineTile = (TileEngineBase) BuildCraftCore.engineBlock.createTileEntity(null, i); + engineTile.blockType = BuildCraftCore.engineBlock; + engineTile.blockMetadata = i; + RenderingEntityBlocks.blockByEntityRenders.put(new RenderingEntityBlocks.EntityRenderIndex(BuildCraftCore.engineBlock, i), new RenderEngine(engineTile)); + } } }