From d530f10f08b2673a7b354343763bbdd2b8b27bea Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Fri, 20 Sep 2013 09:34:20 -0400 Subject: [PATCH] BlockRegistryChanges --- src/dark/farmtech/FarmTech.java | 16 ++-- src/dark/farmtech/blocks/BlockFarmSoil.java | 13 ++-- .../farmtech/machines/BlockBasicMachine.java | 77 ------------------- src/dark/farmtech/machines/BlockFT.java | 8 +- 4 files changed, 16 insertions(+), 98 deletions(-) delete mode 100644 src/dark/farmtech/machines/BlockBasicMachine.java diff --git a/src/dark/farmtech/FarmTech.java b/src/dark/farmtech/FarmTech.java index 8fd4ed16..c14a9937 100644 --- a/src/dark/farmtech/FarmTech.java +++ b/src/dark/farmtech/FarmTech.java @@ -1,9 +1,7 @@ package dark.farmtech; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; @@ -25,11 +23,10 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import dark.api.farm.CropAutomationHandler; import dark.api.farm.DecayMatterList; -import dark.core.common.BlockRegistry; -import dark.core.common.BlockRegistry.BlockData; import dark.core.common.DarkMain; import dark.core.prefab.ModPrefab; import dark.core.prefab.items.ItemBlockHolder; +import dark.core.registration.ModObjectRegistry; import dark.farmtech.blocks.BlockFarmSoil; @Mod(modid = FarmTech.MOD_ID, name = FarmTech.MOD_NAME, version = FarmTech.VERSION, dependencies = "after:DarkCore", useMetadata = true) @@ -101,19 +98,16 @@ public class FarmTech extends ModPrefab } @Override - public List getBlocks() + public void registerObjects() { - List dataList = new ArrayList(); CONFIGURATION.load(); - blockFarmSoil = new BlockFarmSoil(this.getNextID()); - BlockRegistry.addBlockToRegister(new BlockData(blockFarmSoil, ItemBlockHolder.class, "FTFarmSoil")); + blockFarmSoil = ModObjectRegistry.createNewBlock(FarmTech.MOD_ID, BlockFarmSoil.class, ItemBlockHolder.class); - String compostList = CONFIGURATION.get("DecayMatter", "List", "5::8000:1", "Items or blocks beyond the built in ones that can be turned into compost. Entries go BlockID:Meta:Time:Amount").getString(); - DecayMatterList.parseConfigString(compostList); + //String compostList = CONFIGURATION.get("DecayMatter", "List", "5::8000:1", "Items or blocks beyond the built in ones that can be turned into compost. Entries go BlockID:Meta:Time:Amount").getString(); + //DecayMatterList.parseConfigString(compostList); CONFIGURATION.save(); - return dataList; } @Override diff --git a/src/dark/farmtech/blocks/BlockFarmSoil.java b/src/dark/farmtech/blocks/BlockFarmSoil.java index 2239573e..bba91710 100644 --- a/src/dark/farmtech/blocks/BlockFarmSoil.java +++ b/src/dark/farmtech/blocks/BlockFarmSoil.java @@ -10,26 +10,27 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.core.common.DarkMain; import dark.farmtech.FarmTech; /** Generic block set containing farm blocks: mulch, fertilizer, fertile dirt, mud - * + * * mulch/fertilizer -> fertileDirt -> mud -> dirt - * + * * @mulch is a decor version of fertilizer made from wood. decays very slowly when actually used for * crops. Design is to be used with small plant for decor - * + * * @fertilizer enriches the soil and is used to grow crops faster fertilizer can be created from * anything using several means - * + * * @author darkguardsman */ public class BlockFarmSoil extends Block { Icon mulch, mulch_top, fertilizer, fertileDirt, fertileDirt_top, mud, mud_top; - public BlockFarmSoil(int blockID) + public BlockFarmSoil() { - super(FarmTech.CONFIGURATION.getBlock("Soil", blockID).getInt(), Material.clay); + super(FarmTech.CONFIGURATION.getBlock("FarmSoil", DarkMain.getNextID()).getInt(), Material.clay); this.setUnlocalizedName("FarmBlock"); this.setCreativeTab(FarmTech.TabFarmTech); } diff --git a/src/dark/farmtech/machines/BlockBasicMachine.java b/src/dark/farmtech/machines/BlockBasicMachine.java deleted file mode 100644 index 16c1afa4..00000000 --- a/src/dark/farmtech/machines/BlockBasicMachine.java +++ /dev/null @@ -1,77 +0,0 @@ -package dark.farmtech.machines; - -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class BlockBasicMachine extends BlockFT -{ - Icon generic_side, wood_side, box_Top; - - enum basicMachine - { - COMP_BOX("compostBox", TileEntityCompBox.class); - String name; - Class tile; - - private basicMachine(String name, Class tile) - { - this.name = name; - this.tile = tile; - } - - } - - public BlockBasicMachine(String name, int blockID, Material material) - { - super(name, blockID, material); - // TODO Auto-generated constructor stub - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IconRegister iconReg) - { - super.registerIcons(iconReg); - //this.source = iconReg.registerIcon(DarkMain.getInstance().PREFIX + "infSource"); - } - - @Override - @SideOnly(Side.CLIENT) - public Icon getIcon(int side, int meta) - { - switch (meta) - { - default: - return this.blockIcon; - } - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if (metadata < basicMachine.values().length) - { - try - { - return basicMachine.values()[metadata].tile.newInstance(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - return super.createTileEntity(world, metadata); - } - - @Override - public TileEntity createNewTileEntity(World world) - { - return null; - } - -} diff --git a/src/dark/farmtech/machines/BlockFT.java b/src/dark/farmtech/machines/BlockFT.java index f70c9527..892c930c 100644 --- a/src/dark/farmtech/machines/BlockFT.java +++ b/src/dark/farmtech/machines/BlockFT.java @@ -8,19 +8,19 @@ import net.minecraftforge.common.Configuration; import dark.core.prefab.IExtraObjectInfo; import dark.core.prefab.helpers.Pair; import dark.core.prefab.machine.BlockMachine; +import dark.core.registration.ModObjectRegistry.BlockBuildData; import dark.farmtech.FarmTech; /** Prefab class for all farm blocks to remove the need for some configuration of the super class - * + * * @author Darkguardsman */ public abstract class BlockFT extends BlockMachine implements IExtraObjectInfo { private boolean hasConfigFile = false; - public BlockFT(String name, int blockID, Material material) + public BlockFT(Class blockClass, String name, Material material) { - super(name, FarmTech.CONFIGURATION, blockID, material); - this.setCreativeTab(FarmTech.TabFarmTech); + super(new BlockBuildData(blockClass, name, material).setCreativeTab(FarmTech.TabFarmTech)); } @Override