mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
Generating flower implementation.
This commit is contained in:
1 parent
d4fb1aaf6b
commit
bdd4458056
2 files changed
+51
No files matched your search
@@ -11,8 +11,58 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
|
||||
public class SubTileGenerating extends SubTileEntity {
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
int mana;
|
||||
public int knownMana = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
int delay = getDelayBetweenPassiveGeneration();
|
||||
if(delay > 0 && supertile.worldObj.getWorldTime() % delay == 0)
|
||||
addMana(1);
|
||||
}
|
||||
|
||||
public void addMana(int mana) {
|
||||
this.mana = Math.min(getMaxMana(), this.mana + mana);
|
||||
}
|
||||
|
||||
public int getDelayBetweenPassiveGeneration() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onWanded(EntityPlayer player, ItemStack wand) {
|
||||
knownMana = mana;
|
||||
player.worldObj.playSoundAtEntity(player, "random.orb", 1F, 1F);
|
||||
|
||||
// TODO
|
||||
if(!player.worldObj.isRemote)
|
||||
player.addChatMessage("mana: " + knownMana);
|
||||
|
||||
return super.onWanded(player, wand);
|
||||
}
|
||||
|
||||
public int getMaxMana() {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacketNBT(NBTTagCompound cmp) {
|
||||
mana = cmp.getInteger(TAG_MANA);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class TileSpecialFlower extends TileMod {
|
||||
|
||||
public void setSubTile(SubTileEntity tile) {
|
||||
subTile = tile;
|
||||
subTile.setSupertile(this);
|
||||
}
|
||||
|
||||
private void provideSubTile(String name) {
|
||||
|
||||
Reference in new issue
Block a user