mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Added the Mana Fluxfield. GET ON THE RF BANDWAGON, NO FUN REQUIRED
This commit is contained in:
1 parent
e5bf31ae2f
commit
b103323cb7
9 files changed
+285
-1
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Aug 29, 2014, 9:51:58 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.tile.mana.TileDistributor;
|
||||
import vazkii.botania.common.block.tile.mana.TileRFGenerator;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockRFGenerator extends BlockModContainer {
|
||||
|
||||
protected BlockRFGenerator() {
|
||||
super(Material.rock);
|
||||
setHardness(2.0F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockName(LibBlockNames.RF_GENERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileRFGenerator)
|
||||
((TileRFGenerator) tile).onNeighborTileChange(tileX, tileY, tileZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileRFGenerator();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,7 @@ import vazkii.botania.common.block.tile.mana.TileDistributor;
|
||||
import vazkii.botania.common.block.tile.mana.TileManaDetector;
|
||||
import vazkii.botania.common.block.tile.mana.TileManaVoid;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.block.tile.mana.TileRFGenerator;
|
||||
import vazkii.botania.common.block.tile.mana.TileSpreader;
|
||||
import vazkii.botania.common.block.tile.mana.TileTurntable;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
@@ -171,6 +172,7 @@ public final class ModBlocks {
|
||||
public static Block customBrick;
|
||||
public static Block enderEye;
|
||||
public static Block starfield;
|
||||
public static Block rfGenerator;
|
||||
|
||||
public static Block livingwoodStairs;
|
||||
public static Block livingwoodSlab;
|
||||
@@ -288,7 +290,8 @@ public final class ModBlocks {
|
||||
customBrick = new BlockCustomBrick();
|
||||
enderEye = new BlockEnderEye();
|
||||
starfield = new BlockStarfield();
|
||||
|
||||
rfGenerator = new BlockRFGenerator();
|
||||
|
||||
livingwoodStairs = new BlockLivingwoodStairs();
|
||||
livingwoodSlab = new BlockLivingwoodSlab(false);
|
||||
livingwoodSlabFull = new BlockLivingwoodSlab(true);
|
||||
@@ -465,6 +468,7 @@ public final class ModBlocks {
|
||||
registerTile(TileSpawnerClaw.class, LibBlockNames.SPAWNER_CLAW);
|
||||
registerTile(TileEnderEye.class, LibBlockNames.ENDER_EYE_BLOCK);
|
||||
registerTile(TileStarfield.class, LibBlockNames.STARFIELD);
|
||||
registerTile(TileRFGenerator.class, LibBlockNames.RF_GENERATOR);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Aug 29, 2014, 10:01:32 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(iface = "cofh.api.energy.IEnergyConnection", modid = "CoFHAPI")
|
||||
public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyConnection {
|
||||
|
||||
private static final int MAX_MANA = 1280;
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
|
||||
int mana = 0;
|
||||
|
||||
// Thanks to skyboy for help with this cuz I'm a noob with RF
|
||||
private IEnergyHandler[] handlerCache;
|
||||
private boolean deadCache;
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
public void validate() {
|
||||
super.validate();
|
||||
deadCache = true;
|
||||
handlerCache = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
if(deadCache)
|
||||
reCache();
|
||||
|
||||
int transfer = Math.min(mana, 160);
|
||||
mana -= transfer;
|
||||
mana += transmitEnergy(transfer);
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
protected final int transmitEnergy(int energy) {
|
||||
if (handlerCache != null)
|
||||
for(int i = handlerCache.length; i-- > 0;) {
|
||||
IEnergyHandler tile = handlerCache[i];
|
||||
if (tile == null)
|
||||
continue;
|
||||
|
||||
ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i];
|
||||
if(tile.receiveEnergy(from, energy, true) > 0)
|
||||
energy -= tile.receiveEnergy(from, energy * 10, false) / 10;
|
||||
|
||||
if(energy <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
private void reCache() {
|
||||
if(deadCache) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
onNeighborTileChange(xCoord + dir.offsetX,
|
||||
yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
deadCache = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
public void onNeighborTileChange(int x, int y, int z) {
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if(x < xCoord)
|
||||
addCache(tile, 5);
|
||||
else if(x > xCoord)
|
||||
addCache(tile, 4);
|
||||
else if(z < zCoord)
|
||||
addCache(tile, 3);
|
||||
else if(z > zCoord)
|
||||
addCache(tile, 2);
|
||||
else if(y < yCoord)
|
||||
addCache(tile, 1);
|
||||
else if(y > yCoord)
|
||||
addCache(tile, 0);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI")
|
||||
private void addCache(TileEntity tile, int side) {
|
||||
if(handlerCache != null)
|
||||
handlerCache[side] = null;
|
||||
|
||||
if(tile instanceof IEnergyHandler && ((IEnergyHandler)tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) {
|
||||
if(handlerCache == null)
|
||||
handlerCache = new IEnergyHandler[6];
|
||||
handlerCache[side] = (IEnergyHandler)tile;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
return mana >= MAX_MANA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveMana(int mana) {
|
||||
this.mana = Math.min(MAX_MANA, this.mana + mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveManaFromBursts() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
mana = cmp.getInteger(TAG_MANA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,6 +236,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addBlock(ModBlocks.distributor);
|
||||
addBlock(ModBlocks.manaVoid);
|
||||
addBlock(ModBlocks.manaDetector);
|
||||
addBlock(ModBlocks.rfGenerator);
|
||||
addBlock(ModBlocks.spreader);
|
||||
addBlock(ModBlocks.turntable);
|
||||
addItem(ModItems.spark);
|
||||
|
||||
@@ -56,6 +56,7 @@ public final class LibBlockNames {
|
||||
public static final String CUSTOM_BRICK = "customBrick";
|
||||
public static final String ENDER_EYE_BLOCK = "enderEyeBlock";
|
||||
public static final String STARFIELD = "starfield";
|
||||
public static final String RF_GENERATOR = "rfGenerator";
|
||||
|
||||
public static final String SPECIAL_FLOWER_PREFIX = FLOWER + ".";
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||
* accept it; otherwise just use IEnergyHandler.
|
||||
*
|
||||
* Note that {@link IEnergyHandler} is an extension of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the TileEntity can connect on a given side.
|
||||
*/
|
||||
boolean canConnectEnergy(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
*
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyHandler extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to receive.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to extract.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -425,6 +425,7 @@ tile.botania:customBrick14.name=Azulejo
|
||||
tile.botania:customBrick15.name=Azulejo
|
||||
tile.botania:enderEyeBlock.name=Ender Overseer
|
||||
tile.botania:starfield.name=Starfield Creator
|
||||
tile.botania:rfGenerator.name=Mana Fluxfield
|
||||
|
||||
# FLOWER NAMES
|
||||
tile.botania:flower..name=Botania Flower
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Reference in new issue
Block a user