Comment Spark API classes.

This commit is contained in:
Lizbeth Rika committed 2014-08-26 18:15:55 +01:00
1 parent 8861b27245
commit c2930a0102
2 files changed
+69

No files matched your search

@@ -11,17 +11,48 @@
*/
package vazkii.botania.api.mana.spark;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import vazkii.botania.api.mana.IManaReceiver;
/**
* A TileEntity that implements this can have a Spark attached to it.
* For the Spark to be allowed to have upgrades, it needs to be an IManaPool.
*/
public interface ISparkAttachable extends IManaReceiver {
/**
* Can this block have a Spark attached to it. Note that this will not
* unattach the Spark if it's changed later.
*/
public boolean canAttachSpark(ItemStack stack);
/**
* Called when the Spark is attached.
*/
public void attachSpark(ISparkEntity entity);
/**
* Gets the Spark that is attached to this block. A common implementation is
* to check for Spark entities above:
*
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
if(sparks.size() == 1) {
Entity e = (Entity) sparks.get(0);
return (ISparkEntity) e;
}
return null;
*/
public ISparkEntity getAttachedSpark();
/**
* Return true if this Tile no longer requires mana and all Sparks
* transferring mana to it should cancel their transfer.
*/
public boolean areIncomingTranfersDone();
}
@@ -13,18 +13,56 @@ package vazkii.botania.api.mana.spark;
import java.util.Collection;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
/**
* An Entity that implements this is considered a Spark.
*/
public interface ISparkEntity {
/**
* Which TileEntity is this Spark attached to? A common implementation is checking the block below.
*
int x = MathHelper.floor_double(posX);
int y = MathHelper.floor_double(posY) - 1;
int z = MathHelper.floor_double(posZ);
TileEntity tile = worldObj.getTileEntity(x, y, z);
if(tile != null && tile instanceof ISparkAttachable)
return (ISparkAttachable) tile;
return null;
*/
public ISparkAttachable getAttachedTile();
/**
* Gets a collection of all Sparks this is tranfering to.
*/
public Collection<ISparkEntity> getTransfers();
/**
* Registers the Spark passed in as a Spark meant for mana to be transfered towards.
*/
public void registerTransfer(ISparkEntity entity);
/**
* Gets which upgrade is in this Spark.<br>
* 0: None<br>
* 1: Dispersive<br>
* 2: Dominant<br>
* 3: Recessive<br>
* 4: Isolated
*/
public int getUpgrade();
/**
* Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade}
*/
public void setUpgrade(int upgrade);
/**
* See {@link ISparkAttachable#areIncomingTranfersDone()}
*/
public boolean areIncomingTransfersDone();
}