General Update: Untested

really quick update that i should have uploaded 3 days ago but meh.
Anyways no real changes thought i change the task system to inlude the
TE
in the constuction instead of a seperate method. Since i have no way to
test the tasks yet i have yet to know if this will effect anything. Will
add arm to mod by dec 10. For the moment i have other things to do.
This commit is contained in:
Rseifert 2012-11-26 11:58:03 -05:00
parent ce66426131
commit 2ec75ad736
59 changed files with 1331 additions and 419 deletions

View file

@ -1 +1 @@
A mod that brings realistic transportation systems into Minecraft.
A mod that brings realistic factory style transportation systems into Minecraft.

Binary file not shown.

View file

@ -1,6 +1,7 @@
package assemblyline.ai;
import net.minecraft.src.TileEntity;
import assemblyline.machines.crafter.TileEntityCraftingArm;
/**
* An AI Task that is used by TileEntities with
@ -12,7 +13,11 @@ import net.minecraft.src.TileEntity;
public abstract class Task
{
protected int ticks;
protected TileEntityCraftingArm tileEntity;
public Task(TileEntityCraftingArm arm)
{
this.tileEntity = arm;
}
/**
* Called when a task is being done.
*
@ -37,8 +42,6 @@ public abstract class Task
{
}
public abstract void setTileEntity(TileEntity tileEntity);
/**
* @return The tick interval of this task.
* Return 0 for no ticks.

View file

@ -1,14 +1,23 @@
package assemblyline.ai;
import assemblyline.machines.crafter.TileEntityCraftingArm;
import net.minecraft.src.TileEntity;
public class TaskIdle extends Task
{
private TileEntity tileEntity;
@Override
public void setTileEntity(TileEntity tileEntity)
{
this.tileEntity = tileEntity;
public TaskIdle(TileEntityCraftingArm arm)
{
super(arm);
}
protected boolean doTask()
{
/**
* randomly move the arm to
* similate life in the arm
* if the arm is powered
*/
return true;
}
}

View file

@ -48,7 +48,6 @@ public class TaskManager
public void addTask(TileEntity tileEntity, Task task)
{
task.setTileEntity(tileEntity);
task.onTaskStart();
tasks.add(task);
}

View file

@ -398,7 +398,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
}
@Override
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
this.wattsReceived += ElectricInfo.getWatts(amps, voltage);
}

View file

@ -342,7 +342,7 @@ public class TileEntityRejector extends TileEntityElectricityReceiver implements
}
@Override
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
this.wattsReceived += (amps * voltage);

View file

@ -85,7 +85,7 @@ public class TileEntityRoboticSorter extends TileEntityElectricityReceiver imple
}
@Override
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
this.wattsReceived += (amps * voltage);

View file

@ -225,7 +225,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
}
@Override
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
this.wattsReceived += ElectricInfo.getWatts(amps, voltage);
}

View file

@ -12,16 +12,17 @@ import assemblyline.ai.Task;
*/
public class TaskArmCollect extends Task
{
private TileEntityCraftingArm tileEntity;
/**
* The item to be collected.
*/
private EntityItem entityItem;
public TaskArmCollect(EntityItem entityItem)
public TaskArmCollect(TileEntityCraftingArm arm,EntityItem entityItem)
{
this.entityItem = entityItem;
super(arm);
this.entityItem = entityItem;
}
@Override
@ -38,10 +39,4 @@ public class TaskArmCollect extends Task
return true;
}
@Override
public void setTileEntity(TileEntity tileEntity)
{
this.tileEntity = (TileEntityCraftingArm) tileEntity;
}
}

View file

@ -13,7 +13,6 @@ import assemblyline.ai.Task;
*/
public class TaskArmSearch extends Task
{
private TileEntityCraftingArm tileEntity;
/**
* The item to be collected.
@ -22,14 +21,13 @@ public class TaskArmSearch extends Task
private float searchSpeed;
private World worldObj;
private double radius;
private Entity foundEntity;
public TaskArmSearch(Class<? extends Entity> entityToInclude, double radius, float searchSpeed)
public TaskArmSearch(TileEntityCraftingArm arm,Class<? extends Entity> entityToInclude, double radius, float searchSpeed)
{
super(arm);
this.entityToInclude = entityToInclude;
this.radius = radius;
this.searchSpeed = searchSpeed;
@ -38,7 +36,7 @@ public class TaskArmSearch extends Task
@Override
public void onTaskStart()
{
this.foundEntity = (Entity) this.worldObj.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(this.tileEntity.xCoord - this.radius, this.tileEntity.yCoord - this.radius, this.tileEntity.zCoord - this.radius, this.tileEntity.xCoord + this.radius, this.tileEntity.yCoord + this.radius, this.tileEntity.zCoord + this.radius)).get(0);
this.foundEntity = (Entity) this.tileEntity.worldObj.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(this.tileEntity.xCoord - this.radius, this.tileEntity.yCoord - this.radius, this.tileEntity.zCoord - this.radius, this.tileEntity.xCoord + this.radius, this.tileEntity.yCoord + this.radius, this.tileEntity.zCoord + this.radius)).get(0);
}
@Override
@ -56,11 +54,4 @@ public class TaskArmSearch extends Task
return true;
}
@Override
public void setTileEntity(TileEntity tileEntity)
{
this.tileEntity = (TileEntityCraftingArm) tileEntity;
this.worldObj = this.tileEntity.worldObj;
}
}

View file

@ -68,7 +68,7 @@ public class TileEntityCraftingArm extends TileEntityElectricityReceiver impleme
* UE methods
*/
@Override
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
this.jouleReceived = Math.max(jouleReceived + (amps * voltage), maxJoules);
@ -258,4 +258,5 @@ public class TileEntityCraftingArm extends TileEntityElectricityReceiver impleme
nbt.setTag("Items", var2);
}
}

View file

@ -12,8 +12,7 @@ import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.registry.TickRegistry;
/**
* A class used to load Universal Electricity and
* make it work.
* A class used to load Universal Electricity and make it work.
*
* @author Calclavia
*

View file

@ -12,20 +12,14 @@ import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
/**
* Instructions for using the Universal
* Electricity API.
* Instructions for using the Universal Electricity API.
*
* The less you include of the API, the more
* compatible your mod will be for future releases
* of Universal Electricity.
* The less you include of the API, the more compatible your mod will be for future releases of
* Universal Electricity.
*
* REQUIRED PACKAGES: "universalelectricity"
* "universalelectricity.electricity"
* "universalelectricity.implements" - Some
* interfaces can be removed if not needed.
* REQUIRED PACKAGE: "universalelectricity.core" OPTIONAL PACKAGE: "universalelectricity.prefab"
*
* The rest of the classes should be removed if
* you are not going to use them.
* All classes should be removed if you are not going to use them.
*
* @author Calclavia
*
@ -33,23 +27,20 @@ import cpw.mods.fml.common.Loader;
public class UniversalElectricity
{
/**
* The version of the Universal Electricity
* API.
* The version of the Universal Electricity API.
*/
public static final int MAJOR_VERSION = 1;
public static final int MINOR_VERSION = 1;
public static final int REVISION_VERSION = 1;
public static final int REVISION_VERSION = 3;
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
/**
* The Universal Electricity configuration
* file.
* The Universal Electricity configuration file.
*/
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/UniversalElectricity.cfg"));
/**
* Conversion ratios between Buildcraft and
* Industrialcraft energy.
* Conversion ratios between Buildcraft and Industrialcraft energy.
*/
// EU to Watts ratio
public static final float IC2_RATIO = (float) UEConfig.getConfigData(CONFIGURATION, "IndustrialCraft Conversion Ratio", 7);
@ -59,16 +50,14 @@ public class UniversalElectricity
public static final float TO_BC_RATIO = 1 / BC3_RATIO;
/**
* Use this material for all your machine
* blocks. It can be breakable by hand.
* Use this material for all your machine blocks. It can be breakable by hand.
*/
public static final Material machine = new Material(MapColor.ironColor);
public static final List<Object> mods = new ArrayList<Object>();
/**
* You must register your mod with Universal
* Electricity. Call this in your mod's
* You must register your mod with Universal Electricity. Call this in your mod's
* pre-initialization stage.
*/
public static void register(Object mod, int major, int minor, int revision, boolean strict)
@ -97,8 +86,7 @@ public class UniversalElectricity
}
/**
* A function that allows you to lock your mod
* to a specific version of Forge.
* A function that allows you to lock your mod to a specific version of Forge.
*/
public static void forgeLock(int major, int minor, int revision, boolean strict)
{

View file

@ -1,8 +1,7 @@
package universalelectricity.core.electricity;
/**
* An easy way to display information on
* electricity.
* An easy way to display information on electricity.
*
* @author Calclavia
*/
@ -132,8 +131,7 @@ public class ElectricInfo
}
/**
* Displays the unit as text. Works only for
* positive numbers.
* Displays the unit as text. Works only for positive numbers.
*/
public static String getDisplay(double value, ElectricUnit unit, int significantFigures, boolean isShort)
{
@ -186,8 +184,7 @@ public class ElectricInfo
}
/**
* Rounds a number to a specific number place
* places
* Rounds a number to a specific number place places
*
* @param The
* number

View file

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.src.Entity;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.implement.IConductor;
@ -16,9 +17,8 @@ import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.TickType;
/**
* This class is used to manage electricity
* transferring and flow. It is also used to call
* updates on UE tile entities.
* This class is used to manage electricity transferring and flow. It is also used to call updates
* on UE tile entities.
*
* @author Calclavia
*
@ -26,10 +26,8 @@ import cpw.mods.fml.common.TickType;
public class ElectricityManager
{
/**
* ElectricityManager exists on both client
* and server side. Rely on the server side
* one as it is more accurate! Client side
* only simulates.
* ElectricityManager exists on both client and server side. Rely on the server side one as it
* is more accurate! Client side only simulates.
*/
public static ElectricityManager instance;
@ -42,8 +40,7 @@ public class ElectricityManager
}
/**
* Registers a the conductor into the UE
* electricity net.
* Registers a the conductor into the UE electricity net.
*
* @param conductor
* - The IConductor tile entity.
@ -55,15 +52,12 @@ public class ElectricityManager
}
/**
* Merges two connection lines together into
* one.
* Merges two connection lines together into one.
*
* @param networkA
* - The network to be merged into.
* This network will be kept.
* - The network to be merged into. This network will be kept.
* @param networkB
* - The network to be merged. This
* network will be deleted.
* - The network to be merged. This network will be deleted.
*/
public void mergeConnection(ElectricityNetwork networkA, ElectricityNetwork networkB)
{
@ -84,11 +78,8 @@ public class ElectricityManager
}
/**
* Separate one connection line into two
* different ones between two conductors. This
* function does this by resetting all wires
* in the connection line and making them each
* reconnect.
* Separate one connection line into two different ones between two conductors. This function
* does this by resetting all wires in the connection line and making them each reconnect.
*
* @param conductorA
* - existing conductor
@ -123,8 +114,7 @@ public class ElectricityManager
}
/**
* Clean up and remove all useless and invalid
* connections.
* Clean up and remove all useless and invalid connections.
*/
public void cleanUpConnections()
{
@ -147,25 +137,19 @@ public class ElectricityManager
}
/**
* Produces electricity into a specific wire
* which will be distributed across the
* electricity network.
* Produces electricity into a specific wire which will be distributed across the electricity
* network.
*
* @param sender
* The machine sending the
* electricity.
* The machine sending the electricity.
* @param targetConductor
* The conductor receiving the
* electricity (or connected to the
* machine).
* The conductor receiving the electricity (or connected to the machine).
* @param amps
* The amount of amps this machine
* is sending.
* The amount of amps this machine is sending.
* @param voltage
* The amount of volts this machine
* is sending.
* The amount of volts this machine is sending.
*/
public void produceElectricity(TileEntity sender, IConductor targetConductor, double amps, double voltage)
public void produceElectricity(Object sender, IConductor targetConductor, double amps, double voltage)
{
if (targetConductor != null && amps > 0 && voltage > 0)
{
@ -197,12 +181,16 @@ public class ElectricityManager
double transferAmps = Math.max(0, Math.min(leftOverAmps, Math.min(amps / allElectricUnitsInLine.size(), ElectricInfo.getAmps(this.getActualWattRequest(receiver), receiver.getVoltage()))));
leftOverAmps -= transferAmps;
// Calculate
// electricity
// loss
double distance = Vector3.distance(Vector3.get(sender), Vector3.get((TileEntity) receiver));
double ampsReceived = transferAmps - (transferAmps * transferAmps * targetConductor.getResistance() * distance) / voltage;
double voltsReceived = voltage - (transferAmps * targetConductor.getResistance() * distance);
double ampsReceived = transferAmps;
double voltsReceived = voltage;
if (sender instanceof TileEntity)
{
// Calculate electricity loss
double distance = Vector3.distance(Vector3.get((TileEntity) sender), Vector3.get((TileEntity) receiver));
ampsReceived = transferAmps - (transferAmps * transferAmps * targetConductor.getResistance() * distance) / voltage;
voltsReceived = voltage - (transferAmps * targetConductor.getResistance() * distance);
}
this.electricityTransferQueue.add(new ElectricityTransferData(sender, receiver, electricityNetwork, ForgeDirection.getOrientation(i).getOpposite(), ampsReceived, voltsReceived));
}
@ -218,9 +206,24 @@ public class ElectricityManager
}
}
public void produceElectricity(Object sender, Entity entity, double amps, double voltage, ForgeDirection outputDirection)
{
if (entity instanceof IElectricityReceiver)
{
IElectricityReceiver electricEntity = ((IElectricityReceiver) entity);
if (electricEntity.wattRequest() > 0)
{
if (electricEntity.canReceiveFromSide(outputDirection.getOpposite()))
{
electricEntity.onReceive(this, amps, voltage, outputDirection.getOpposite());
}
}
}
}
/**
* Gets the actual watt request of an electric
* receiver accounting all current electricity
* Gets the actual watt request of an electric receiver accounting all current electricity
* packets qued up for it.
*
* @return - The amount of watts requested.
@ -254,11 +257,9 @@ public class ElectricityManager
}
/**
* Checks if the current connection line needs
* electricity
* Checks if the current connection line needs electricity
*
* @return - The amount of joules this
* connection line needs
* @return - The amount of joules this connection line needs
*/
public double getElectricityRequired(ElectricityNetwork network)
{
@ -323,8 +324,7 @@ public class ElectricityManager
}
/**
* This function is called to refresh all
* conductors in the world.
* This function is called to refresh all conductors in the world.
*/
public void refreshConductors()
{
@ -345,12 +345,13 @@ public class ElectricityManager
public void onTick(EnumSet<TickType> type, Object... tickData)
{
if (ElectricityManagerTicker.inGameTicks % 40 == 0)
{
this.refreshConductors();
}
if (type.contains(TickType.WORLD) && !type.contains(TickType.WORLDLOAD))
{
if (ElectricityManagerTicker.inGameTicks % 40 == 0)
{
this.refreshConductors();
}
try
{

View file

@ -29,8 +29,7 @@ public class ElectricityNetwork
}
/**
* Get only the electric units that can
* receive electricity from the given side.
* Get only the electric units that can receive electricity from the given side.
*/
public List<IElectricityReceiver> getConnectedReceivers()
{
@ -110,8 +109,7 @@ public class ElectricityNetwork
}
/**
* This function is called to refresh all
* conductors in this network
* This function is called to refresh all conductors in this network
*/
public void refreshConductors()
{

View file

@ -1,12 +1,11 @@
package universalelectricity.core.electricity;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.implement.IElectricityReceiver;
public class ElectricityTransferData
{
public TileEntity sender;
public Object sender;
public IElectricityReceiver receiver;
public ElectricityNetwork network;
public double amps;
@ -15,20 +14,17 @@ public class ElectricityTransferData
/**
* @param sender
* - Tile that's sending
* electricity.
* - Tile that's sending electricity.
* @param receiver
* - Receiver that's receiving
* electricity
* - Receiver that's receiving electricity
* @param conductor
* - Conductor that is conducting
* the electricity
* - Conductor that is conducting the electricity
* @param side
* -
* @param amps
* @param voltage
*/
public ElectricityTransferData(TileEntity sender, IElectricityReceiver receiver, ElectricityNetwork network, ForgeDirection side, double amps, double voltage)
public ElectricityTransferData(Object sender, IElectricityReceiver receiver, ElectricityNetwork network, ForgeDirection side, double amps, double voltage)
{
this.sender = sender;
this.receiver = receiver;

View file

@ -6,8 +6,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityNetwork;
/**
* Must be applied to all tile entities that are
* conductors.
* Must be applied to all tile entities that are conductors.
*
* @author Calclavia
*
@ -15,63 +14,54 @@ import universalelectricity.core.electricity.ElectricityNetwork;
public interface IConductor extends IConnector
{
/**
* The electrical network this conductor is
* on.
* The electrical network this conductor is on.
*/
public ElectricityNetwork getNetwork();
public void setNetwork(ElectricityNetwork network);
/**
* The UE tile entities that this conductor is
* connected to.
* The UE tile entities that this conductor is connected to.
*
* @return
*/
public TileEntity[] getConnectedBlocks();
/**
* Gets the resistance of the conductor. Used
* to calculate energy loss. A higher
* resistance means a higher energy loss.
* Gets the resistance of the conductor. Used to calculate energy loss. A higher resistance
* means a higher energy loss.
*
* @return The amount of Ohm's of resistance.
*/
public double getResistance();
/**
* The maximum amount of amps this conductor
* can handle before melting down. This is
* calculating PER TICK!
* The maximum amount of amps this conductor can handle before melting down. This is calculating
* PER TICK!
*
* @return The amount of amps in volts
*/
public double getMaxAmps();
/**
* Called when the electricity passing through
* exceeds the maximum voltage.
* Called when the electricity passing through exceeds the maximum voltage.
*/
public void onOverCharge();
/**
* Resets the conductor and recalculate
* connection IDs again
* Resets the conductor and recalculate connection IDs again
*/
public void reset();
public World getWorld();
/**
* Adds a connection between this conductor
* and a UE unit
* Adds a connection between this conductor and a UE unit
*
* @param tileEntity
* - Must be either a producer,
* consumer or a conductor
* - Must be either a producer, consumer or a conductor
* @param side
* - side in which the connection
* is coming from
* - side in which the connection is coming from
*/
public void updateConnection(TileEntity tileEntity, ForgeDirection side);

View file

@ -3,8 +3,7 @@ package universalelectricity.core.implement;
import net.minecraftforge.common.ForgeDirection;
/**
* Applied to a TileEntity that can connect to UE
* wires.
* Applied to a TileEntity that can connect to UE wires.
*
* @author Calclavia
*
@ -12,12 +11,10 @@ import net.minecraftforge.common.ForgeDirection;
public interface IConnector
{
/**
* Can this TileEntity visually connect to a
* wire on this specific side?
* Can this TileEntity visually connect to a wire on this specific side?
*
* @param side
* - The side in which the
* connection is coming from.
* - The side in which the connection is coming from.
* @return - True if so.
*/
public boolean canConnect(ForgeDirection side);

View file

@ -1,9 +1,8 @@
package universalelectricity.core.implement;
/**
* This class should be applied to all tile
* entities (mainly machines) that can be disabled
* (by things like EMP, short circuit etc.).
* This class should be applied to all tile entities (mainly machines) that can be disabled (by
* things like EMP, short circuit etc.).
*
* @author Calclavia
*
@ -11,21 +10,17 @@ package universalelectricity.core.implement;
public interface IDisableable
{
/**
* This is called when the tile entity is to
* be disabled.
* This is called when the tile entity is to be disabled.
*
* @param duration
* - The duration of the disable in
* ticks.
* - The duration of the disable in ticks.
*/
public void onDisable(int duration);
/**
* Called to see if this tile entity is
* disabled.
* Called to see if this tile entity is disabled.
*
* @return True if the tile entity is
* disabled.
* @return True if the tile entity is disabled.
*/
public boolean isDisabled();
}

View file

@ -1,10 +1,8 @@
package universalelectricity.core.implement;
/**
* Applied to TileEntities that can produces
* electricity. Of course, you will still need to
* call ElectricityManager.instance.produce() to
* actually output the electricity.
* Applied to TileEntities that can produces electricity. Of course, you will still need to call
* ElectricityManager.instance.produce() to actually output the electricity.
*
* @author Calclavia
*/

View file

@ -1,12 +1,10 @@
package universalelectricity.core.implement;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
/**
* The IElectricityReceiver interface is an
* interface that must be applied to all tile
* entities that can receive electricity.
* The IElectricityReceiver interface is an interface that must be applied to all TileEntities or
* Entities that can receive electricity.
*
* @author Calclavia
*
@ -16,32 +14,27 @@ public interface IElectricityReceiver extends IDisableable, IConnector, IVoltage
/**
* Called every tick on this machine.
*
* @param sender
* - Either the TileEntity or the Entity sending the electricity to this
* TileEntity/Entity.
* @param amps
* - Amount of amps this electric
* unit is receiving.
* - Amount of amps this electric unit is receiving.
* @param voltage
* - The voltage of the electricity
* sent. If more than one packet is
* being sent to you in this
* update, the highest voltage will
* override.
* - The voltage of the electricity sent. If more than one packet is being sent to
* you in this update, the highest voltage will override.
* @param side
* - The side of the block in which
* the electricity is coming from.
* - The side of the block in which the electricity is coming from.
*/
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side);
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side);
/**
* How many watts does this electrical unit
* need this tick? Recommended for you to
* return the max electricity storage of this
* machine (if there is one).
* How many watts does this electrical unit need this tick? Recommended for you to return the
* max electricity storage of this machine (if there is one).
*/
public double wattRequest();
/**
* Can this unit receive electricity from this
* specific side?
* Can this unit receive electricity from this specific side?
*/
public boolean canReceiveFromSide(ForgeDirection side);
}

View file

@ -10,25 +10,21 @@ public interface IItemElectric extends IJouleStorage, IVoltage
public double onReceive(double amps, double voltage, ItemStack itemStack);
/**
* Called when something requests electricity
* from this item.
* Called when something requests electricity from this item.
*
* @return - The amount of given joules
*/
public double onUse(double joulesNeeded, ItemStack itemStack);
/**
* @return Returns true or false if this
* consumer can receive electricity at
* this given tick or moment.
* @return Returns true or false if this consumer can receive electricity at this given tick or
* moment.
*/
public boolean canReceiveElectricity();
/**
* Can this item give out electricity when
* placed in an tile entity? Electric items
* like batteries should be able to produce
* electricity (if they are rechargeable).
* Can this item give out electricity when placed in an tile entity? Electric items like
* batteries should be able to produce electricity (if they are rechargeable).
*
* @return - True or False.
*/

View file

@ -1,28 +1,24 @@
package universalelectricity.core.implement;
/**
* This interface is to be applied to all tile
* entities which stores energy within them.
* This interface is to be applied to all tile entities which stores energy within them.
*
* @author Calclavia
*/
public interface IJouleStorage
{
/**
* Returns the amount of joules this unit has
* stored.
* Returns the amount of joules this unit has stored.
*/
public double getJoules(Object... data);
/**
* Sets the amount of joules this unit has
* stored.
* Sets the amount of joules this unit has stored.
*/
public void setJoules(double wattHours, Object... data);
public void setJoules(double joules, Object... data);
/**
* Gets the maximum amount of joules this unit
* can store.
* Gets the maximum amount of joules this unit can store.
*/
public double getMaxJoules(Object... data);
}

View file

@ -11,8 +11,7 @@ public interface IVoltage
/**
* Gets the voltage of this object.
*
* @return The amount of volts. E.g 120v or
* 240v
* @return The amount of volts. E.g 120v or 240v
*/
public double getVoltage();
}

View file

@ -3,11 +3,9 @@ package universalelectricity.core.vector;
import net.minecraft.src.MathHelper;
/**
* Vector2 Class is used for defining objects in a
* 2D space. Vector2 makes it easier to handle the
* coordinates of objects. Instead of fumbling
* with x and y variables, all x and y variables
* are stored in one class. Vector3.x, Vector3.y.
* Vector2 Class is used for defining objects in a 2D space. Vector2 makes it easier to handle the
* coordinates of objects. Instead of fumbling with x and y variables, all x and y variables are
* stored in one class. Vector3.x, Vector3.y.
*
* @author Calclavia
*/
@ -46,8 +44,7 @@ public class Vector2 implements Cloneable
}
/**
* Makes a new copy of this Vector. Prevents
* variable referencing problems.
* Makes a new copy of this Vector. Prevents variable referencing problems.
*/
@Override
public Vector2 clone()
@ -80,7 +77,7 @@ public class Vector2 implements Cloneable
this.x += par1;
this.y += par1;
}
public void substract(Vector2 par1)
{
this.x -= par1.x;
@ -106,6 +103,6 @@ public class Vector2 implements Cloneable
@Override
public String toString()
{
return "Vector2: " + this.x + "," + this.y;
return "Vector2 [" + this.x + "," + this.y + "]";
}
}

View file

@ -1,5 +1,8 @@
package universalelectricity.core.vector;
import java.util.List;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.ChunkCoordinates;
import net.minecraft.src.Entity;
import net.minecraft.src.IBlockAccess;
@ -13,12 +16,9 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.implement.IConnector;
/**
* Vector3 Class is used for defining objects in a
* 3D space. Vector3 makes it easier to handle the
* coordinates of objects. Instead of fumbling
* with x, y and z variables, all x, y and z
* variables are stored in one class. Vector3.x,
* Vector3.y, Vector3.z.
* Vector3 Class is used for defining objects in a 3D space. Vector3 makes it easier to handle the
* coordinates of objects. Instead of fumbling with x, y and z variables, all x, y and z variables
* are stored in one class. Vector3.x, Vector3.y, Vector3.z.
*
* @author Calclavia
*/
@ -65,8 +65,7 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Makes a new copy of this Vector. Prevents
* variable referencing problems.
* Makes a new copy of this Vector. Prevents variable referencing problems.
*/
@Override
public Vector3 clone()
@ -139,8 +138,7 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Converts this Vector3 into a Vector2 by
* dropping the Y axis.
* Converts this Vector3 into a Vector2 by dropping the Y axis.
*/
public Vector2 toVector2()
{
@ -148,8 +146,7 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Converts this vector three into a Minecraft
* Vec3 object
* Converts this vector three into a Minecraft Vec3 object
*/
public Vec3 toVec3()
{
@ -157,8 +154,7 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Compares two vectors and see if they are
* equal. True if so.
* Compares two vectors and see if they are equal. True if so.
*/
public boolean isEqual(Vector3 vector3)
{
@ -223,14 +219,28 @@ public class Vector3 extends Vector2 implements Cloneable
this.z -= amount.z;
}
public static Vector3 multiply(Vector3 par1, Vector3 par2)
public void multiply(int amount)
{
return new Vector3(par1.x * par2.x, par1.y * par2.y, par1.z * par2.z);
this.x *= amount;
this.y *= amount;
this.z *= amount;
}
public static Vector3 multiply(Vector3 par1, double par2)
public void multiply(Vector3 vec)
{
return new Vector3(par1.x * par2, par1.y * par2, par1.z * par2);
this.x *= vec.x;
this.y *= vec.y;
this.z *= vec.z;
}
public static Vector3 multiply(Vector3 vec1, Vector3 vec2)
{
return new Vector3(vec1.x * vec2.x, vec1.y * vec2.y, vec1.z * vec2.z);
}
public static Vector3 multiply(Vector3 vec1, double vec2)
{
return new Vector3(vec1.x * vec2, vec1.y * vec2, vec1.z * vec2);
}
public static Vector3 readFromNBT(String prefix, NBTTagCompound par1NBTTagCompound)
@ -246,11 +256,9 @@ public class Vector3 extends Vector2 implements Cloneable
* Saves this Vector3 to disk
*
* @param prefix
* - The prefix of this save. Use
* some unique string.
* - The prefix of this save. Use some unique string.
* @param par1NBTTagCompound
* - The NBT compound object to
* save the data in
* - The NBT compound object to save the data in
*/
public void writeToNBT(String prefix, NBTTagCompound par1NBTTagCompound)
{
@ -270,44 +278,54 @@ public class Vector3 extends Vector2 implements Cloneable
{
return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
}
/**
* Gets a position relative to another
* position's side
* Gets all entities inside of this position in block space.
*/
public List<Entity> getEntitiesWithin(World worldObj, Class<? extends Entity> par1Class)
{
return (List<Entity>) worldObj.getEntitiesWithinAABB(par1Class, AxisAlignedBB.getBoundingBox(this.intX(), this.intY(), this.intZ(), this.intX() + 1, this.intY() + 1, this.intZ() + 1));
}
/**
* Gets a position relative to another position's side
*
* @param position
* - The position
* @param side
* - The side. 0-5
* @return The position relative to the
* original position's side
* @return The position relative to the original position's side
*/
public void modifyPositionFromSide(ForgeDirection side)
public void modifyPositionFromSide(ForgeDirection side, double amount)
{
switch (side.ordinal())
{
case 0:
this.y -= 1;
this.y -= amount;
break;
case 1:
this.y += 1;
this.y += amount;
break;
case 2:
this.z -= 1;
this.z -= amount;
break;
case 3:
this.z += 1;
this.z += amount;
break;
case 4:
this.x -= 1;
this.x -= amount;
break;
case 5:
this.x += 1;
this.x += amount;
break;
}
}
public void modifyPositionFromSide(ForgeDirection side)
{
this.modifyPositionFromSide(side, 1);
}
public static TileEntity getTileEntityFromSide(World world, Vector3 position, ForgeDirection side)
{
position.modifyPositionFromSide(side);
@ -315,8 +333,7 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Gets a connector unit based on the given
* side.
* Gets a connector unit based on the given side.
*/
public static TileEntity getConnectorFromSide(World world, Vector3 position, ForgeDirection side)
{
@ -331,25 +348,17 @@ public class Vector3 extends Vector2 implements Cloneable
}
/**
* Finds the side of a block depending on it's
* facing direction from the given side. The
* side numbers are compatible with the
* function
* "getBlockTextureFromSideAndMetadata".
* Finds the side of a block depending on it's facing direction from the given side. The side
* numbers are compatible with the function "getBlockTextureFromSideAndMetadata".
*
* Bottom: 0; Top: 1; Back: 2; Front: 3; Left:
* 4; Right: 5;
* Bottom: 0; Top: 1; Back: 2; Front: 3; Left: 4; Right: 5;
*
* @param front
* - The direction in which this
* block is facing/front. Use a
* number between 0 and 5. Default
* is 3.
* - The direction in which this block is facing/front. Use a number between 0 and 5.
* Default is 3.
* @param side
* - The side you are trying to
* find. A number between 0 and 5.
* @return The side relative to the facing
* direction.
* - The side you are trying to find. A number between 0 and 5.
* @return The side relative to the facing direction.
*/
public static ForgeDirection getOrientationFromSide(ForgeDirection front, ForgeDirection side)
@ -447,10 +456,10 @@ public class Vector3 extends Vector2 implements Cloneable
return ForgeDirection.UNKNOWN;
}
@Override
public String toString()
{
return "Vector3: " + this.x + "," + this.y + "," + this.z;
return "Vector3 [" + this.x + "," + this.y + "," + this.z + "]";
}
}

View file

@ -0,0 +1,54 @@
package universalelectricity.prefab;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import universalelectricity.core.implement.IConductor;
public abstract class BlockConductor extends BlockContainer
{
public BlockConductor(int id, Material material)
{
super(id, material);
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof IConductor)
{
((IConductor) tileEntity).refreshConnectedBlocks();
}
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
* (coordinates passed are their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
if (tileEntity instanceof IConductor)
{
((IConductor) tileEntity).refreshConnectedBlocks();
}
}
world.markBlockForUpdate(x, y, z);
}
}

View file

@ -13,14 +13,12 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import universalelectricity.core.implement.IItemElectric;
import buildcraft.api.tools.IToolWrench;
import universalelectricity.prefab.implement.IWrench;
/**
* A block you may extend from to create your
* machine blocks! You do not have to extend from
* this block if you do not want to. It's optional
* but it comes with some useful functions that
* will make coding easier for you.
* A block you may extend from to create your machine blocks! You do not have to extend from this
* block if you do not want to. It's optional but it comes with some useful functions that will make
* coding easier for you.
*/
public abstract class BlockMachine extends BlockContainer
{
@ -44,8 +42,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Returns the quantity of items to drop on
* block destruction.
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
@ -54,8 +51,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Returns the ID of the items to drop on
* destruction.
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
@ -64,13 +60,9 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* DO NOT OVERRIDE THIS FUNCTION! Called when
* the block is right clicked by the player.
* This modified version detects electric
* items and wrench actions on your machine
* block. Do not override this function. Use
* machineActivated instead! (It does the same
* thing)
* DO NOT OVERRIDE THIS FUNCTION! Called when the block is right clicked by the player. This
* modified version detects electric items and wrench actions on your machine block. Do not
* override this function. Use machineActivated instead! (It does the same thing)
*/
@Override
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
@ -78,16 +70,14 @@ public abstract class BlockMachine extends BlockContainer
int metadata = par1World.getBlockMetadata(x, y, z);
/**
* Check if the player is holding a wrench
* or an electric item. If so, do not open
* the GUI.
* Check if the player is holding a wrench or an electric item. If so, do not open the GUI.
*/
if (par5EntityPlayer.inventory.getCurrentItem() != null)
{
if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolWrench)
if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IWrench)
{
par1World.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
((IToolWrench) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z);
((IWrench) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z);
if (par5EntityPlayer.isSneaking())
{
@ -115,8 +105,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Called when the machine is right clicked by
* the player
* Called when the machine is right clicked by the player
*
* @return True if something happens
*/
@ -126,8 +115,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Called when the machine is right clicked by
* the player while sneaking (shift clicking)
* Called when the machine is right clicked by the player while sneaking (shift clicking)
*
* @return True if something happens
*/
@ -137,8 +125,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Called when a player uses an electric item
* on the machine
* Called when a player uses an electric item on the machine
*
* @return True if some happens
*/
@ -148,8 +135,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Called when a player uses a wrench on the
* machine
* Called when a player uses a wrench on the machine
*
* @return True if some happens
*/
@ -159,8 +145,7 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Called when a player uses a wrench on the
* machine while sneaking
* Called when a player uses a wrench on the machine while sneaking
*
* @return True if some happens
*/
@ -170,10 +155,8 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Returns the TileEntity used by this block.
* You should use the metadata sensitive
* version of this to get the maximum
* optimization!
* Returns the TileEntity used by this block. You should use the metadata sensitive version of
* this to get the maximum optimization!
*/
@Override
public TileEntity createNewTileEntity(World var1)
@ -182,9 +165,8 @@ public abstract class BlockMachine extends BlockContainer
}
/**
* Override this if you don't need it. This
* will eject all items out of this machine if
* it has an inventory
* Override this if you don't need it. This will eject all items out of this machine if it has
* an inventory
*/
@Override
public void breakBlock(World par1World, int x, int y, int z, int par5, int par6)

View file

@ -0,0 +1,205 @@
package universalelectricity.prefab;
import java.util.List;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagFloat;
import net.minecraft.src.World;
import universalelectricity.core.electricity.ElectricInfo;
import universalelectricity.core.electricity.ElectricInfo.ElectricUnit;
import universalelectricity.core.implement.IItemElectric;
/**
* Extend from this class if your item requires electricity or to be charged. Optionally, you can
* implement IItemElectric instead.
*
* @author Calclavia
*
*/
public abstract class ItemElectric extends Item implements IItemElectric
{
public ItemElectric(int id)
{
super(id);
this.setMaxStackSize(1);
this.setMaxDamage((int) this.getMaxJoules());
this.setNoRepair();
}
/**
* Allows items to add custom lines of information to the mouseover description. If you want to
* add more information to your item, you can super.addInformation() to keep the electiricty
* info in the item info bar.
*/
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
String color = "";
double joules = this.getJoules(par1ItemStack);
if (joules <= this.getMaxJoules() / 3)
{
color = "\u00a74";
}
else if (joules > this.getMaxJoules() * 2 / 3)
{
color = "\u00a72";
}
else
{
color = "\u00a76";
}
par3List.add(color + ElectricInfo.getDisplay(joules, ElectricUnit.JOULES) + " - " + Math.round((joules / this.getMaxJoules()) * 100) + "%");
}
/**
* Make sure you super this method!
*/
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
// Makes sure the damage is set correctly
// for this electric item!
ItemElectric item = ((ItemElectric) par1ItemStack.getItem());
item.setJoules(item.getJoules(par1ItemStack), par1ItemStack);
}
/**
* Makes sure the item is uncharged when it is crafted and not charged. Change this if you do
* not want this to happen!
*/
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par1ItemStack = this.getUncharged();
}
@Override
public double onReceive(double amps, double voltage, ItemStack itemStack)
{
double rejectedElectricity = Math.max((this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - this.getMaxJoules(), 0);
this.setJoules(this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1) - rejectedElectricity, itemStack);
return rejectedElectricity;
}
@Override
public double onUse(double joulesNeeded, ItemStack itemStack)
{
double electricityToUse = Math.min(this.getJoules(itemStack), joulesNeeded);
this.setJoules(this.getJoules(itemStack) - electricityToUse, itemStack);
return electricityToUse;
}
public boolean canReceiveElectricity()
{
return true;
}
public boolean canProduceElectricity()
{
return false;
}
/**
* This function sets the electriicty. Do not directly call this function. Try to use
* onReceiveElectricity or onUseElectricity instead.
*
* @param wattHours
* - The amount of electricity in joules
*/
@Override
public void setJoules(double wattHours, Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
// Saves the frequency in the
// itemstack
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
double electricityStored = Math.max(Math.min(wattHours, this.getMaxJoules()), 0);
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
itemStack.setItemDamage((int) (getMaxJoules() - electricityStored));
}
}
/**
* This function is called to get the electricity stored in this item
*
* @return - The amount of electricity stored in watts
*/
@Override
public double getJoules(Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
if (itemStack.stackTagCompound == null) { return 0; }
double electricityStored = 0;
if (itemStack.stackTagCompound.getTag("electricity") instanceof NBTTagFloat)
{
electricityStored = itemStack.stackTagCompound.getFloat("electricity");
}
else
{
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
}
itemStack.setItemDamage((int) (getMaxJoules() - electricityStored));
return electricityStored;
}
return -1;
}
/**
* Returns an uncharged version of the electric item. Use this if you want the crafting recipe
* to use a charged version of the electric item instead of an empty version of the electric
* item
*
* @return The ItemStack of a fully charged electric item
*/
public ItemStack getUncharged()
{
ItemStack chargedItem = new ItemStack(this);
chargedItem.setItemDamage((int) this.getMaxJoules());
return chargedItem;
}
public static ItemStack getUncharged(ItemStack itemStack)
{
if (itemStack.getItem() instanceof IItemElectric)
{
ItemStack chargedItem = itemStack.copy();
chargedItem.setItemDamage((int) ((IItemElectric) itemStack.getItem()).getMaxJoules());
return chargedItem;
}
return null;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
// Add an uncharged version of the
// electric item
ItemStack unchargedItem = new ItemStack(this, 1);
unchargedItem.setItemDamage((int) this.getMaxJoules());
par3List.add(unchargedItem);
// Add an electric item to the creative
// list that is fully charged
ItemStack chargedItem = new ItemStack(this, 1);
this.setJoules(((IItemElectric) chargedItem.getItem()).getMaxJoules(), chargedItem);
par3List.add(chargedItem);
}
}

View file

@ -0,0 +1,188 @@
package universalelectricity.prefab;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.src.CraftingManager;
import net.minecraft.src.IRecipe;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import universalelectricity.core.UEConfig;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* This class is used to replace recipes that are already added in the existing recipe pool for
* crafting and smelting. All recipe functions take account of the Forge Ore Dictionary. It also
* includes some recipe helper functions to shorten some of your function calls.
*
* @author Calclavia
*
*/
public class RecipeHelper
{
public static List<IRecipe> getRecipesByOutput(ItemStack output)
{
List<IRecipe> list = new ArrayList<IRecipe>();
for (Object obj : CraftingManager.getInstance().getRecipeList())
{
if (obj instanceof IRecipe)
{
if (((IRecipe) obj).getRecipeOutput() == output)
{
list.add((IRecipe) obj);
}
}
}
return list;
}
/**
* Replaces a recipe with a new IRecipe.
*
* @return True if successful
*/
public static boolean replaceRecipe(IRecipe recipe, IRecipe newRecipe)
{
for (Object obj : CraftingManager.getInstance().getRecipeList())
{
if (obj instanceof IRecipe)
{
if (((IRecipe) obj).equals(recipe) || obj == recipe)
{
CraftingManager.getInstance().getRecipeList().remove(obj);
CraftingManager.getInstance().getRecipeList().add(newRecipe);
return true;
}
}
}
return false;
}
/**
* Replaces a recipe with the resulting ItemStack with a new IRecipe.
*
* @return True if successful
*/
public static boolean replaceRecipe(ItemStack recipe, IRecipe newRecipe)
{
if (removeRecipe(recipe))
{
CraftingManager.getInstance().getRecipeList().add(newRecipe);
return true;
}
return false;
}
/**
* Removes a recipe by its IRecipe class.
*
* @return True if successful
*/
public static boolean removeRecipe(IRecipe recipe)
{
for (Object obj : CraftingManager.getInstance().getRecipeList())
{
if (obj != null)
{
if (obj instanceof IRecipe)
{
if (((IRecipe) obj).equals(recipe) || obj == recipe)
{
CraftingManager.getInstance().getRecipeList().remove(obj);
return true;
}
}
}
}
return false;
}
/**
* Removes the first recipe found by its output.
*
* @return True if successful
*/
public static boolean removeRecipe(ItemStack stack)
{
for (Object obj : CraftingManager.getInstance().getRecipeList())
{
if (obj != null)
{
if (obj instanceof IRecipe)
{
if (((IRecipe) obj).getRecipeOutput() != null)
{
if (((IRecipe) obj).getRecipeOutput().isItemEqual(stack))
{
CraftingManager.getInstance().getRecipeList().remove(obj);
return true;
}
}
}
}
}
return false;
}
/**
* Removes all recipes found that has this output.
*
* @return True if successful
*/
public static boolean removeRecipes(ItemStack... itemStacks)
{
boolean didRemove = false;
for (Iterator itr = CraftingManager.getInstance().getRecipeList().iterator(); itr.hasNext();)
{
Object obj = itr.next();
if (obj != null)
{
if (obj instanceof IRecipe)
{
if (((IRecipe) obj).getRecipeOutput() != null)
{
for (ItemStack itemStack : itemStacks)
{
if (((IRecipe) obj).getRecipeOutput().isItemEqual(itemStack))
{
itr.remove();
didRemove = true;
break;
}
}
}
}
}
}
return didRemove;
}
/**
* Use this function if you want to check if the recipe is allowed in the configuration file.
*/
public static void addRecipe(IRecipe recipe, String name, Configuration config, boolean defaultBoolean)
{
if (config != null)
{
if (UEConfig.getConfigData(config, "Allow " + name + " Crafting", defaultBoolean))
{
GameRegistry.addRecipe(recipe);
}
}
}
public static void addRecipe(IRecipe recipe, Configuration config, boolean defaultBoolean)
{
addRecipe(recipe, recipe.getRecipeOutput().getItemName(), config, defaultBoolean);
}
}

View file

@ -0,0 +1,29 @@
package universalelectricity.prefab;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot;
import universalelectricity.core.implement.IItemElectric;
/**
* This slot should be used by any container that needs the slot for an electric items only.
*
* @author Calclavia
*
*/
public class SlotElectricItem extends Slot
{
public SlotElectricItem(IInventory par2IInventory, int par3, int par4, int par5)
{
super(par2IInventory, par3, par4, par5);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return par1ItemStack.getItem() instanceof IItemElectric;
}
}

View file

@ -0,0 +1,57 @@
package universalelectricity.prefab;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.src.DamageSource;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class UEDamageSource extends DamageSource
{
public static final List<UEDamageSource> damageSources = new ArrayList<UEDamageSource>();
/**
* Use this damage source for all types of electrical attacks.
*/
public static final UEDamageSource electrocution = (UEDamageSource) new UEDamageSource("electrocution", "%1$s got electrocuted!").setDamageBypassesArmor();
public String deathMessage;
public UEDamageSource(String damageType)
{
super(damageType);
damageSources.add(this);
}
public UEDamageSource(String damageType, String deathMessage)
{
this(damageType);
this.setDeathMessage(deathMessage);
}
public UEDamageSource setDeathMessage(String deathMessage)
{
this.deathMessage = deathMessage;
return this;
}
public DamageSource setDamageBypassesArmor()
{
return super.setDamageBypassesArmor();
}
public DamageSource setDamageAllowedInCreativeMode()
{
return super.setDamageAllowedInCreativeMode();
}
public DamageSource setFireDamage()
{
return super.setFireDamage();
}
public void registerDeathMessage()
{
LanguageRegistry.instance().addStringLocalization("death." + this.damageType, this.deathMessage);
}
}

View file

@ -3,8 +3,7 @@ package universalelectricity.prefab.implement;
import net.minecraftforge.common.ForgeDirection;
/**
* This should be applied on tile entities that
* can provide redstone power
* This should be applied on tile entities that can provide redstone power
*
* @author Calclavia
*

View file

@ -1,8 +1,7 @@
package universalelectricity.prefab.implement;
/**
* This interface should be applied onto all tile
* entities that needs to receive redstone power.
* This interface should be applied onto all tile entities that needs to receive redstone power.
* Look at TileEntityBatteryBox for reference.
*
* @author Calclavia
@ -11,14 +10,12 @@ package universalelectricity.prefab.implement;
public interface IRedstoneReceptor
{
/**
* Called when the block is powered on by
* redstone
* Called when the block is powered on by redstone
*/
public void onPowerOn();
/**
* Called when the block is powered off by
* redstone
* Called when the block is powered off by redstone
*/
public void onPowerOff();
}

View file

@ -3,10 +3,8 @@ package universalelectricity.prefab.implement;
import net.minecraftforge.common.ForgeDirection;
/**
* This interface should be applied onto all tile
* entities that are rotatable. This interface
* however is optional and you do not need it for
* your add-on to function. It just makes things
* This interface should be applied onto all tile entities that are rotatable. This interface
* however is optional and you do not need it for your add-on to function. It just makes things
* easier for you to code.
*
* @author Calclavia
@ -16,26 +14,20 @@ import net.minecraftforge.common.ForgeDirection;
public interface IRotatable
{
/**
* Gets the facing direction of the tile
* entity. Always returns the front side of
* the tile entity.
* Gets the facing direction of the tile entity. Always returns the front side of the tile
* entity.
*
* @return The facing side from 0-5 The full
* list of which side the number
* represents is in the
* @return The facing side from 0-5 The full list of which side the number represents is in the
* UniversalElectricity class.
*/
public ForgeDirection getDirection();
/**
* Sets the facing direction of the tile
* entity.
* Sets the facing direction of the tile entity.
*
* @param facingDirection
* - A direction from 0-5. The full
* list of which side the number
* represents is in the
* UniversalElectricity class.
* - A direction from 0-5. The full list of which side the number represents is in
* the UniversalElectricity class.
*/
public void setDirection(ForgeDirection facingDirection);
}

View file

@ -1,8 +1,7 @@
package universalelectricity.prefab.implement;
/**
* This interface should be applied to all things
* that has a tier/level.
* This interface should be applied to all things that has a tier/level.
*
* @author Calclavia
*

View file

@ -0,0 +1,36 @@
package universalelectricity.prefab.implement;
import net.minecraft.src.EntityPlayer;
/**
* Code written by Buildcraft.
*
* @author Buildcraft Team
*/
public interface IWrench
{
/***
* Called to ensure that the wrench can be used. To get the ItemStack that is used, check
* player.inventory.getCurrentItem()
*
* @param player
* - The player doing the wrenching
* @param x
* ,y,z - The coordinates for the block being wrenched
*
* @return true if wrenching is allowed, false if not
*/
public boolean canWrench(EntityPlayer player, int x, int y, int z);
/***
* Callback after the wrench has been used. This can be used to decrease durability or for other
* purposes. To get the ItemStack that was used, check player.inventory.getCurrentItem()
*
* @param player
* - The player doing the wrenching
* @param x
* ,y,z - The coordinates of the block being wrenched
*/
public void wrenchUsed(EntityPlayer player, int x, int y, int z);
}

View file

@ -0,0 +1,22 @@
package universalelectricity.prefab.modifier;
import net.minecraft.src.ItemStack;
/**
* This must be applied to an item that acts as a modifier or an upgrade.
*
* @author Calclavia
*
*/
public interface IModifier
{
/**
* @return - The name of the modifier.
*/
public String getName(ItemStack itemstack);
/**
* @return - How much effect does this modifier have?
*/
public int getEffectiveness(ItemStack itemstack);
}

View file

@ -0,0 +1,29 @@
package universalelectricity.prefab.modifier;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot;
/**
* This slot should be used by any container that contains an item that is a modifier. An example of
* this would be upgrade slots.
*
* @author Calclavia
*
*/
public class SlotModifier extends Slot
{
public SlotModifier(IInventory par2IInventory, int par3, int par4, int par5)
{
super(par2IInventory, par3, par4, par5);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return par1ItemStack.getItem() instanceof IModifier;
}
}

View file

@ -36,12 +36,9 @@ public class BlockMulti extends BlockContainer
}
/**
* Called when the block is right clicked by
* the player. This modified version detects
* electric items and wrench actions on your
* machine block. Do not override this
* function. Use machineActivated instead! (It
* does the same thing)
* Called when the block is right clicked by the player. This modified version detects electric
* items and wrench actions on your machine block. Do not override this function. Use
* machineActivated instead! (It does the same thing)
*/
@Override
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
@ -51,8 +48,7 @@ public class BlockMulti extends BlockContainer
}
/**
* Returns the quantity of items to drop on
* block destruction.
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)

View file

@ -3,8 +3,7 @@ package universalelectricity.prefab.multiblock;
import net.minecraft.src.EntityPlayer;
/**
* A general interface to be implemented by
* anything that needs it.
* A general interface to be implemented by anything that needs it.
*
* @author Calclavia
*

View file

@ -4,9 +4,8 @@ import net.minecraft.src.TileEntity;
import universalelectricity.core.vector.Vector3;
/**
* Interface to be applied to tile entity blocks
* that occupies more than one block space. Useful
* for large machines.
* Interface to be applied to tile entity blocks that occupies more than one block space. Useful for
* large machines.
*
* @author Calclavia
*
@ -17,18 +16,15 @@ public interface IMultiBlock extends IBlockActivate
* Called when this multiblock is created
*
* @param placedPosition
* - The position the block was
* placed at
* - The position the block was placed at
*/
public void onCreate(Vector3 placedPosition);
/**
* Called when one of the multiblocks of this
* block is destroyed
* Called when one of the multiblocks of this block is destroyed
*
* @param callingBlock
* - The tile entity who called the
* onDestroy function
* - The tile entity who called the onDestroy function
*/
public void onDestroy(TileEntity callingBlock);
}

View file

@ -14,8 +14,7 @@ import universalelectricity.prefab.network.PacketManager;
import com.google.common.io.ByteArrayDataInput;
/**
* This is a multiblock to be used for blocks that
* are bigger than one block.
* This is a multiblock to be used for blocks that are bigger than one block.
*
* @author Calclavia
*
@ -97,11 +96,9 @@ public class TileEntityMulti extends TileEntity implements IPacketReceiver
}
/**
* Determines if this TileEntity requires
* update calls.
* Determines if this TileEntity requires update calls.
*
* @return True if you want updateEntity() to
* be called, false if not
* @return True if you want updateEntity() to be called, false if not
*/
public boolean canUpdate()
{

View file

@ -5,9 +5,7 @@ import universalelectricity.prefab.network.ConnectionHandler.ConnectionType;
public interface ISimpleConnectionHandler
{
/**
* Called when a player logs in. Use this to
* reset some tile entities variables if you
* need to.
* Called when a player logs in. Use this to reset some tile entities variables if you need to.
*
* @param player
*/

View file

@ -21,20 +21,13 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
/**
* This class is used for sending and receiving
* packets between the server and the client. You
* can directly use this by registering this
* packet manager with NetworkMod. Example:
* This class is used for sending and receiving packets between the server and the client. You can
* directly use this by registering this packet manager with NetworkMod. Example:
*
* @NetworkMod(channels = { "BasicComponents" },
* clientSideRequired = true,
* serverSideRequired =
* false, packetHandler =
* PacketManager.class)
* @NetworkMod(channels = { "BasicComponents" }, clientSideRequired = true, serverSideRequired =
* false, packetHandler = PacketManager.class)
*
* Check out
* {@link #BasicComponents}
* for better reference.
* Check out {@link #BasicComponents} for better reference.
*
* @author Calclavia
*/
@ -60,7 +53,6 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
try
{
data.writeInt(id);
data = encodeDataStream(data, sendData);
Packet250CustomPayload packet = new Packet250CustomPayload();
@ -121,10 +113,8 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
}
/**
* Sends packets to clients around a specific
* coordinate. A wrapper using Vector3. See
* {@PacketDispatcher} for
* detailed information.
* Sends packets to clients around a specific coordinate. A wrapper using Vector3. See
* {@PacketDispatcher} for detailed information.
*/
public static void sendPacketToClients(Packet packet, World worldObj, Vector3 position, double range)
{
@ -140,8 +130,7 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
}
/**
* Sends a packet to all the clients on this
* server.
* Sends a packet to all the clients on this server.
*/
public static void sendPacketToClients(Packet packet, World worldObj)
{

View file

@ -0,0 +1,104 @@
package universalelectricity.prefab.ore;
import java.util.Random;
import net.minecraft.src.Block;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.core.UEConfig;
import universalelectricity.core.UniversalElectricity;
/**
* This class is used for storing ore generation data. If you are too lazy to generate your own
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
* to generate.
*
* @author Calclavia
*
*/
public abstract class OreGenBase
{
public String name;
public String oreDictionaryName;
public boolean shouldGenerate;
public int blockIndexTexture;
public ItemStack oreStack;
public int oreID;
public int oreMeta;
/**
* What harvest level does this machine need to be acquired?
*/
public int harvestLevel;
/**
* The predefined tool classes are "pickaxe", "shovel", "axe". You can add others for custom
* tools.
*/
public String harvestTool;
/**
* @param name
* - The name of the ore for display
* @param textureFile
* - The 16x16 png texture of your ore to override
* @param minGenerateLevel
* - The highest generation level of your ore
* @param maxGenerateLevel
* - The lowest generation level of your ore
* @param amountPerChunk
* - The amount of ores to generate per chunk
* @param amountPerBranch
* - The amount of ores to generate in a clutter. E.g coal generates with a lot of
* other coal next to it. How much do you want?
*/
public OreGenBase(String name, String oreDiectionaryName, ItemStack stack, String harvestTool, int harvestLevel)
{
this.name = name;
this.shouldGenerate = false;
this.harvestTool = harvestTool;
this.harvestLevel = harvestLevel;
this.oreDictionaryName = oreDiectionaryName;
this.oreStack = stack;
this.oreID = stack.itemID;
this.oreMeta = stack.getItemDamage();
OreDictionary.registerOre(oreDictionaryName, stack);
MinecraftForge.setBlockHarvestLevel(Block.blocksList[stack.itemID], stack.getItemDamage(), harvestTool, harvestLevel);
}
public OreGenBase enable()
{
this.shouldGenerate = shouldGenerateOre(name);
return this;
}
// You may inherit from this class and change
// this function if you want a
// custom texture render for your ore.
public int getBlockTextureFromSide(int side)
{
return this.blockIndexTexture;
}
// Checks the config file and see if Universal
// Electricity should generate
// this ore
private static boolean shouldGenerateOre(String oreName)
{
return UEConfig.getConfigData(UniversalElectricity.CONFIGURATION, "Generate " + oreName, true);
}
public abstract void generate(World world, Random random, int varX, int varZ);
public abstract boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator);
}

View file

@ -0,0 +1,132 @@
package universalelectricity.prefab.ore;
import java.util.Random;
import net.minecraft.src.ChunkProviderEnd;
import net.minecraft.src.ChunkProviderGenerate;
import net.minecraft.src.ChunkProviderHell;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.World;
/**
* This class is used for storing ore generation data. If you are too lazy to generate your own
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
* to generate.
*
* @author Calclavia
*
*/
public class OreGenReplace extends OreGenBase
{
public int minGenerateLevel;
public int maxGenerateLevel;
public int amountPerChunk;
public int amountPerBranch;
public int replaceID;
public boolean generateSurface;
public boolean generateNether;
public boolean generateEnd;
/**
* @param name
* - The name of the ore for display
* @param textureFile
* - The 16x16 png texture of your ore to override
* @param minGenerateLevel
* - The highest generation level of your ore
* @param maxGenerateLevel
* - The lowest generation level of your ore
* @param amountPerChunk
* - The amount of ores to generate per chunk
* @param amountPerBranch
* - The amount of ores to generate in a clutter. E.g coal generates with a lot of
* other coal next to it. How much do you want?
*/
public OreGenReplace(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
{
super(name, oreDiectionaryName, stack, harvestTool, harvestLevel);
this.minGenerateLevel = minGenerateLevel;
this.maxGenerateLevel = maxGenerateLevel;
this.amountPerChunk = amountPerChunk;
this.amountPerBranch = amountPerBranch;
this.replaceID = replaceID;
}
public void generate(World world, Random random, int varX, int varZ)
{
for (int i = 0; i < this.amountPerChunk; i++)
{
int x = varX + random.nextInt(16);
int z = varZ + random.nextInt(16);
int y = random.nextInt(this.maxGenerateLevel - this.minGenerateLevel) + this.minGenerateLevel;
generateReplace(world, random, x, y, z);
}
}
public boolean generateReplace(World par1World, Random par2Random, int par3, int par4, int par5)
{
float var6 = par2Random.nextFloat() * (float) Math.PI;
double var7 = (double) ((float) (par3 + 8) + MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
double var9 = (double) ((float) (par3 + 8) - MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
double var11 = (double) ((float) (par5 + 8) + MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
double var13 = (double) ((float) (par5 + 8) - MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
double var15 = (double) (par4 + par2Random.nextInt(3) - 2);
double var17 = (double) (par4 + par2Random.nextInt(3) - 2);
for (int var19 = 0; var19 <= this.amountPerBranch; ++var19)
{
double var20 = var7 + (var9 - var7) * (double) var19 / (double) this.amountPerBranch;
double var22 = var15 + (var17 - var15) * (double) var19 / (double) this.amountPerBranch;
double var24 = var11 + (var13 - var11) * (double) var19 / (double) this.amountPerBranch;
double var26 = par2Random.nextDouble() * (double) this.amountPerBranch / 16.0D;
double var28 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
double var30 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
for (int var38 = var32; var38 <= var35; ++var38)
{
double var39 = ((double) var38 + 0.5D - var20) / (var28 / 2.0D);
if (var39 * var39 < 1.0D)
{
for (int var41 = var33; var41 <= var36; ++var41)
{
double var42 = ((double) var41 + 0.5D - var22) / (var30 / 2.0D);
if (var39 * var39 + var42 * var42 < 1.0D)
{
for (int var44 = var34; var44 <= var37; ++var44)
{
double var45 = ((double) var44 + 0.5D - var24) / (var28 / 2.0D);
int block = par1World.getBlockId(var38, var41, var44);
if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (this.replaceID == 0 || block == this.replaceID))
{
par1World.setBlockAndMetadata(var38, var41, var44, this.oreID, this.oreMeta);
}
}
}
}
}
}
}
return true;
}
@Override
public boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator)
{
return ((this.generateSurface && chunkGenerator instanceof ChunkProviderGenerate) || (this.generateNether && chunkGenerator instanceof ChunkProviderHell) || (this.generateEnd && chunkGenerator instanceof ChunkProviderEnd));
}
}

View file

@ -0,0 +1,18 @@
package universalelectricity.prefab.ore;
import net.minecraft.src.ItemStack;
public class OreGenReplaceStone extends OreGenReplace
{
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
{
super(name, oreDiectionaryName, stack, 1, minGenerateLevel, maxGenerateLevel, amountPerChunk, amountPerBranch, harvestTool, harvestLevel);
this.generateSurface = true;
}
// A simplified version of the constructor
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int maxGenerateLevel, int amountPerChunk, int amountPerBranch)
{
this(name, oreDiectionaryName, stack, 0, replaceID, maxGenerateLevel, amountPerChunk, amountPerBranch, "pickaxe", 1);
}
}

View file

@ -0,0 +1,75 @@
package universalelectricity.prefab.ore;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.World;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
public class OreGenerator implements IWorldGenerator
{
public static boolean isInitiated = false;
/**
* Add your ore data to this list of ores for it to automatically generate! No hassle indeed!
*/
private static final List<OreGenBase> ORES_TO_GENERATE = new ArrayList<OreGenBase>();
/**
* Adds an ore to the ore generate list. Do this in pre-init.
*/
public static void addOre(OreGenBase data)
{
if (!isInitiated)
{
GameRegistry.registerWorldGenerator(new OreGenerator());
}
ORES_TO_GENERATE.add(data);
}
/**
* Checks to see if this ore
*
* @param oreName
* @return
*/
public static boolean oreExists(String oreName)
{
for (OreGenBase ore : ORES_TO_GENERATE)
{
if (ore.oreDictionaryName == oreName) { return true; }
}
return false;
}
/**
* Removes an ore to the ore generate list. Do this in init.
*/
public static void removeOre(OreGenBase data)
{
ORES_TO_GENERATE.remove(data);
}
@Override
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
chunkX = chunkX << 4;
chunkZ = chunkZ << 4;
// Checks to make sure this is the normal
// world
for (OreGenBase oreData : ORES_TO_GENERATE)
{
if (oreData.shouldGenerate && oreData.isOreGeneratedInWorld(world, chunkGenerator))
{
oreData.generate(world, rand, chunkX, chunkZ);
}
}
}
}

View file

@ -0,0 +1,41 @@
package universalelectricity.prefab.potion;
import net.minecraft.src.Potion;
import cpw.mods.fml.common.registry.LanguageRegistry;
public abstract class CustomPotion extends Potion
{
/**
* Creates a new type of potion
*
* @param id
* - The ID of this potion. Make it greater than 20.
* @param isBadEffect
* - Is this potion a good potion or a bad one?
* @param color
* - The color of this potion.
* @param name
* - The name of this potion.
*/
public CustomPotion(int id, boolean isBadEffect, int color, String name)
{
super(id, isBadEffect, color);
this.setPotionName("potion." + name);
LanguageRegistry.instance().addStringLocalization(this.getName(), name);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
/**
* You must register all your potion effects during mod initialization!
*/
public void register()
{
Potion.potionTypes[this.getId()] = this;
}
}

View file

@ -0,0 +1,41 @@
package universalelectricity.prefab.potion;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Potion;
import net.minecraft.src.PotionEffect;
public class CustomPotionEffect extends PotionEffect
{
public CustomPotionEffect(int potionID, int duration, int amplifier)
{
super(potionID, duration, amplifier);
}
public CustomPotionEffect(Potion potion, int duration, int amplifier)
{
this(potion.getId(), duration, amplifier);
}
/**
* Creates a potion effect with custom curable items.
*
* @param curativeItems
* - ItemStacks that can cure this potion effect
*/
public CustomPotionEffect(int potionID, int duration, int amplifier, List<ItemStack> curativeItems)
{
super(potionID, duration, amplifier);
if (curativeItems == null)
{
this.setCurativeItems(new ArrayList<ItemStack>());
}
else
{
this.setCurativeItems(curativeItems);
}
}
}

View file

@ -4,8 +4,7 @@ import net.minecraft.src.Block;
import net.minecraft.src.TileEntity;
/**
* A TileEntity with some pre-added
* functionalities.
* A TileEntity with some pre-added functionalities.
*
* @author Calclavia
*

View file

@ -16,8 +16,7 @@ import universalelectricity.prefab.network.IPacketReceiver;
import com.google.common.io.ByteArrayDataInput;
/**
* This tile entity pre-fabricated for all
* conductors.
* This tile entity pre-fabricated for all conductors.
*
* @author Calclavia
*
@ -27,8 +26,7 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
private ElectricityNetwork network;
/**
* Stores information on the blocks that this
* conductor is connected to
* Stores information on the blocks that this conductor is connected to
*/
public TileEntity[] connectedBlocks =
{ null, null, null, null, null, null };
@ -122,11 +120,9 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
}
/**
* Determines if this TileEntity requires
* update calls.
* Determines if this TileEntity requires update calls.
*
* @return True if you want updateEntity() to
* be called, false if not
* @return True if you want updateEntity() to be called, false if not
*/
@Override
public boolean canUpdate()

View file

@ -3,9 +3,7 @@ package universalelectricity.prefab.tile;
import universalelectricity.core.implement.IDisableable;
/**
* An easier way to implement the methods from
* IElectricityDisableable with default values
* set.
* An easier way to implement the methods from IElectricityDisableable with default values set.
*
* @author Calclavia
*/
@ -27,8 +25,7 @@ public abstract class TileEntityDisableable extends TileEntityAdvanced implement
}
/**
* Called every tick while this tile entity is
* disabled.
* Called every tick while this tile entity is disabled.
*/
protected void whileDisable()
{

View file

@ -4,8 +4,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.implement.IElectricityReceiver;
/**
* An easier way to implement the methods from
* IElectricityReceiver with default values set.
* An easier way to implement the methods from IElectricityReceiver with default values set.
*
* @author Calclavia
*/

View file

@ -1,4 +1,6 @@
package universalelectricity.core.vector;
package universalelectricity.prefab.vector;
import universalelectricity.core.vector.Vector2;
public class Region2
{
@ -17,8 +19,7 @@ public class Region2
}
/**
* Checks if a point is located inside a
* region
* Checks if a point is located inside a region
*/
public boolean isIn(Vector2 point)
{
@ -26,8 +27,7 @@ public class Region2
}
/**
* Returns whether the given region intersects
* with this one.
* Returns whether the given region intersects with this one.
*/
public boolean isIn(Region2 region)
{

View file

@ -1,4 +1,4 @@
package universalelectricity.core.vector;
package universalelectricity.prefab.vector;
import java.util.ArrayList;
import java.util.List;
@ -6,6 +6,7 @@ import java.util.List;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Entity;
import net.minecraft.src.World;
import universalelectricity.core.vector.Vector3;
/**
* A cubical region class.
@ -44,8 +45,7 @@ public class Region3
}
/**
* Checks if a point is located inside a
* region
* Checks if a point is located inside a region
*/
public boolean isIn(Vector3 point)
{
@ -53,8 +53,7 @@ public class Region3
}
/**
* Returns whether the given region intersects
* with this one.
* Returns whether the given region intersects with this one.
*/
public boolean isIn(Region3 region)
{