added string ops and biome getter
This commit is contained in:
1 parent
a066c02469
commit
99af49661b
2 files changed
+28
No files matched your search
@@ -400,6 +400,8 @@ public class CarpetExpression
|
||||
* place_item('piston,x,y,z,'down') // places a piston facing down
|
||||
* place_item('carrot',x,y,z) // attempts to plant a carrot plant. Returns true if could place carrots at that position.
|
||||
* </pre>
|
||||
* <h3><code>biome(pos)</code></h3>
|
||||
* <p>returns biome at that block position.</p>
|
||||
* <h3><code>set_biome(pos, biome_name)</code></h3>
|
||||
* <p>changes biome at that block position.</p>
|
||||
* <h3><code>update(pos)</code></h3>
|
||||
@@ -997,6 +999,16 @@ public class CarpetExpression
|
||||
return (_c, _t) -> res;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("biome", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Biome biome = world.getBiome(pos);
|
||||
Value res = new StringValue(biome.getTranslationKey().replaceFirst("^biome\\.minecraft\\.", ""));
|
||||
return (_c, _t) -> res;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("set_biome", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
|
||||
Reference in new issue
Block a user