NaturesAura/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java

43 lines
1.3 KiB
Java
Raw Normal View History

2020-02-25 15:14:56 +01:00
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
2021-12-04 15:40:09 +01:00
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.tileentity.BlockEntityType;
2020-02-25 15:14:56 +01:00
2021-12-04 15:40:09 +01:00
public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBlockEntity {
2020-02-25 15:14:56 +01:00
public boolean justGenerated;
2021-12-04 15:40:09 +01:00
public BlockEntityAuraBloom() {
2020-02-25 15:56:46 +01:00
this(ModTileEntities.AURA_BLOOM);
}
2021-12-04 15:40:09 +01:00
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type) {
2020-02-25 15:56:46 +01:00
super(type);
2020-02-25 15:14:56 +01:00
}
// Doing this in validate() creates a loading deadlock for some reason...
@Override
public void tick() {
2021-12-04 15:40:09 +01:00
if (this.level.isClientSide || !this.justGenerated)
2020-02-25 15:14:56 +01:00
return;
2021-03-30 15:44:31 +02:00
this.generateAura(150000);
2020-02-25 15:14:56 +01:00
this.justGenerated = false;
}
@Override
2021-12-04 15:40:09 +01:00
public void writeNBT(CompoundTag compound, SaveType type) {
2020-02-25 15:14:56 +01:00
super.writeNBT(compound, type);
if (type == SaveType.TILE)
compound.putBoolean("just_generated", this.justGenerated);
}
@Override
2021-12-04 15:40:09 +01:00
public void readNBT(CompoundTag compound, SaveType type) {
2020-02-25 15:14:56 +01:00
super.readNBT(compound, type);
if (type == SaveType.TILE)
this.justGenerated = compound.getBoolean("just_generated");
}
}