2020-02-25 15:14:56 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles;
|
|
|
|
|
2021-12-05 23:32:31 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.nbt.CompoundTag;
|
2021-12-05 23:32:31 +01:00
|
|
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
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-05 23:32:31 +01:00
|
|
|
public BlockEntityAuraBloom(BlockPos pos, BlockState state) {
|
2021-12-19 15:32:45 +01:00
|
|
|
this(ModBlockEntities.AURA_BLOOM, pos, state);
|
2020-02-25 15:56:46 +01:00
|
|
|
}
|
|
|
|
|
2021-12-05 23:32:31 +01:00
|
|
|
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type, BlockPos pos, BlockState state) {
|
|
|
|
super(type, pos, state);
|
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");
|
|
|
|
}
|
|
|
|
}
|