TheBrokenRail
b347a67a10
All checks were successful
EnergonRelics/pipeline/head This commit looks good
36 lines
1.4 KiB
Java
36 lines
1.4 KiB
Java
package com.thebrokenrail.energonrelics.block.entity;
|
|
|
|
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
|
import com.thebrokenrail.energonrelics.api.energy.Action;
|
|
import com.thebrokenrail.energonrelics.block.HolographicSkyBlock;
|
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.LightType;
|
|
|
|
public class HolographicSkyBlockEntity extends EnergyReceiverBlockEntity {
|
|
public HolographicSkyBlockEntity(BlockEntityType<?> type) {
|
|
super(type);
|
|
}
|
|
|
|
@Override
|
|
protected void energyTick() {
|
|
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.HOLOGRAPHIC_SKY_ENERGY_REQUIRED, HolographicSkyBlock.POWERED, true, false));
|
|
|
|
assert getWorld() != null;
|
|
|
|
int newLightLevel;
|
|
if (getCachedState().get(HolographicSkyBlock.POWERED)) {
|
|
newLightLevel = getWorld().getLightLevel(LightType.SKY, new BlockPos(getPos().getX(), 1024, getPos().getZ())) - getWorld().getAmbientDarkness();
|
|
} else {
|
|
newLightLevel = 0;
|
|
}
|
|
|
|
int oldLightLevel = getCachedState().get(HolographicSkyBlock.LIGHT_LEVEL);
|
|
|
|
if (oldLightLevel != newLightLevel) {
|
|
getWorld().setBlockState(getPos(), getCachedState().with(HolographicSkyBlock.LIGHT_LEVEL, newLightLevel));
|
|
}
|
|
}
|
|
}
|