You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package com.zivilon.cinder_loe.tileentity;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
public class TileEntityShadowTile extends TileEntity {
|
|
public long spawnTime;
|
|
public static long REMOVAL_DELAY_MS = 15000;
|
|
|
|
@Override
|
|
public void updateEntity() {
|
|
if (!worldObj.isRemote) {
|
|
if (spawnTime == 0) {
|
|
spawnTime = System.currentTimeMillis();
|
|
}
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
if (currentTime >= spawnTime + REMOVAL_DELAY_MS) {
|
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); // Force the client to update
|
|
worldObj.removeTileEntity(xCoord, yCoord, zCoord); // Clean up the tile entity
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void writeToNBT(NBTTagCompound nbt) {
|
|
super.writeToNBT(nbt);
|
|
nbt.setLong("spawnTime", spawnTime);
|
|
}
|
|
|
|
@Override
|
|
public void readFromNBT(NBTTagCompound nbt) {
|
|
super.readFromNBT(nbt);
|
|
spawnTime = nbt.getLong("spawnTime");
|
|
}
|
|
}
|