Javadoc standard sunlight rules
import org.terasology.world.propagation.SingleChunkView;
/**
+ * Rules that determine how the sunlight propagates
*/
public class SunlightPropagationRules extends CommonLightPropagationRules {
@@ -37,17 +38,32 @@ public SunlightPropagationRules(LitChunk chunk) {
this.regenWorldView = new SingleChunkView(new SunlightRegenPropagationRules(), chunk);
}
+ /**
+ * If the light is above the sunlight regeneration threshold it is maintained, otherwise it is zero
+ * <p>
+ * {@inheritDoc}
+ */
@Override
public byte getFixedValue(Block block, Vector3i pos) {
byte lightVal = (byte) (regenWorldView.getValueAt(pos) - ChunkConstants.SUNLIGHT_REGEN_THRESHOLD);
return (lightVal > 0) ? lightVal : 0;
}
+ /**
+ * Sunlight reduces by one to a minimum of zero per propagation
+ * <p>
+ * {@inheritDoc}
+ */
@Override
public byte propagateValue(byte existingValue, Side side, Block from) {
- return (existingValue > 0) ? (byte) (existingValue - 1) : 0;
+ return (byte) Math.max(existingValue - 1, 0);
}
+ /**
+ * The maximum sunlight is given by {@link ChunkConstants#MAX_SUNLIGHT}
+ * <p>
+ * {@inheritDoc}
+ */
@Override
public byte getMaxValue() {
return ChunkConstants.MAX_SUNLIGHT;
