Search in sources :

Example 1 with SkyLuminanceProperty

use of org.spongepowered.api.data.property.block.SkyLuminanceProperty in project SpongeCommon by SpongePowered.

the class SkyLuminancePropertyStore method getFor.

@Override
public Optional<SkyLuminanceProperty> getFor(Location<World> location) {
    final net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
    final float light = world.getLightFor(EnumSkyBlock.SKY, VecHelper.toBlockPos(location));
    return Optional.of(new SkyLuminanceProperty(light));
}
Also used : SkyLuminanceProperty(org.spongepowered.api.data.property.block.SkyLuminanceProperty) World(org.spongepowered.api.world.World)

Example 2 with SkyLuminanceProperty

use of org.spongepowered.api.data.property.block.SkyLuminanceProperty in project SpongeCommon by SpongePowered.

the class SkyLuminancePropertyStore method getFor.

@Override
public Optional<SkyLuminanceProperty> getFor(PropertyHolder propertyHolder) {
    if (propertyHolder instanceof Location && ((Location<?>) propertyHolder).getExtent() instanceof Chunk) {
        final Chunk chunk = (Chunk) ((Location<?>) propertyHolder).getExtent();
        final float light = chunk.getLightFor(EnumSkyBlock.SKY, VecHelper.toBlockPos((Location<?>) propertyHolder));
        return Optional.of(new SkyLuminanceProperty(light));
    }
    return super.getFor(propertyHolder);
}
Also used : SkyLuminanceProperty(org.spongepowered.api.data.property.block.SkyLuminanceProperty) Chunk(net.minecraft.world.chunk.Chunk) Location(org.spongepowered.api.world.Location)

Aggregations

SkyLuminanceProperty (org.spongepowered.api.data.property.block.SkyLuminanceProperty)2 Chunk (net.minecraft.world.chunk.Chunk)1 Location (org.spongepowered.api.world.Location)1 World (org.spongepowered.api.world.World)1