mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 11:19:28 +00:00
Use new block and item registration
This commit is contained in:
1 parent
7601a60c5e
commit
7403a6cdcd
9 files changed
+75
-52
No files matched your search
@@ -29,16 +29,21 @@ public class BlockRegistryApiculture extends BlockRegistry {
|
||||
private final Map<BlockAlvearyType, BlockAlveary> alvearyBlockMap;
|
||||
|
||||
public BlockRegistryApiculture() {
|
||||
apiculture = registerBlock(new BlockApiculture(), ItemBlockForestry.class, "apiculture");
|
||||
apiculture = new BlockApiculture();
|
||||
registerBlock(apiculture, new ItemBlockForestry(apiculture), "apiculture");
|
||||
|
||||
apicultureChest = registerBlock(new BlockBase<>(BlockTypeApicultureTesr.class), ItemBlockForestry.class, "apicultureChest");
|
||||
apicultureChest = new BlockBase<>(BlockTypeApicultureTesr.class);
|
||||
registerBlock(apicultureChest, new ItemBlockForestry(apicultureChest), "apicultureChest");
|
||||
apicultureChest.setCreativeTab(Tabs.tabApiculture);
|
||||
apicultureChest.setHarvestLevel("axe", 0);
|
||||
|
||||
beehives = registerBlock(new BlockBeeHives(), ItemBlockForestry.class, "beehives");
|
||||
beehives = new BlockBeeHives();
|
||||
registerBlock(beehives, new ItemBlockForestry(beehives), "beehives");
|
||||
|
||||
candle = registerBlock(new BlockCandle(), ItemBlockCandle.class, "candle");
|
||||
stump = registerBlock(new BlockStump(), ItemBlockForestry.class, "stump");
|
||||
candle = new BlockCandle();
|
||||
registerBlock(candle, new ItemBlockCandle(candle), "candle");
|
||||
stump = new BlockStump();
|
||||
registerBlock(stump, new ItemBlockForestry(stump), "stump");
|
||||
|
||||
alvearyBlockMap = BlockAlveary.create();
|
||||
for (BlockAlveary block : alvearyBlockMap.values()) {
|
||||
|
||||
@@ -59,25 +59,25 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
// Wood blocks
|
||||
logs = BlockArbLog.create(false);
|
||||
for (BlockArbLog block : logs) {
|
||||
registerBlock(block, ItemBlockWood.class, "logs." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "logs." + block.getBlockNumber());
|
||||
registerOreDictWildcard("logWood", block);
|
||||
}
|
||||
|
||||
logsFireproof = BlockArbLog.create(true);
|
||||
for (BlockArbLog block : logsFireproof) {
|
||||
registerBlock(block, ItemBlockWood.class, "logs.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "logs.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard("logWood", block);
|
||||
}
|
||||
|
||||
planks = BlockArbPlanks.create(false);
|
||||
for (BlockArbPlanks block : planks) {
|
||||
registerBlock(block, ItemBlockWood.class, "planks." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "planks." + block.getBlockNumber());
|
||||
registerOreDictWildcard("plankWood", block);
|
||||
}
|
||||
|
||||
planksFireproof = BlockArbPlanks.create(true);
|
||||
for (BlockArbPlanks block : planksFireproof) {
|
||||
registerBlock(block, ItemBlockWood.class, "planks.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "planks.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard("plankWood", block);
|
||||
}
|
||||
|
||||
@@ -103,26 +103,28 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
|
||||
fences = BlockArbFence.create(false);
|
||||
for (BlockArbFence block : fences) {
|
||||
registerBlock(block, ItemBlockWood.class, "fences." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "fences." + block.getBlockNumber());
|
||||
registerOreDictWildcard("fenceWood", block);
|
||||
}
|
||||
|
||||
fencesFireproof = BlockArbFence.create(true);
|
||||
for (BlockArbFence block : fencesFireproof) {
|
||||
registerBlock(block, ItemBlockWood.class, "fences.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood(block), "fences.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard("fenceWood", block);
|
||||
}
|
||||
|
||||
fenceGates = new ArrayList<>();
|
||||
fenceGatesFireproof = new ArrayList<>();
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
BlockArbFenceGate fence = registerBlock(new BlockArbFenceGate(false, woodType), ItemBlockWood.class, "fence.gates." + woodType);
|
||||
registerOreDictWildcard("fenceGateWood", fence);
|
||||
fenceGates.add(fence);
|
||||
BlockArbFenceGate fenceGate = new BlockArbFenceGate(false, woodType);
|
||||
registerBlock(fenceGate, new ItemBlockWood(fenceGate), "fence.gates." + woodType);
|
||||
registerOreDictWildcard("fenceGateWood", fenceGate);
|
||||
fenceGates.add(fenceGate);
|
||||
|
||||
BlockArbFenceGate fenceFireproof = registerBlock(new BlockArbFenceGate(true, woodType), ItemBlockWood.class, "fence.gates.fireproof." + woodType);
|
||||
registerOreDictWildcard("fenceGateWood", fenceFireproof);
|
||||
fenceGatesFireproof.add(fenceFireproof);
|
||||
BlockArbFenceGate fenceGateFireproof = new BlockArbFenceGate(true, woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood(fenceGateFireproof), "fence.gates.fireproof." + woodType);
|
||||
registerOreDictWildcard("fenceGateWood", fenceGateFireproof);
|
||||
fenceGatesFireproof.add(fenceGateFireproof);
|
||||
}
|
||||
|
||||
stairs = new ArrayList<>();
|
||||
@@ -132,7 +134,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
EnumWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockArbStairs stair = new BlockArbStairs(false, blockState, woodType);
|
||||
stair = registerBlock(stair, ItemBlockWood.class, "stairs." + woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs." + woodType);
|
||||
registerOreDictWildcard("stairWood", stair);
|
||||
stairs.add(stair);
|
||||
}
|
||||
@@ -145,7 +147,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
EnumWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockArbStairs stair = new BlockArbStairs(true, blockState, woodType);
|
||||
stair = registerBlock(stair, ItemBlockWood.class, "stairs.fireproof." + woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs.fireproof." + woodType);
|
||||
registerOreDictWildcard("stairWood", stair);
|
||||
stairsFireproof.add(stair);
|
||||
}
|
||||
@@ -153,18 +155,21 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
|
||||
doors = new ArrayList<>();
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
BlockArbDoor door = registerBlock(new BlockArbDoor(woodType), ItemBlockWoodDoor.class, "doors." + woodType);
|
||||
BlockArbDoor door = new BlockArbDoor(woodType);
|
||||
registerBlock(door, new ItemBlockWoodDoor(door), "doors." + woodType);
|
||||
registerOreDictWildcard("doorWood", door);
|
||||
doors.add(door);
|
||||
}
|
||||
|
||||
// Saplings
|
||||
TreeDefinition.preInit();
|
||||
saplingGE = registerBlock(new BlockSapling(), ItemBlockForestry.class, "saplingGE");
|
||||
saplingGE = new BlockSapling();
|
||||
registerBlock(new BlockSapling(), new ItemBlockForestry(saplingGE), "saplingGE");
|
||||
registerOreDictWildcard("treeSapling", saplingGE);
|
||||
|
||||
// Leaves
|
||||
leaves = registerBlock(new BlockForestryLeaves(), ItemBlockLeaves.class, "leaves");
|
||||
leaves = new BlockForestryLeaves();
|
||||
registerBlock(new BlockForestryLeaves(), new ItemBlockLeaves(leaves), "leaves");
|
||||
registerOreDictWildcard("treeLeaves", leaves);
|
||||
|
||||
leavesDecorative = BlockDecorativeLeaves.create();
|
||||
@@ -191,7 +196,8 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
}
|
||||
|
||||
// Machines
|
||||
arboriculture = registerBlock(new BlockArboriculture(), ItemBlockForestry.class, "arboriculture");
|
||||
arboriculture = new BlockArboriculture();
|
||||
registerBlock(arboriculture, new ItemBlockForestry(arboriculture), "arboriculture");
|
||||
}
|
||||
|
||||
public ItemStack getDecorativeLeaves(String speciesUid) {
|
||||
|
||||
@@ -21,29 +21,24 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public abstract class BlockRegistry {
|
||||
protected <T extends Block> T registerBlock(T block, ItemBlock itemBlock, String name) {
|
||||
protected <T extends Block> void registerBlock(T block, ItemBlock itemBlock, String name) {
|
||||
if (PluginManager.getStage() != PluginManager.Stage.REGISTER) {
|
||||
throw new RuntimeException("Tried to register Block outside of REGISTER");
|
||||
}
|
||||
block.setUnlocalizedName("for." + name);
|
||||
GameRegistry.registerBlock(block, null, name);
|
||||
GameRegistry.registerItem(itemBlock, name);
|
||||
block.setRegistryName(name);
|
||||
GameRegistry.register(block);
|
||||
Proxies.common.registerBlock(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
protected <T extends Block> T registerBlock(T block, String name) {
|
||||
return registerBlock(block, (Class<? extends ItemBlock>) null, name);
|
||||
}
|
||||
|
||||
protected <T extends Block> T registerBlock(T block, Class<? extends ItemBlock> itemClass, String name, Object... itemCtorArgs) {
|
||||
if (PluginManager.getStage() != PluginManager.Stage.REGISTER) {
|
||||
throw new RuntimeException("Tried to register Block outside of REGISTER");
|
||||
if (itemBlock != null) {
|
||||
itemBlock.setRegistryName(name);
|
||||
GameRegistry.register(itemBlock);
|
||||
Proxies.common.registerItem(itemBlock);
|
||||
}
|
||||
block.setUnlocalizedName("for." + name);
|
||||
GameRegistry.registerBlock(block, itemClass, name, itemCtorArgs);
|
||||
Proxies.common.registerBlock(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
protected <T extends Block> void registerBlock(T block, String name) {
|
||||
registerBlock(block, null, name);
|
||||
}
|
||||
|
||||
protected static void registerOreDictWildcard(String oreDictName, Block block) {
|
||||
|
||||
@@ -23,19 +23,23 @@ public class BlockRegistryCore extends BlockRegistry {
|
||||
public final BlockResourceStorage resourceStorage;
|
||||
|
||||
public BlockRegistryCore() {
|
||||
core = registerBlock(new BlockCore(), ItemBlockForestry.class, "core");
|
||||
core = new BlockCore();
|
||||
registerBlock(core, new ItemBlockForestry(core), "core");
|
||||
|
||||
soil = registerBlock(new BlockSoil(), ItemBlockForestry.class, "soil");
|
||||
soil = new BlockSoil();
|
||||
registerBlock(soil, new ItemBlockForestry(soil), "soil");
|
||||
soil.setHarvestLevel("shovel", 0, soil.getStateFromMeta(0));
|
||||
soil.setHarvestLevel("shovel", 0, soil.getStateFromMeta(1));
|
||||
|
||||
resources = registerBlock(new BlockResourceOre(), ItemBlockForestry.class, "resources");
|
||||
resources = new BlockResourceOre();
|
||||
registerBlock(resources, new ItemBlockForestry(resources), "resources");
|
||||
resources.setHarvestLevel("pickaxe", 1);
|
||||
OreDictionary.registerOre("oreApatite", resources.get(EnumResourceType.APATITE, 1));
|
||||
OreDictionary.registerOre("oreCopper", resources.get(EnumResourceType.COPPER, 1));
|
||||
OreDictionary.registerOre("oreTin", resources.get(EnumResourceType.TIN, 1));
|
||||
|
||||
resourceStorage = registerBlock(new BlockResourceStorage(), ItemBlockForestry.class, "resourceStorage");
|
||||
resourceStorage = new BlockResourceStorage();
|
||||
registerBlock(resourceStorage, new ItemBlockForestry(resourceStorage), "resourceStorage");
|
||||
resourceStorage.setHarvestLevel("pickaxe", 0);
|
||||
OreDictionary.registerOre("blockApatite", resourceStorage.get(EnumResourceType.APATITE));
|
||||
OreDictionary.registerOre("blockCopper", resourceStorage.get(EnumResourceType.COPPER));
|
||||
|
||||
@@ -17,6 +17,7 @@ public class BlockRegistryEnergy extends BlockRegistry {
|
||||
public final BlockEngine engine;
|
||||
|
||||
public BlockRegistryEnergy() {
|
||||
engine = registerBlock(new BlockEngine(), ItemEngine.class, "engine");
|
||||
engine = new BlockEngine();
|
||||
registerBlock(engine, new ItemEngine(engine), "engine");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,10 @@ public class BlockRegistryFactory extends BlockRegistry {
|
||||
public final BlockFactoryPlain factoryPlain;
|
||||
|
||||
public BlockRegistryFactory() {
|
||||
factoryTESR = registerBlock(new BlockFactoryTESR(), ItemBlockForestry.class, "factory");
|
||||
factoryPlain = registerBlock(new BlockFactoryPlain(), ItemBlockNBT.class, "factory2");
|
||||
factoryTESR = new BlockFactoryTESR();
|
||||
registerBlock(factoryTESR, new ItemBlockForestry(factoryTESR), "factory");
|
||||
|
||||
factoryPlain = new BlockFactoryPlain();
|
||||
registerBlock(factoryPlain, new ItemBlockNBT(factoryPlain), "factory2");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,10 @@ public class BlockRegistryFarming extends BlockRegistry {
|
||||
public final BlockFarm farm;
|
||||
|
||||
public BlockRegistryFarming() {
|
||||
mushroom = registerBlock(new BlockMushroom(), ItemBlockForestry.class, "mushroom");
|
||||
farm = registerBlock(new BlockFarm(), ItemBlockFarm.class, "ffarm");
|
||||
mushroom = new BlockMushroom();
|
||||
registerBlock(mushroom, new ItemBlockForestry(mushroom), "mushroom");
|
||||
|
||||
farm = new BlockFarm();
|
||||
registerBlock(farm, new ItemBlockFarm(farm), "ffarm");
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,14 @@ public class BlockRegistryLepidopterology extends BlockRegistry {
|
||||
public final BlockSolidCocoon solidCocoon;
|
||||
|
||||
public BlockRegistryLepidopterology() {
|
||||
lepidopterology = registerBlock(new BlockLepidopterology(), ItemBlockForestry.class, "lepidopterology");
|
||||
lepidopterology = new BlockLepidopterology();
|
||||
registerBlock(lepidopterology, new ItemBlockForestry(lepidopterology), "lepidopterology");
|
||||
|
||||
AlleleButterflyCocoon.createAlleles();
|
||||
cocoon = registerBlock(new BlockCocoon(), ItemBlockForestry.class, "cocoon");
|
||||
solidCocoon = registerBlock(new BlockSolidCocoon(), ItemBlockForestry.class, "cocoon.solid");
|
||||
cocoon = new BlockCocoon();
|
||||
registerBlock(cocoon, new ItemBlockForestry(cocoon), "cocoon");
|
||||
|
||||
solidCocoon = new BlockSolidCocoon();
|
||||
registerBlock(solidCocoon, new ItemBlockForestry(solidCocoon), "cocoon.solid");
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class BlockRegistryMail extends BlockRegistry {
|
||||
public final BlockMail mail;
|
||||
|
||||
public BlockRegistryMail() {
|
||||
mail = registerBlock(new BlockMail(), ItemBlockForestry.class, "mail");
|
||||
mail = new BlockMail();
|
||||
registerBlock(mail, new ItemBlockForestry(mail), "mail");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user