Toying with annotations
Plan is to replace IExtraObjectInfo with annotations to be used in combo with the new reflection based block registration system. Might try this on a few more things and see were it goes.
This commit is contained in:
parent
a72c06950e
commit
657e3cddf9
9 changed files with 46 additions and 7 deletions
|
@ -55,6 +55,7 @@ import dark.core.prefab.ModPrefab;
|
|||
import dark.core.prefab.helpers.FluidHelper;
|
||||
import dark.core.prefab.items.ItemBlockHolder;
|
||||
import dark.core.prefab.machine.BlockMulti;
|
||||
import dark.core.registration.ModObjectRegistry;
|
||||
|
||||
/** @author HangCow, DarkGuardsman */
|
||||
@Mod(modid = DarkMain.MOD_ID, name = DarkMain.MOD_NAME, version = DarkMain.VERSION, dependencies = "after:BuildCraft|Energy", useMetadata = true)
|
||||
|
|
|
@ -13,11 +13,11 @@ 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.ModObjectRegistry.BlockBuildData;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
import dark.core.prefab.machine.BlockMachine;
|
||||
import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
||||
|
||||
public class BlockDebug extends BlockMachine implements IExtraObjectInfo
|
||||
{
|
||||
|
|
|
@ -13,12 +13,12 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import dark.core.common.ModObjectRegistry.BlockBuildData;
|
||||
import dark.core.common.CommonProxy;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
import dark.core.prefab.machine.BlockMachine;
|
||||
import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
||||
|
||||
public class BlockBasicMachine extends BlockMachine implements IExtraObjectInfo
|
||||
{
|
||||
|
|
|
@ -16,11 +16,11 @@ import net.minecraftforge.common.Configuration;
|
|||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.TileEntityConductor;
|
||||
import dark.core.common.ModObjectRegistry.BlockBuildData;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
import dark.core.prefab.machine.BlockMachine;
|
||||
import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
||||
|
||||
public class BlockWire extends BlockMachine implements IExtraObjectInfo
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import dark.core.common.ModObjectRegistry;
|
||||
import dark.core.registration.ModObjectRegistry;
|
||||
|
||||
public abstract class ModPrefab
|
||||
{
|
||||
|
|
|
@ -12,8 +12,8 @@ import universalelectricity.prefab.block.BlockTile;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.api.parts.INetworkPart;
|
||||
import dark.core.common.ModObjectRegistry.BlockBuildData;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
||||
|
||||
/** Basic TileEntity Container class designed to be used by generic machines. It is suggested that
|
||||
* each mod using this create there own basic block extending this to reduce need to input config
|
||||
|
|
13
src/dark/core/registration/BlockConfigFile.java
Normal file
13
src/dark/core/registration/BlockConfigFile.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package dark.core.registration;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface BlockConfigFile
|
||||
{
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dark.core.common;
|
||||
package dark.core.registration;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraftforge.common.Configuration;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
import dark.core.prefab.machine.BlockMachine;
|
||||
|
@ -110,7 +111,7 @@ public class ModObjectRegistry
|
|||
|
||||
public static void finishCreation(Block block, BlockBuildData data)
|
||||
{
|
||||
if (data != null)
|
||||
if (data != null && block != null)
|
||||
{
|
||||
if (data.tiles != null)
|
||||
{
|
||||
|
@ -119,6 +120,10 @@ public class ModObjectRegistry
|
|||
GameRegistry.registerTileEntityWithAlternatives(par.getValue(), par.getKey(), "DM" + par.getKey());
|
||||
}
|
||||
}
|
||||
if (data.creativeTab != null)
|
||||
{
|
||||
block.setCreativeTab(data.creativeTab);
|
||||
}
|
||||
}
|
||||
if (block instanceof IExtraObjectInfo)
|
||||
{
|
20
src/dark/core/registration/TileEntityUser.java
Normal file
20
src/dark/core/registration/TileEntityUser.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package dark.core.registration;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface TileEntityUser
|
||||
{
|
||||
/** Array of tile entities this tile uses. Is a parallel array in combo with tileEntitiesName */
|
||||
Class<? extends TileEntity>[] tileEntities() default {};
|
||||
|
||||
/** Array of tile entities names that are used to register the tile entity. Is a parallel array
|
||||
* in combo with tileEntities */
|
||||
Class<? extends TileEntity>[] tileEntitiesNames() default {};
|
||||
}
|
Loading…
Reference in a new issue