Added to the object reg
This commit is contained in:
parent
16f4403a82
commit
784e05ef30
2 changed files with 46 additions and 7 deletions
|
@ -37,9 +37,9 @@ import dark.api.energy.IPowerLess;
|
||||||
import dark.core.common.ExternalModHandler;
|
import dark.core.common.ExternalModHandler;
|
||||||
|
|
||||||
/** Basic energy tile that can consume power
|
/** Basic energy tile that can consume power
|
||||||
*
|
*
|
||||||
* Based off both UE universal electrical tile, and electrical tile prefabs
|
* Based off both UE universal electrical tile, and electrical tile prefabs
|
||||||
*
|
*
|
||||||
* @author DarkGuardsman */
|
* @author DarkGuardsman */
|
||||||
public class TileEntityEnergyMachine extends TileEntityMachine implements IElectrical, IElectricalStorage, IEnergySink, IEnergySource, IPowerReceptor, IPowerLess
|
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.
|
/** Produces UE power towards a specific direction.
|
||||||
*
|
*
|
||||||
* @param outputDirection - The output direction. */
|
* @param outputDirection - The output direction. */
|
||||||
public void produceUE(ForgeDirection outputDirection)
|
public void produceUE(ForgeDirection outputDirection)
|
||||||
{
|
{
|
||||||
|
@ -446,7 +446,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The electrical input direction.
|
/** The electrical input direction.
|
||||||
*
|
*
|
||||||
* @return The direction that electricity is entered into the tile. Return null for no input. By
|
* @return The direction that electricity is entered into the tile. Return null for no input. By
|
||||||
* default you can accept power from all sides. */
|
* default you can accept power from all sides. */
|
||||||
public EnumSet<ForgeDirection> getInputDirections()
|
public EnumSet<ForgeDirection> getInputDirections()
|
||||||
|
@ -455,7 +455,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The electrical output direction.
|
/** The electrical output direction.
|
||||||
*
|
*
|
||||||
* @return The direction that electricity is output from the tile. Return null for no output. By
|
* @return The direction that electricity is output from the tile. Return null for no output. By
|
||||||
* default it will return an empty EnumSet. */
|
* default it will return an empty EnumSet. */
|
||||||
public EnumSet<ForgeDirection> getOutputDirections()
|
public EnumSet<ForgeDirection> getOutputDirections()
|
||||||
|
|
|
@ -2,7 +2,10 @@ package dark.core.registration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -25,10 +28,11 @@ import dark.core.prefab.ModPrefab;
|
||||||
import dark.core.prefab.machine.BlockMachine;
|
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
|
/** Handler to make registering all parts of a mod's objects that are loaded into the game by forge
|
||||||
*
|
*
|
||||||
* @author DarkGuardsman */
|
* @author DarkGuardsman */
|
||||||
public class ModObjectRegistry
|
public class ModObjectRegistry
|
||||||
{
|
{
|
||||||
|
public static HashMap<Block, String> registredBlocks = new HashMap<Block, String>();
|
||||||
|
|
||||||
@SidedProxy(clientSide = "dark.core.registration.ClientRegistryProxy", serverSide = "dark.core.registration.RegistryProxy")
|
@SidedProxy(clientSide = "dark.core.registration.ClientRegistryProxy", serverSide = "dark.core.registration.RegistryProxy")
|
||||||
public static RegistryProxy proxy;
|
public static RegistryProxy proxy;
|
||||||
|
@ -55,6 +59,7 @@ public class ModObjectRegistry
|
||||||
Block block = null;
|
Block block = null;
|
||||||
if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
|
if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
|
||||||
{
|
{
|
||||||
|
//TODO redesign to catch blockID conflict
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
block = blockClass.newInstance();
|
block = blockClass.newInstance();
|
||||||
|
@ -65,6 +70,7 @@ public class ModObjectRegistry
|
||||||
}
|
}
|
||||||
if (block != null)
|
if (block != null)
|
||||||
{
|
{
|
||||||
|
registredBlocks.put(block, name);
|
||||||
proxy.registerBlock(block, itemClass, name, modID);
|
proxy.registerBlock(block, itemClass, name, modID);
|
||||||
ModObjectRegistry.finishCreation(block, null);
|
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<Block,String> 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<Block,String> entry : registredBlocks.entrySet())
|
||||||
|
{
|
||||||
|
if (entry.getKey().blockID == blockID)
|
||||||
|
{
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Block createNewFluidBlock(String modDomainPrefix, Configuration config, Fluid fluid)
|
public static Block createNewFluidBlock(String modDomainPrefix, Configuration config, Fluid fluid)
|
||||||
{
|
{
|
||||||
Block fluidBlock = null;
|
Block fluidBlock = null;
|
||||||
|
@ -244,7 +283,7 @@ public class ModObjectRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a tileEntity to be registered when this block is registered
|
/** Adds a tileEntity to be registered when this block is registered
|
||||||
*
|
*
|
||||||
* @param name - mod name for the tileEntity, should be unique
|
* @param name - mod name for the tileEntity, should be unique
|
||||||
* @param class1 - new instance of the TileEntity to register */
|
* @param class1 - new instance of the TileEntity to register */
|
||||||
public BlockBuildData addTileEntity(String name, Class<? extends TileEntity> class1)
|
public BlockBuildData addTileEntity(String name, Class<? extends TileEntity> class1)
|
||||||
|
|
Loading…
Reference in a new issue