diff --git a/MODSRC/vazkii/botania/api/mana/spark/ISparkAttachable.java b/MODSRC/vazkii/botania/api/mana/spark/ISparkAttachable.java index 4f4d40220..599c75d73 100644 --- a/MODSRC/vazkii/botania/api/mana/spark/ISparkAttachable.java +++ b/MODSRC/vazkii/botania/api/mana/spark/ISparkAttachable.java @@ -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 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(); } diff --git a/MODSRC/vazkii/botania/api/mana/spark/ISparkEntity.java b/MODSRC/vazkii/botania/api/mana/spark/ISparkEntity.java index 3dbd281e5..7f5cb8954 100644 --- a/MODSRC/vazkii/botania/api/mana/spark/ISparkEntity.java +++ b/MODSRC/vazkii/botania/api/mana/spark/ISparkEntity.java @@ -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 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.
+ * 0: None
+ * 1: Dispersive
+ * 2: Dominant
+ * 3: Recessive
+ * 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(); }