FixedIssuesWithRegistry
This commit is contained in:
parent
5fe80517a7
commit
07eb79cdd0
7 changed files with 48 additions and 68 deletions
|
@ -33,6 +33,7 @@ import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
|||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import dark.api.ProcessorRecipes;
|
||||
import dark.core.common.blocks.BlockBasalt;
|
||||
import dark.core.common.blocks.BlockColorGlass;
|
||||
import dark.core.common.blocks.BlockColorGlowGlass;
|
||||
import dark.core.common.blocks.BlockColorSand;
|
||||
|
@ -184,15 +185,19 @@ public class DarkMain extends ModPrefab
|
|||
/* CONFIGS */
|
||||
CONFIGURATION.load();
|
||||
/* BLOCKS */
|
||||
blockMulti = (BlockMulti) ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockMulti.class, false);
|
||||
basicMachine = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockBasicMachine.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockOre = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockOre.class, ItemBlockOre.class);
|
||||
CoreRecipeLoader.blockWire = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockWire.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockDebug = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockDebug.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockStainGlass = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockColorGlass.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockColorSand = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockColorSand.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockBasalt = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockColorSand.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockGlowGlass = ModObjectRegistry.createNewBlock(DarkMain.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class);
|
||||
Block m = ModObjectRegistry.createNewBlock("DMBlockMulti", DarkMain.MOD_ID, BlockMulti.class, false);
|
||||
if (m instanceof BlockMulti)
|
||||
{
|
||||
blockMulti = (BlockMulti) m;
|
||||
}
|
||||
basicMachine = ModObjectRegistry.createNewBlock("DMBlockBasicMachine", DarkMain.MOD_ID, BlockBasicMachine.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockOre = ModObjectRegistry.createNewBlock("DMBlockOre", DarkMain.MOD_ID, BlockOre.class, ItemBlockOre.class);
|
||||
CoreRecipeLoader.blockWire = ModObjectRegistry.createNewBlock("DMBlockWire", DarkMain.MOD_ID, BlockWire.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockDebug = ModObjectRegistry.createNewBlock("DMBlockDebug", DarkMain.MOD_ID, BlockDebug.class, ItemBlockHolder.class);
|
||||
CoreRecipeLoader.blockStainGlass = ModObjectRegistry.createNewBlock("DMBlockStainedGlass", DarkMain.MOD_ID, BlockColorGlass.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockColorSand = ModObjectRegistry.createNewBlock("DMBlockColorSand", DarkMain.MOD_ID, BlockColorSand.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockBasalt = ModObjectRegistry.createNewBlock("DMBlockBasalt", DarkMain.MOD_ID, BlockBasalt.class, ItemBlockColored.class);
|
||||
CoreRecipeLoader.blockGlowGlass = ModObjectRegistry.createNewBlock("DMBlockGlowGlass", DarkMain.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class);
|
||||
|
||||
/* ITEMS */
|
||||
CoreRecipeLoader.itemTool = new ItemTools(ITEM_ID_PREFIX++, DarkMain.CONFIGURATION);
|
||||
|
@ -253,41 +258,6 @@ public class DarkMain extends ModPrefab
|
|||
return "dark";
|
||||
}
|
||||
|
||||
/** Creative tab for generic items and block that don't belong in any other tab */
|
||||
public static CreativeTabs tabGSMGeneral = new CreativeTabs("AutomationMachines")
|
||||
{
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
return new ItemStack(Item.ingotIron, 1, 0);
|
||||
}
|
||||
};
|
||||
/** Creative tab for High tech and industrial based items and blocks that don't belong in any
|
||||
* other tab */
|
||||
public static CreativeTabs tabIndustrial = new CreativeTabs("IndustrialMachines")
|
||||
{
|
||||
ItemStack tabItemStack = new ItemStack(Item.ingotIron, 1, 0);
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
if (DarkMain.basicMachine != null)
|
||||
{
|
||||
new ItemStack(DarkMain.basicMachine.blockID, 1, 0);
|
||||
}
|
||||
return tabItemStack;
|
||||
}
|
||||
};
|
||||
/** Creative tab for general castle and fortress related items and blocks that don't belong in
|
||||
* any other tab */
|
||||
public static CreativeTabs tabHydrualic = new CreativeTabs("HydraulicMachines")
|
||||
{
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
return new ItemStack(Item.ingotIron, 1, 0);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class BlockOre extends Block implements IExtraObjectInfo
|
|||
{
|
||||
if (EnumMeterials.values()[i].doWorldGen)
|
||||
{
|
||||
OreDictionary.registerOre(EnumMeterials.values()[i].name + "Ore", new ItemStack(CoreRecipeLoader.blockOre.blockID, 1, i));
|
||||
OreDictionary.registerOre(EnumMeterials.values()[i].name + "Ore", new ItemStack(this.blockID, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.Configuration;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.common.DMCreativeTab;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
|
@ -23,9 +24,9 @@ public class BlockDebug extends BlockMachine implements IExtraObjectInfo
|
|||
{
|
||||
public static float DebugWattOut, DebugWattDemand;
|
||||
|
||||
public BlockDebug(int blockID)
|
||||
public BlockDebug()
|
||||
{
|
||||
super(new BlockBuildData(BlockDebug.class, "DebugBlock", Material.clay).setCreativeTab(DarkMain.tabIndustrial));
|
||||
super(new BlockBuildData(BlockDebug.class, "DebugBlock", Material.clay).setCreativeTab(DMCreativeTab.tabIndustrial));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import dark.core.common.CommonProxy;
|
||||
import dark.core.common.DMCreativeTab;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
|
@ -25,7 +26,7 @@ public class BlockBasicMachine extends BlockMachine implements IExtraObjectInfo
|
|||
|
||||
public BlockBasicMachine()
|
||||
{
|
||||
super(new BlockBuildData(BlockBasicMachine.class, "BasicMachine", UniversalElectricity.machine).setCreativeTab(DarkMain.tabIndustrial));
|
||||
super(new BlockBuildData(BlockBasicMachine.class, "BasicMachine", UniversalElectricity.machine).setCreativeTab(DMCreativeTab.tabIndustrial));
|
||||
this.setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraftforge.common.Configuration;
|
|||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.TileEntityConductor;
|
||||
import dark.core.common.DMCreativeTab;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
|
@ -32,7 +33,7 @@ public class BlockWire extends BlockMachine implements IExtraObjectInfo
|
|||
|
||||
public BlockWire()
|
||||
{
|
||||
super(new BlockBuildData(BlockWire.class, "DMWire", Material.cloth).setCreativeTab(DarkMain.tabIndustrial));
|
||||
super(new BlockBuildData(BlockWire.class, "DMWire", Material.cloth).setCreativeTab(DMCreativeTab.tabIndustrial));
|
||||
this.setStepSound(soundClothFootstep);
|
||||
this.setResistance(0.2F);
|
||||
this.setHardness(0.1f);
|
||||
|
|
|
@ -19,7 +19,7 @@ public class BlockFluid extends BlockFluidFinite
|
|||
|
||||
public BlockFluid(String prefix, Fluid fluid, Configuration config)
|
||||
{
|
||||
super(config.getBlock(fluid.getName(), DarkMain.getNextID()).getInt(), fluid, Material.water);
|
||||
super(config.getBlock("BlockFluid" + fluid.getName(), DarkMain.getNextID()).getInt(), fluid, Material.water);
|
||||
this.fluid = fluid;
|
||||
if (prefix != null && prefix.contains(":"))
|
||||
{
|
||||
|
|
|
@ -31,25 +31,25 @@ public class ModObjectRegistry
|
|||
{
|
||||
public static Configuration masterBlockConfig = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/EnabledBlocks.cfg"));
|
||||
|
||||
public static Block createNewBlock(String modID, Class<? extends Block> blockClass)
|
||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass)
|
||||
{
|
||||
return ModObjectRegistry.createNewBlock(modID, blockClass, true);
|
||||
return ModObjectRegistry.createNewBlock(name, modID, blockClass, true);
|
||||
}
|
||||
|
||||
public static Block createNewBlock(String modID, Class<? extends Block> blockClass, boolean canDisable)
|
||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, boolean canDisable)
|
||||
{
|
||||
return ModObjectRegistry.createNewBlock(modID, blockClass, null, canDisable);
|
||||
return ModObjectRegistry.createNewBlock(name, modID, blockClass, null, canDisable);
|
||||
}
|
||||
|
||||
public static Block createNewBlock(String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass)
|
||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass)
|
||||
{
|
||||
return createNewBlock(modID, blockClass, itemClass, true);
|
||||
return createNewBlock(name, modID, blockClass, itemClass, true);
|
||||
}
|
||||
|
||||
public static Block createNewBlock(String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass, boolean canDisable)
|
||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass, boolean canDisable)
|
||||
{
|
||||
Block block = null;
|
||||
if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + block.getUnlocalizedName().replace("tile.", ""), true).getBoolean(true)))
|
||||
if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ public class ModObjectRegistry
|
|||
if (block != null)
|
||||
{
|
||||
ModObjectRegistry.finishCreation(block, null);
|
||||
ModObjectRegistry.registerBlock(block, itemClass, block.getUnlocalizedName().replace("tile.", ""), modID);
|
||||
ModObjectRegistry.registerBlock(block, itemClass, name, modID);
|
||||
}
|
||||
}
|
||||
return block;
|
||||
|
@ -91,14 +91,21 @@ public class ModObjectRegistry
|
|||
{
|
||||
|
||||
constructor.setAccessible(true);
|
||||
block = (Block) constructor.newInstance(buildData.config.getBlock(buildData.blockName, DarkMain.getNextID()), buildData.blockMaterial);
|
||||
|
||||
Object obj = (Block) constructor.newInstance(buildData.config.getBlock(buildData.blockName, DarkMain.getNextID()), buildData.blockMaterial);
|
||||
if (obj instanceof Block)
|
||||
{
|
||||
block = (Block) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
constructor.setAccessible(true);
|
||||
block = (Block) constructor.newInstance(buildData);
|
||||
Object obj = constructor.newInstance(buildData);
|
||||
if (obj instanceof Block)
|
||||
{
|
||||
block = (Block) obj;
|
||||
}
|
||||
|
||||
}
|
||||
ModObjectRegistry.finishCreation(block, buildData);
|
||||
|
@ -235,13 +242,13 @@ public class ModObjectRegistry
|
|||
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemClass, String name, String modID)
|
||||
{
|
||||
if (block != null && name != null && !name.isEmpty())
|
||||
if (block != null && name != null)
|
||||
{
|
||||
if (itemClass == null)
|
||||
{
|
||||
itemClass = ItemBlock.class;
|
||||
}
|
||||
GameRegistry.registerBlock(block, itemClass, name, modID);
|
||||
|
||||
System.out.println("Block: " + (block == null ? "null" : block.toString()));
|
||||
System.out.println("Item: " + (itemClass == null ? "null" : itemClass.toString()));
|
||||
System.out.println("name: " + name.toString());
|
||||
GameRegistry.registerBlock(block, itemClass == null ? ItemBlock.class : itemClass, name, modID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue