This commit is contained in:
Robert 2013-12-18 21:16:31 -05:00
parent 425edd2bd6
commit 83c0e9cb38
7 changed files with 46 additions and 74 deletions

View file

@ -35,21 +35,45 @@ public class CoreRegistry
public static Configuration masterBlockConfig = new Configuration(new File(Loader.instance().getConfigDir(), "objects/EnabledBlocks.cfg"));
/** Generates a block using reflection, and runs it threw config checks
*
* @param name - name to register the block with
* @param modID - mod id to register the block to
* @param blockClass - class to generate the instance from */
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass)
{
return CoreRegistry.createNewBlock(name, modID, blockClass, true);
}
/** Generates a block using reflection, and runs it threw config checks
*
* @param name - name to register the block with
* @param modID - mod id to register the block to
* @param blockClass - class to generate the instance from
* @param canDisable - should we allow the player the option to disable the block */
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, boolean canDisable)
{
return CoreRegistry.createNewBlock(name, modID, blockClass, null, canDisable);
}
/** Generates a block using reflection, and runs it threw config checks
*
* @param name - name to register the block with
* @param modID - mod id to register the block to
* @param blockClass - class to generate the instance from
* @param itemClass - item block to register with the block */
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass)
{
return createNewBlock(name, modID, blockClass, itemClass, true);
}
/** Generates a block using reflection, and runs it threw config checks
*
* @param name - name to register the block with
* @param modID - mod id to register the block to
* @param blockClass - class to generate the instance from
* @param canDisable - should we allow the player the option to disable the block
* @param itemClass - item block to register with the block */
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass, boolean canDisable)
{
Block block = null;
@ -66,7 +90,9 @@ public class CoreRegistry
}
catch (Exception e)
{
System.out.println("\n\nWarning: Block [" + name + "] failed to be created\n");
e.printStackTrace();
System.out.println("\n\n");
}
if (block != null)
{
@ -166,7 +192,6 @@ public class CoreRegistry
Item item = null;
if (clazz != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
{
//TODO redesign to catch blockID conflict
try
{
item = clazz.newInstance();

View file

@ -58,7 +58,6 @@ public class DarkCore
{
if (!load)
{
ExternalModHandler.init();
CoreRegistry.masterBlockConfig.load();
load = true;
}

View file

@ -1,65 +0,0 @@
package com.dark;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.Loader;
/** Handles working with other mod without or without the need of the APIs.
*
* @author DarkGuardsman */
public class ExternalModHandler
{
private static boolean init = false;
/** Calls this to load all external mod settings and handling */
public static void init()
{
if (!init)
{
for (MOD_ID mod : MOD_ID.values())
{
mod.loaded = Loader.isModLoaded(mod.modID);
}
}
}
/** Checks to see if something can run powerless based on mods loaded
*
* @param optional - power system that the device can use
* @return true if free power is to be generated */
public static boolean runPowerLess()
{
for (MOD_ID mod : MOD_ID.values())
{
if (mod.validPowerSystem)
{
return false;
}
}
return true;
}
/** Enum storing MOD_IDs and some general info on mods */
public static enum MOD_ID
{
BUILCRAFT_MOD("BuildCraft|Core", false),
BUILCRAFT_ENERGY_MOD("BuildCraft|Energy", true),
BUILCRAFT_FACTORY_MOD("BuildCraft|Factory", false),
BUILCRAFT_SILICON_MOD("BuildCraft|Silicon", false),
BUILCRAFT_BUILDERS_MOD("BuildCraft|Builders", false),
BUILCRAFT_TRANSPORT_MOD("BuildCraft|Transport", false),
INDUSTRIALCRAFT_MOD("IC2", true),
MEKANISM_MOD("Mekanism", true); //TODO add mek sub mods
public final String modID;
public String modNAME;
public boolean loaded;
public boolean validPowerSystem;
private MOD_ID(String modID, boolean power)
{
this.modID = modID;
this.validPowerSystem = power;
}
}
}

View file

@ -8,10 +8,11 @@ public class IndustryTabs extends CreativeTabs
{
public ItemStack itemStack = new ItemStack(Item.ingotIron, 1, 0);
private static IndustryTabs tabAutomation = new IndustryTabs("Automation");
private static IndustryTabs tabIndustrial = new IndustryTabs("Industrial");
private static IndustryTabs tabHydrualic = new IndustryTabs("Hydraulic");
private static IndustryTabs tabMining = new IndustryTabs("Mining");
private static IndustryTabs tabAutomation;
private static IndustryTabs tabIndustrial;
private static IndustryTabs tabHydrualic;
private static IndustryTabs tabMining;
private static IndustryTabs tabWar;
public IndustryTabs(String label)
{
@ -38,6 +39,15 @@ public class IndustryTabs extends CreativeTabs
return tabAutomation;
}
public static IndustryTabs tabWar()
{
if (tabWar == null)
{
tabWar = new IndustryTabs("War");
}
return tabWar;
}
public static IndustryTabs tabIndustrial()
{
if (tabIndustrial == null)

View file

@ -284,7 +284,7 @@ public class AccessProfile implements ISpecialAccess, IVirtualObject
{
if (this.saveFile == null)
{
this.saveFile = new File(NBTFileHelper.getWorldSaveDirectory(MinecraftServer.getServer().getFolderName()), "CoreMachine/Access/" + this.getID() + ".dat");
this.saveFile = new File(NBTFileHelper.getWorldSaveDirectory(MinecraftServer.getServer().getFolderName()), "Access/Profile/" + this.getID() + ".dat");
}
return this.saveFile;
}

View file

@ -9,6 +9,9 @@ public interface IProfileContainer
/** Return the active profile of the machine. When calling this avoid editing the profile */
public AccessProfile getAccessProfile();
/** Sets the active profile used by the machine. Should only be called by set profile GUI */
public void setAccessProfile(AccessProfile profile);
/** Strait up yes or no can this user access the tile. Any future checks should be done after the
* user has accessed the machine */
public boolean canAccess(String username);

View file

@ -2,10 +2,10 @@ package com.dark.access;
import java.util.List;
/** Used by any object that needs to restrict access to it by a set of users or groups. Make sure to
* always use the default groups(user,admin,owner) so that things work smoothly.
/** Deprecated in favor of using profile containers to reduce on methods in the entity class file
*
* @author DarkGuardsman */
@Deprecated
public interface ISpecialAccess
{
/** Gets the user access instance */