BloodMagic/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java

38 lines
985 B
Java
Raw Normal View History

2015-12-27 19:38:12 -05:00
package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.tile.base.TileTicking;
2015-12-27 19:38:12 -05:00
import net.minecraft.nbt.NBTTagCompound;
2017-08-15 21:30:48 -07:00
public class TilePhantomBlock extends TileTicking {
private int ticksRemaining = 10;
2015-12-27 19:38:12 -05:00
public TilePhantomBlock() {
}
2017-08-15 21:30:48 -07:00
public TilePhantomBlock(int ticksRemaining) {
this.ticksRemaining = ticksRemaining;
2015-12-27 19:38:12 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public void deserialize(NBTTagCompound tagCompound) {
this.ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
2015-12-27 19:38:12 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public NBTTagCompound serialize(NBTTagCompound tagCompound) {
2015-12-27 19:38:12 -05:00
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
return tagCompound;
2015-12-27 19:38:12 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public void onUpdate() {
2015-12-27 19:38:12 -05:00
ticksRemaining--;
2017-08-15 21:30:48 -07:00
if (ticksRemaining <= 0) {
2016-12-12 19:56:36 -08:00
getWorld().setBlockToAir(getPos());
getWorld().removeTileEntity(getPos());
2015-12-27 19:38:12 -05:00
}
}
}