Skip to content

Commit

Permalink
Merge pull request #259 from Lildirt/master
Browse files Browse the repository at this point in the history
Added get_temperature()
  • Loading branch information
LadyCailin committed Feb 14, 2015
2 parents dea2090 + c29c94e commit 106d750
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/blocks/MCBlock.java
Expand Up @@ -24,6 +24,8 @@ public interface MCBlock extends MCMetadatable {

public void setTypeAndData(int type, byte data, boolean physics);

public double getTemperature();

public MCBlockState getState();

public MCMaterial getType();
Expand Down
Expand Up @@ -67,6 +67,11 @@ public void setTypeAndData(int type, byte data, boolean physics) {
b.setTypeIdAndData(type, data, physics);
}

@Override
public double getTemperature() {
return b.getTemperature();
}

@Override
public MCBlockState getState() {
if(b.getState() == null){
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/World.java
Expand Up @@ -1801,4 +1801,54 @@ public Version since() {
}

}

@api
public static class get_temperature extends AbstractFunction {

@Override
public ExceptionType[] thrown() {
return new Exceptions.ExceptionType[]{Exceptions.ExceptionType.FormatException};
}

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

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

@Override
public Construct exec(Target target, Environment environment, Construct... args) throws ConfigRuntimeException {
MCPlayer player = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
MCWorld world = null;
if(player != null) {
world = player.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], world, target);
return new CDouble(loc.getBlock().getTemperature(), target);
}

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

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

@Override
public String docs() {
return "double {locationArray} Returns the current temperature of the location given.";
}

@Override
public Version since() {
return CHVersion.V3_3_1;
}
}
}

0 comments on commit 106d750

Please sign in to comment.