Search in sources :

Example 1 with GroundLuminanceProperty

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

the class GroundLuminancePropertyStore method getFor.

@Override
public Optional<GroundLuminanceProperty> 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.BLOCK, ((IMixinLocation) propertyHolder).getBlockPos());
        return Optional.of(new GroundLuminanceProperty(light));
    }
    return super.getFor(propertyHolder);
}
Also used : GroundLuminanceProperty(org.spongepowered.api.data.property.block.GroundLuminanceProperty) Chunk(net.minecraft.world.chunk.Chunk) Location(org.spongepowered.api.world.Location) IMixinLocation(org.spongepowered.common.interfaces.world.IMixinLocation)

Example 2 with GroundLuminanceProperty

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

the class GroundLuminancePropertyStore method getFor.

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

Aggregations

GroundLuminanceProperty (org.spongepowered.api.data.property.block.GroundLuminanceProperty)2 Chunk (net.minecraft.world.chunk.Chunk)1 Location (org.spongepowered.api.world.Location)1 World (org.spongepowered.api.world.World)1 IMixinLocation (org.spongepowered.common.interfaces.world.IMixinLocation)1