added a way to check if no power system is loaded
This will make is possible for mods using the lib to just check if a power system they can use it loaded.
This commit is contained in:
parent
2827565c7a
commit
7f34d242cd
3 changed files with 62 additions and 8 deletions
|
@ -6,7 +6,6 @@ import java.util.logging.Logger;
|
|||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import basiccomponents.common.BasicComponents;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
@ -15,10 +14,8 @@ import dark.library.effects.FXBeam;
|
|||
|
||||
public class DarkMain
|
||||
{
|
||||
private static boolean isInit = false;
|
||||
|
||||
private static boolean loadedItems = false;
|
||||
|
||||
public static boolean runPowerLess = true;
|
||||
/* RESOURCE FILE PATHS */
|
||||
public static final String RESOURCE_PATH = "/mods/dark/";
|
||||
public static final String TEXTURE_DIRECTORY = RESOURCE_PATH + "textures/";
|
||||
|
@ -32,6 +29,17 @@ public class DarkMain
|
|||
|
||||
public static final Logger LOGGER = Logger.getLogger("Dark-Lib");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Renders a laser beam from one power to another by a set color for a set time
|
||||
*
|
||||
* @param world - world this laser is to be rendered in
|
||||
* @param position - start vector3
|
||||
* @param target - end vector3
|
||||
* @param color - color of the beam
|
||||
* @param age - life of the beam in 1/20 secs
|
||||
*/
|
||||
public static void renderBeam(World world, Vector3 position, Vector3 target, Color color, int age)
|
||||
{
|
||||
if (world.isRemote)
|
||||
|
@ -40,6 +48,9 @@ public class DarkMain
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a bullet tracer from one spot to another will later be replaced with start and degree
|
||||
*/
|
||||
public static void renderTracer(World world, Vector3 position, Vector3 target)
|
||||
{
|
||||
if (world.isRemote)
|
||||
|
@ -48,11 +59,14 @@ public class DarkMain
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads most of the items from basic components to be used
|
||||
*/
|
||||
public static void forceLoadBCItems(Object mod, String channel)
|
||||
{
|
||||
BasicComponents.register(mod, channel);
|
||||
|
||||
if (!isInit)
|
||||
if (!loadedItems)
|
||||
{
|
||||
// UniversalElectricity.CONFIGURATION.load();
|
||||
BasicComponents.requestItem("ingotCopper", 0);
|
||||
|
@ -79,7 +93,7 @@ public class DarkMain
|
|||
BasicComponents.registerInfiniteBattery(0);
|
||||
BasicComponents.registerBattery(0);
|
||||
|
||||
isInit = true;
|
||||
loadedItems = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
40
src/minecraft/dark/library/PowerSystems.java
Normal file
40
src/minecraft/dark/library/PowerSystems.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package dark.library;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public enum PowerSystems
|
||||
{
|
||||
INDUSTRIALCRAFT("IC2"), MEKANISM("Mekanism"), BUILDCRAFT("BuildCraft|Energy");
|
||||
public String id;
|
||||
|
||||
private PowerSystems(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(PowerSystems... optional)
|
||||
{
|
||||
for (int i = 0; i < optional.length; i++)
|
||||
{
|
||||
if (isPowerSystemLoaded(optional[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if one of the mods listed in the PowerSystem enum is loaded
|
||||
*/
|
||||
public static boolean isPowerSystemLoaded(PowerSystems power)
|
||||
{
|
||||
return power != null && Loader.isModLoaded(power.id);
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import dark.library.DarkMain;
|
||||
import dark.library.PowerSystems;
|
||||
import dark.library.access.AccessLevel;
|
||||
import dark.library.access.UserAccess;
|
||||
import dark.library.access.interfaces.ISpecialAccess;
|
||||
|
@ -63,7 +63,7 @@ public abstract class TileEntityTerminal extends TileEntityUniversalRunnable imp
|
|||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (DarkMain.runPowerLess)
|
||||
if (PowerSystems.runPowerLess(PowerSystems.INDUSTRIALCRAFT, PowerSystems.BUILDCRAFT, PowerSystems.MEKANISM))
|
||||
{
|
||||
this.wattsReceived += this.getRequest().getWatts();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue