NaturesAura/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySpawnLamp.java
2023-02-16 19:03:26 +01:00

47 lines
1.2 KiB
Java

package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.misc.LevelData;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
public class BlockEntitySpawnLamp extends BlockEntityImpl {
public BlockEntitySpawnLamp(BlockPos pos, BlockState state) {
super(ModBlockEntities.SPAWN_LAMP, pos, state);
}
public int getRadius() {
return this.redstonePower * 3;
}
@Override
public void onLoad() {
super.onLoad();
if (!this.level.isClientSide) {
var data = (LevelData) ILevelData.getLevelData(this.level);
data.spawnLamps.add(this);
}
}
@Override
public void setRemoved() {
super.setRemoved();
if (!this.level.isClientSide) {
var data = (LevelData) ILevelData.getLevelData(this.level);
data.spawnLamps.remove(this);
}
}
@Override
public void onRedstonePowerChange(int newPower) {
super.onRedstonePowerChange(newPower);
if (!this.level.isClientSide)
this.sendToClients();
}
@Override
public boolean allowsLowerLimiter() {
return true;
}
}