updated ICBM api

This commit is contained in:
DarkGuardsman 2013-07-22 18:24:55 -04:00
parent 090c84b48f
commit 75b5ace914
22 changed files with 295 additions and 151 deletions

View file

@ -6,10 +6,10 @@ package icbm.api;
* @author Calclavia
*/
public interface IBlockFrequency {
public interface IBlockFrequency
{
/**
* @param data
* - Pass an ItemStack if dealing with items with frequencies.
* @param data - Pass an ItemStack if dealing with items with frequencies.
* @return The frequency of this object.
*/
public int getFrequency();
@ -17,10 +17,8 @@ public interface IBlockFrequency {
/**
* Sets the frequency
*
* @param frequency
* - The frequency of this object.
* @param data
* - Pass an ItemStack if dealing with items with frequencies.
* @param frequency - The frequency of this object.
* @param data - Pass an ItemStack if dealing with items with frequencies.
*/
public void setFrequency(int frequency);
}

View file

@ -10,7 +10,8 @@ import java.lang.reflect.Method;
* @author Calclavia
*
*/
public class ICBM {
public class ICBM
{
/**
* Name of the channel and mod ID.
*/
@ -23,12 +24,11 @@ public class ICBM {
public static final String MINOR_VERSION = "@MINOR@";
public static final String REVISION_VERSION = "@REVIS@";
public static final String BUILD_VERSION = "@BUILD@";
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION
+ "." + REVISION_VERSION;
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
/**
* The block ID in which ICBM starts with. ICBM Explosion will count up,
* ICBM Contraption will count down.
* The block ID in which ICBM starts with. ICBM Explosion will count up, ICBM Contraption will
* count down.
*/
public static final int BLOCK_ID_PREFIX = 3880;
@ -42,15 +42,18 @@ public class ICBM {
/**
* @return Gets an explosive object based on the name of the explosive.
*/
public static IExplosive getExplosive(String name) {
if (name != null) {
try {
public static IExplosive getExplosive(String name)
{
if (name != null)
{
try
{
Method method = explosionManager.getMethod("get", String.class);
return (IExplosive) method.invoke(null, name);
} catch (Exception e) {
System.out
.println("ICBM: Failed to get explosive with the name: "
+ name);
}
catch (Exception e)
{
System.out.println("ICBM: Failed to get explosive with the name: " + name);
e.printStackTrace();
}
}

View file

@ -1,13 +1,14 @@
package icbm.api;
/**
* Applied to all blocks that can be used as a camouflage for the camouflage
* block. Use this interface if your block is not a normal block but yet would
* like it to be used as a camouflage material.
* Applied to all blocks that can be used as a camouflage for the camouflage block. Use this
* interface if your block is not a normal block but yet would like it to be used as a camouflage
* material.
*
* @author Calclavia
*
*/
public interface ICamouflageMaterial {
public interface ICamouflageMaterial
{
}

View file

@ -2,7 +2,8 @@ package icbm.api;
import net.minecraft.entity.player.EntityPlayer;
public interface IHackable {
public interface IHackable
{
/**
* Causes the machine to generate a new pass key
*/

View file

@ -8,10 +8,10 @@ import net.minecraft.item.ItemStack;
* @author Calclavia
*/
public interface IItemFrequency {
public interface IItemFrequency
{
/**
* @param data
* - Pass an ItemStack if dealing with items with frequencies.
* @param data - Pass an ItemStack if dealing with items with frequencies.
* @return The frequency of this object.
*/
public int getFrequency(ItemStack itemStack);
@ -19,10 +19,8 @@ public interface IItemFrequency {
/**
* Sets the frequency
*
* @param frequency
* - The frequency of this object.
* @param data
* - Pass an ItemStack if dealing with items with frequencies.
* @param frequency - The frequency of this object.
* @param data - Pass an ItemStack if dealing with items with frequencies.
*/
public void setFrequency(int frequency, ItemStack itemStack);
}

View file

@ -6,7 +6,8 @@ package icbm.api;
* @author Calclavia
*
*/
public interface ILauncherContainer {
public interface ILauncherContainer
{
public IMissile getContainingMissile();
public void setContainingMissile(IMissile missile);

View file

@ -5,13 +5,12 @@ import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.vector.Vector3;
/**
* Applied to all launcher TileEntitiies that operates the launching of
* missiles.
* Applied to all launcher TileEntitiies that operates the launching of missiles.
*
* @author Calclavia
*/
public interface ILauncherController extends IElectricalStorage,
IBlockFrequency {
public interface ILauncherController extends IElectricalStorage, IBlockFrequency
{
/**
* What type of launcher is this?
*/
@ -38,8 +37,7 @@ public interface ILauncherController extends IElectricalStorage,
public Vector3 getTarget();
/**
* @param target
* Sets the target of the launcher
* @param target Sets the target of the launcher
*/
public void setTarget(Vector3 target);

View file

@ -4,25 +4,23 @@ import icbm.api.explosion.IExplosiveContainer;
import universalelectricity.core.vector.Vector3;
/**
* This is an interface applied by all missile entities. You may cast this into
* an @Entity. The "set" version of the function will make the entity do the
* action on the next tick.
* This is an interface applied by all missile entities. You may cast this into an @Entity. The
* "set" version of the function will make the entity do the action on the next tick.
*
* @author Calclavia
*/
public interface IMissile extends IExplosiveContainer {
public interface IMissile extends IExplosiveContainer
{
/**
* Blows up this missile. It will detonate the missile with the appropriate
* explosion.
* Blows up this missile. It will detonate the missile with the appropriate explosion.
*/
public void explode();
public void setExplode();
/**
* Blows up this missile like a TNT explosion. Small explosion used for
* events such as a missile crashing or failure to explode will result in
* this function being called.
* Blows up this missile like a TNT explosion. Small explosion used for events such as a missile
* crashing or failure to explode will result in this function being called.
*/
public void normalExplode();
@ -34,8 +32,8 @@ public interface IMissile extends IExplosiveContainer {
public void dropMissileAsItem();
/**
* The amount of ticks this missile has been flying for. Returns -1 if the
* missile is not flying.
* The amount of ticks this missile has been flying for. Returns -1 if the missile is not
* flying.
*/
public int getTicksInAir();

View file

@ -3,13 +3,13 @@ package icbm.api;
import universalelectricity.core.vector.Vector3;
/**
* Implement this to your entity if you want antiballistic missiles to be able
* to lock onto it.
* Implement this to your entity if you want antiballistic missiles to be able to lock onto it.
*
* @author Calclavia
*
*/
public interface IMissileLockable {
public interface IMissileLockable
{
/**
* Can this entity be locked on by a missile?
*
@ -18,13 +18,10 @@ public interface IMissileLockable {
public boolean canLock(IMissile missile);
/**
* Gets the predicted position of this entity after a specified amount of
* ticks.
* Gets the predicted position of this entity after a specified amount of ticks.
*
* @param ticks
* - The amount of time.
* @return The predicted Vector, or if not predictable, the current
* position.
* @param ticks - The amount of time.
* @return The predicted Vector, or if not predictable, the current position.
*/
public Vector3 getPredictedPosition(int ticks);
}

View file

@ -6,7 +6,8 @@ package icbm.api;
* @author Calclavia
*
*/
public interface ITier {
public interface ITier
{
/**
* Gets the tier of this object
*
@ -17,8 +18,7 @@ public interface ITier {
/**
* Sets the tier of the object
*
* @param tier
* - The tier to be set
* @param tier - The tier to be set
*/
public void setTier(int tier);
}

View file

@ -4,7 +4,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface ITracker {
public interface ITracker
{
public void setTrackingEntity(ItemStack itemStack, Entity entity);
public Entity getTrackingEntity(World worldObj, ItemStack itemStack);

View file

@ -6,6 +6,7 @@ package icbm.api;
* @author Calclavia
*
*/
public enum LauncherType {
public enum LauncherType
{
TRADITIONAL, CRUISE
}

View file

@ -0,0 +1,150 @@
package icbm.api;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.vector.Region2;
/**
* This class allows you to register TileEntities and Entities to be detectable by the ICBM radar.
*
* Make sure you unregister your object when it invalidates!
*
* @author Calclavia
*
*/
public class RadarRegistry
{
private static Set<TileEntity> detectableTileEntities = new HashSet<TileEntity>();
private static Set<Entity> detectableEntities = new HashSet<Entity>();
public static void register(TileEntity tileEntity)
{
if (!detectableTileEntities.contains(tileEntity))
{
detectableTileEntities.add(tileEntity);
}
}
public static void unregister(TileEntity tileEntity)
{
if (detectableTileEntities.contains(tileEntity))
{
detectableTileEntities.remove(tileEntity);
}
}
public static void register(Entity entity)
{
if (!detectableEntities.contains(entity))
{
detectableEntities.add(entity);
}
}
public static void unregister(Entity entity)
{
if (detectableEntities.contains(entity))
{
detectableEntities.remove(entity);
}
}
public static List<TileEntity> getTileEntitiesInArea(Vector2 minVector, Vector2 maxVector)
{
cleanUpArray();
List<TileEntity> returnArray = new ArrayList<TileEntity>();
for (TileEntity tileEntity : detectableTileEntities)
{
if (new Region2(minVector, maxVector).isIn(new Vector3(tileEntity).toVector2()))
{
returnArray.add(tileEntity);
}
}
return returnArray;
}
public static List<Entity> getEntitiesWithinRadius(Vector2 vector, int radius)
{
cleanUpArray();
List<Entity> returnArray = new ArrayList<Entity>();
for (Entity entity : detectableEntities)
{
if (Vector2.distance(vector, new Vector3(entity).toVector2()) <= radius)
{
returnArray.add(entity);
}
}
return returnArray;
}
public static Set<TileEntity> getTileEntities()
{
cleanUpArray();
return detectableTileEntities;
}
public static Set<Entity> getEntities()
{
cleanUpArray();
return detectableEntities;
}
public static void cleanUpArray()
{
try
{
Iterator<TileEntity> it = detectableTileEntities.iterator();
while (it.hasNext())
{
TileEntity tileEntity = it.next();
if (tileEntity == null)
{
it.remove();
}
else if (tileEntity.isInvalid())
{
it.remove();
}
else if (tileEntity.worldObj.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity)
{
it.remove();
}
}
Iterator<Entity> it2 = detectableEntities.iterator();
while (it2.hasNext())
{
Entity entity = it2.next();
if (entity == null)
{
it2.remove();
}
else if (entity.isDead)
{
it2.remove();
}
}
}
catch (Exception e)
{
System.out.println("Failed to clean up radar list properly.");
e.printStackTrace();
}
}
}

View file

@ -7,18 +7,18 @@ import net.minecraftforge.event.Cancelable;
import net.minecraftforge.event.Event;
/**
* Use ForgeSubscribe to subscribe to this event. This event is called every
* single time when an ICBM explosion happens.
* Use ForgeSubscribe to subscribe to this event. This event is called every single time when an
* ICBM explosion happens.
*
* @author Calclavia
*
*/
@Cancelable
public class ExplosionEvent extends Event {
public class ExplosionEvent extends Event
{
/**
* The explosion object. Can be cast into {@link Explosion}. This event can
* be canceled to prevent a specific part of an explosion from being
* executed.
* The explosion object. Can be cast into {@link Explosion}. This event can be canceled to
* prevent a specific part of an explosion from being executed.
*/
public World world;
public double x, y, z;
@ -29,7 +29,8 @@ public class ExplosionEvent extends Event {
*/
public Explosion explosion;
public ExplosionEvent(World world, IExplosion iExplosion) {
public ExplosionEvent(World world, IExplosion iExplosion)
{
this.world = world;
this.iExplosion = iExplosion;
this.x = ((Explosion) iExplosion).explosionX;
@ -38,15 +39,16 @@ public class ExplosionEvent extends Event {
}
/**
* Called before an explosive is detonated to check if detonation is
* possible. You may cancel and explosion here if needed. After this it will
* be a bit too late to prevent destruction without any losses.
* Called before an explosive is detonated to check if detonation is possible. You may cancel
* and explosion here if needed. After this it will be a bit too late to prevent destruction
* without any losses.
*
* @author Calclavia
*
*/
@Cancelable
public static class ExplosivePreDetonationEvent extends Event {
public static class ExplosivePreDetonationEvent extends Event
{
public World world;
public Entity entity;
public double x, y, z;
@ -54,15 +56,15 @@ public class ExplosionEvent extends Event {
public IExplosive explosion;
public ExplosiveType type;
public ExplosivePreDetonationEvent(World world, double x, double y,
double z, ExplosiveType type, IExplosive explosion) {
public ExplosivePreDetonationEvent(World world, double x, double y, double z, ExplosiveType type, IExplosive explosion)
{
this.world = world;
this.type = type;
this.explosion = explosion;
}
public ExplosivePreDetonationEvent(World world, Entity entity,
ExplosiveType type, IExplosive explosion) {
public ExplosivePreDetonationEvent(World world, Entity entity, ExplosiveType type, IExplosive explosion)
{
this.world = world;
this.entity = entity;
this.type = type;
@ -76,8 +78,10 @@ public class ExplosionEvent extends Event {
* @author Calclavia
*
*/
public static class ExplosionConstructionEvent extends ExplosionEvent {
public ExplosionConstructionEvent(World world, IExplosion explosion) {
public static class ExplosionConstructionEvent extends ExplosionEvent
{
public ExplosionConstructionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
@ -88,21 +92,25 @@ public class ExplosionEvent extends Event {
* @author Calclavia
*
*/
public static class PreExplosionEvent extends ExplosionEvent {
public PreExplosionEvent(World world, IExplosion explosion) {
public static class PreExplosionEvent extends ExplosionEvent
{
public PreExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
/**
* Called while an explosion happens. May be called every single tick if
* explosion is procedural. (E.g: Red matter explosive)
* Called while an explosion happens. May be called every single tick if explosion is
* procedural. (E.g: Red matter explosive)
*
* @author Calclavia
*
*/
public static class DoExplosionEvent extends ExplosionEvent {
public DoExplosionEvent(World world, IExplosion explosion) {
public static class DoExplosionEvent extends ExplosionEvent
{
public DoExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
@ -113,8 +121,10 @@ public class ExplosionEvent extends Event {
* @author Calclavia
*
*/
public static class PostExplosionEvent extends ExplosionEvent {
public PostExplosionEvent(World world, IExplosion explosion) {
public static class PostExplosionEvent extends ExplosionEvent
{
public PostExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}

View file

@ -1,6 +1,7 @@
package icbm.api.explosion;
public enum ExplosiveType {
public enum ExplosiveType
{
ALL,
/** An explosive in TNT block form. */
BLOCK,
@ -11,8 +12,10 @@ public enum ExplosiveType {
/** An explosive in vehicle form such as a minecart. */
VEHICLE;
public static ExplosiveType get(int id) {
if (id >= 0 && id < ExplosiveType.values().length) {
public static ExplosiveType get(int id)
{
if (id >= 0 && id < ExplosiveType.values().length)
{
return ExplosiveType.values()[id];
}

View file

@ -4,22 +4,19 @@ import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
/**
* Applied to all blocks that has a custom reaction to EMPs. Blocks not
* TileEntities.
* Applied to all blocks that has a custom reaction to EMPs. Blocks not TileEntities.
*
* @author Calclavia
*
*/
public interface IEMPBlock {
public interface IEMPBlock
{
/**
* Called when this block gets attacked by EMP.
*
* @param world
* - The world object.
* @param position
* - The position.
* @param empExplosive
* - The explosion
* @param world - The world object.
* @param position - The position.
* @param empExplosive - The explosion
*/
public void onEMP(World world, Vector3 position, IExplosion empExplosive);
}

View file

@ -10,17 +10,14 @@ import universalelectricity.core.item.IItemElectric;
* @author Calclavia
*
*/
public interface IEMPItem extends IItemElectric {
public interface IEMPItem extends IItemElectric
{
/**
* Called when this item is being EMPed
*
* @param itemStack
* - The itemstack attacked by EMP
* @param entity
* - The entity holding the item
* @param empExplosives
* - The IExplosive object
* @param itemStack - The itemstack attacked by EMP
* @param entity - The entity holding the item
* @param empExplosives - The IExplosive object
*/
public void onEMP(ItemStack itemStack, Entity entity,
IExplosion empExplosive);
public void onEMP(ItemStack itemStack, Entity entity, IExplosion empExplosive);
}

View file

@ -6,7 +6,8 @@ package icbm.api.explosion;
* @author Calclavia
*
*/
public interface IExplosion {
public interface IExplosion
{
/**
* Called to initiate the explosion.
*/
@ -18,8 +19,8 @@ public interface IExplosion {
public float getRadius();
/**
* @return The energy emitted by this explosive. In Joules and approximately
* based off of a real life equivalent.
* @return The energy emitted by this explosive. In Joules and approximately based off of a real
* life equivalent.
*/
public float getEnergy();
}

View file

@ -10,7 +10,8 @@ import net.minecraft.world.World;
* @author Calclavia
*
*/
public interface IExplosive extends ITier {
public interface IExplosive extends ITier
{
/**
* @return Gets the explosive's ID.
*/
@ -22,26 +23,22 @@ public interface IExplosive extends ITier {
public String getUnlocalizedName();
/**
* @return Gets the specific translated name of the block versions of the
* explosive.
* @return Gets the specific translated name of the block versions of the explosive.
*/
public String getExplosiveName();
/**
* @return Gets the specific translated name of the grenade versions of the
* explosive.
* @return Gets the specific translated name of the grenade versions of the explosive.
*/
public String getGrenadeName();
/**
* @return Gets the specific translated name of the missile versions of the
* explosive.
* @return Gets the specific translated name of the missile versions of the explosive.
*/
public String getMissileName();
/**
* @return Gets the specific translated name of the minecart versions of the
* explosive.
* @return Gets the specific translated name of the minecart versions of the explosive.
*/
public String getMinecartName();
@ -54,17 +51,11 @@ public interface IExplosive extends ITier {
/**
* Creates a new explosion at a given location.
*
* @param world
* The world in which the explosion takes place.
* @param x
* The X-Coord
* @param y
* The Y-Coord
* @param z
* The Z-Coord
* @param entity
* Entity that caused the explosion.
* @param world The world in which the explosion takes place.
* @param x The X-Coord
* @param y The Y-Coord
* @param z The Z-Coord
* @param entity Entity that caused the explosion.
*/
public void createExplosion(World world, double x, double y, double z,
Entity entity);
public void createExplosion(World world, double x, double y, double z, Entity entity);
}

View file

@ -3,13 +3,14 @@ package icbm.api.explosion;
import net.minecraft.nbt.NBTTagCompound;
/**
* An object that contains a reference to IExplosive. Carried by explosives,
* grenades and missile entities etc.
* An object that contains a reference to IExplosive. Carried by explosives, grenades and missile
* entities etc.
*
* @author Calclavia
*
*/
public interface IExplosiveContainer {
public interface IExplosiveContainer
{
public NBTTagCompound getTagCompound();
public IExplosive getExplosiveType();

View file

@ -6,6 +6,7 @@ package icbm.api.explosion;
* @author Calclavia
*
*/
public interface IExplosiveIgnore {
public interface IExplosiveIgnore
{
public boolean canIgnore(IExplosion explosion);
}

View file

@ -6,32 +6,28 @@ package icbm.api.sentry;
* @author Calclavia
*
*/
public interface IAATarget {
public interface IAATarget
{
/**
* destroys the target with a boom. This is a forced way for the sentry too
* kill the target if it doesn't take damage
* destroys the target with a boom. This is a forced way for the sentry too kill the target if
* it doesn't take damage
*/
public void destroyCraft();
/**
* Applies damage to the the target
*
* @param damage
* - damage in half HP
* @return the amount of HP left. Return -1 if this target can't take
* damage, and will be chance killed. Return 0 if this target is
* dead and destroyCraft() will be called.
* @param damage - damage in half HP
* @return the amount of HP left. Return -1 if this target can't take damage, and will be chance
* killed. Return 0 if this target is dead and destroyCraft() will be called.
*/
public int doDamage(int damage);
/**
* Can this be targeted by automated targeting systems or AIs. Used to
* implement radar jammers, cloaking devices, and other addons for the
* Entity being targeted
* Can this be targeted by automated targeting systems or AIs. Used to implement radar jammers,
* cloaking devices, and other addons for the Entity being targeted
*
* @param entity
* - entity that is targeting this, can be an Entity,
* EntityLiving, or TileEntity
* @param entity - entity that is targeting this, can be an Entity, EntityLiving, or TileEntity
* @return true if it can
*/
public boolean canBeTargeted(Object entity);