diff --git a/src/dark/core/prefab/machine/TileEntityEnergyMachine.java b/src/dark/core/prefab/machine/TileEntityEnergyMachine.java index a44e155a7..7dfb4c694 100644 --- a/src/dark/core/prefab/machine/TileEntityEnergyMachine.java +++ b/src/dark/core/prefab/machine/TileEntityEnergyMachine.java @@ -37,9 +37,9 @@ import dark.api.energy.IPowerLess; import dark.core.common.ExternalModHandler; /** Basic energy tile that can consume power - * + * * Based off both UE universal electrical tile, and electrical tile prefabs - * + * * @author DarkGuardsman */ public class TileEntityEnergyMachine extends TileEntityMachine implements IElectrical, IElectricalStorage, IEnergySink, IEnergySource, IPowerReceptor, IPowerLess { @@ -417,7 +417,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect } /** Produces UE power towards a specific direction. - * + * * @param outputDirection - The output direction. */ public void produceUE(ForgeDirection outputDirection) { @@ -446,7 +446,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect } /** The electrical input direction. - * + * * @return The direction that electricity is entered into the tile. Return null for no input. By * default you can accept power from all sides. */ public EnumSet getInputDirections() @@ -455,7 +455,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect } /** The electrical output direction. - * + * * @return The direction that electricity is output from the tile. Return null for no output. By * default it will return an empty EnumSet. */ public EnumSet getOutputDirections() diff --git a/src/dark/core/registration/ModObjectRegistry.java b/src/dark/core/registration/ModObjectRegistry.java index c3f9d9309..172f5f4b2 100644 --- a/src/dark/core/registration/ModObjectRegistry.java +++ b/src/dark/core/registration/ModObjectRegistry.java @@ -2,7 +2,10 @@ package dark.core.registration; import java.io.File; import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import java.util.Set; import net.minecraft.block.Block; @@ -25,10 +28,11 @@ import dark.core.prefab.ModPrefab; import dark.core.prefab.machine.BlockMachine; /** Handler to make registering all parts of a mod's objects that are loaded into the game by forge - * + * * @author DarkGuardsman */ public class ModObjectRegistry { + public static HashMap registredBlocks = new HashMap(); @SidedProxy(clientSide = "dark.core.registration.ClientRegistryProxy", serverSide = "dark.core.registration.RegistryProxy") public static RegistryProxy proxy; @@ -55,6 +59,7 @@ public class ModObjectRegistry Block block = null; if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true))) { + //TODO redesign to catch blockID conflict try { block = blockClass.newInstance(); @@ -65,6 +70,7 @@ public class ModObjectRegistry } if (block != null) { + registredBlocks.put(block, name); proxy.registerBlock(block, itemClass, name, modID); ModObjectRegistry.finishCreation(block, null); } @@ -166,6 +172,39 @@ public class ModObjectRegistry } + /** Method to get block via name + * + * @param blockName + * @return Block requested */ + public static Block getBlock(String blockName) + { + for (Entry entry : registredBlocks.entrySet()) + { + String name = entry.getKey().getUnlocalizedName().replace("tile.", ""); + if (name.equalsIgnoreCase(blockName)) + { + return entry.getKey(); + } + } + return null; + } + + /** Method to get block via id + * + * @param blockID + * @return Block requested */ + public static Block getBlock(int blockID) + { + for (Entry entry : registredBlocks.entrySet()) + { + if (entry.getKey().blockID == blockID) + { + return entry.getKey(); + } + } + return null; + } + public static Block createNewFluidBlock(String modDomainPrefix, Configuration config, Fluid fluid) { Block fluidBlock = null; @@ -244,7 +283,7 @@ public class ModObjectRegistry } /** Adds a tileEntity to be registered when this block is registered - * + * * @param name - mod name for the tileEntity, should be unique * @param class1 - new instance of the TileEntity to register */ public BlockBuildData addTileEntity(String name, Class class1)