Skip to content
Permalink
Browse files

Add separate light level functions for sky and block sources

  • Loading branch information
PseudoKnight committed Dec 22, 2019
1 parent 330f1cf commit c88780cd605e79b30c5b0801082accde4eeaee23
Showing with 106 additions and 0 deletions.
  1. +106 −0 src/main/java/com/laytonsmith/core/functions/Environment.java
@@ -1921,6 +1921,112 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class get_sky_light_at extends AbstractFunction {

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CRECastException.class, CREInvalidWorldException.class,
CREFormatException.class};
}

@Override
public boolean isRestricted() {
return false;
}

@Override
public Boolean runAsync() {
return false;
}

@Override
public String getName() {
return "get_sky_light_at";
}

@Override
public Integer[] numArgs() {
return new Integer[]{1};
}

@Override
public String docs() {
return "int {locationArray} Returns the sky light level for a location."
+ " Disregards all block sources of light, where 15 is directly beneath the sky during the day.";
}

@Override
public Version since() {
return MSVersion.V3_3_4;
}

@Override
public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args)
throws ConfigRuntimeException {
MCWorld w = null;
MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
if(pl != null) {
w = pl.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
return new CInt(loc.getBlock().getLightFromSky(), t);
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class get_block_light_at extends AbstractFunction {

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CRECastException.class, CREInvalidWorldException.class,
CREFormatException.class};
}

@Override
public boolean isRestricted() {
return false;
}

@Override
public Boolean runAsync() {
return false;
}

@Override
public String getName() {
return "get_block_light_at";
}

@Override
public Integer[] numArgs() {
return new Integer[]{1};
}

@Override
public String docs() {
return "int {locationArray} Returns the block light level at a location."
+ " This counts block sources like torches and lava, disregarding light from the sky.";
}

@Override
public Version since() {
return MSVersion.V3_3_4;
}

@Override
public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args)
throws ConfigRuntimeException {
MCWorld w = null;
MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
if(pl != null) {
w = pl.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
return new CInt(loc.getBlock().getLightFromBlocks(), t);
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class is_block_powered extends AbstractFunction {

0 comments on commit c88780c

Please sign in to comment.
You can’t perform that action at this time.