2018-11-24 15:06:18 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles;
|
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
|
|
|
import de.ellpeck.naturesaura.misc.LevelData;
|
2021-12-08 00:31:29 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
2020-02-15 13:07:43 +01:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public class BlockEntitySpawnLamp extends BlockEntityImpl {
|
2018-11-24 15:06:18 +01:00
|
|
|
|
2021-12-08 00:31:29 +01:00
|
|
|
public BlockEntitySpawnLamp(BlockPos pos, BlockState state) {
|
2021-12-19 15:32:45 +01:00
|
|
|
super(ModBlockEntities.SPAWN_LAMP, pos, state);
|
2020-01-21 23:02:39 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 15:06:18 +01:00
|
|
|
public int getRadius() {
|
|
|
|
return this.redstonePower * 3;
|
|
|
|
}
|
|
|
|
|
2020-02-15 13:07:43 +01:00
|
|
|
@Override
|
2021-12-08 00:31:29 +01:00
|
|
|
public void onLoad() {
|
|
|
|
super.onLoad();
|
2021-12-04 15:40:09 +01:00
|
|
|
if (!this.level.isClientSide) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var data = (LevelData) ILevelData.getLevelData(this.level);
|
2020-02-15 13:07:43 +01:00
|
|
|
data.spawnLamps.add(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-08 00:31:29 +01:00
|
|
|
public void setRemoved() {
|
|
|
|
super.setRemoved();
|
2021-12-04 15:40:09 +01:00
|
|
|
if (!this.level.isClientSide) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var data = (LevelData) ILevelData.getLevelData(this.level);
|
2020-02-15 13:07:43 +01:00
|
|
|
data.spawnLamps.remove(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 13:57:34 +01:00
|
|
|
@Override
|
2019-03-19 17:21:06 +01:00
|
|
|
public void onRedstonePowerChange(int newPower) {
|
|
|
|
super.onRedstonePowerChange(newPower);
|
2021-12-04 15:40:09 +01:00
|
|
|
if (!this.level.isClientSide)
|
2019-01-27 13:57:34 +01:00
|
|
|
this.sendToClients();
|
|
|
|
}
|
2023-02-16 19:03:26 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean allowsLowerLimiter() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-24 15:06:18 +01:00
|
|
|
}
|