Is there a way to get the light level on a block/location and is it possible to get the difference between the natural light and the artificial light?
When I try, they are not present.
Possibly not implemented? pokes @gabizou
It’s not currently or a bug, I tried with @ryantheleach
1 Like
They appear to be implemented. Note that you need to get to get the property for a particular Location
(not a BlockState
).
I was doing this.
@Listener
public void onClick(InteractBlockEvent.Secondary event){
Optional<GroundLuminanceProperty> ground = event.getTargetBlock().getProperty(GroundLuminanceProperty.class);
Optional<SkyLuminanceProperty> sky = event.getTargetBlock().getProperty(SkyLuminanceProperty.class);
for(Property property : event.getTargetBlock().getExtendedState().getApplicableProperties())
System.out.println(property.getKey());
System.out.println("-------------");
if(ground.isPresent()){
GroundLuminanceProperty property = ground.get();
System.out.println(property.getValue());
}
if(sky.isPresent()){
SkyLuminanceProperty property = sky.get();
System.out.println(property.getValue());
}
}
Here’s an example:
@Listener
public void onInteract(InteractBlockEvent.Secondary event, @First Player player) {
player.sendMessage(Text.of("Luminance: ", event.getTargetBlock().getLocation().get().getProperty(GroundLuminanceProperty.class).get().getValue()));
}
Note that the Property
is being retrieved from the Location
, not the BlockSnapshot
.
1 Like
Hmm perhaps the properties should be available on the BlockSnapshot too
Not with how MC works, light values are cached per location on the live world, they can’t be restored or stored since they’d be invalid on a BlockSnapshot
.
wat?
Engrish gabi, engrish.
1 Like