mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 13:09:42 +00:00
Mana Distributors do stuff now.
This commit is contained in:
1 parent
6eaeb4a330
commit
804902be89
2 files changed
+55
-2
No files matched your search
@@ -13,7 +13,8 @@ package vazkii.botania.api.mana;
|
||||
|
||||
/**
|
||||
* Any TileEntity that implements this is considered a Mana Pool,
|
||||
* by which nearby functional flowers will pull mana from it.<br><br>
|
||||
* by which nearby functional flowers will pull mana from it.<br>
|
||||
* Mana Distributors will also accept it as valid output.<br><br>
|
||||
*
|
||||
* <b>Implementation Instructions:</b><br>
|
||||
* - Override invalidate() and onChunkUnload(), calling <i>ManaNetworkEvent.removePool(this);</i> on both.<br>
|
||||
|
||||
@@ -11,8 +11,60 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
|
||||
public class TileDistributor extends TileEntity {
|
||||
public class TileDistributor extends TileMod implements IManaReceiver {
|
||||
|
||||
List<IManaReceiver> validPools = new ArrayList();
|
||||
|
||||
static final ForgeDirection[] DIRECTIONS = new ForgeDirection[] {
|
||||
ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST
|
||||
};
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
validPools.clear();
|
||||
for(ForgeDirection dir : DIRECTIONS) {
|
||||
TileEntity tileAt = worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
|
||||
if(tileAt != null && tileAt instanceof IManaPool) {
|
||||
IManaReceiver receiver = (IManaReceiver) tileAt;
|
||||
if(!receiver.isFull())
|
||||
validPools.add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
return validPools.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveMana(int mana) {
|
||||
int tiles = validPools.size();
|
||||
if(tiles != 0) {
|
||||
int manaForEach = mana / tiles;
|
||||
for(IManaReceiver pool : validPools) {
|
||||
pool.recieveMana(manaForEach);
|
||||
PacketDispatcher.sendPacketToAllInDimension(((TileEntity) pool).getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveManaFromBursts() {
|
||||
return !isFull();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user