Merge branch 'master' into 1.15

# Conflicts:
#	src/main/java/carpet/script/CarpetExpression.java
This commit is contained in:
gnembon committed 2020-01-25 20:06:54 -04:00
commit 797894c662
7 files changed
+147 -26

No files matched your search

@@ -103,6 +103,7 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import org.apache.commons.lang3.tuple.Pair;
@@ -608,6 +609,8 @@ public class CarpetExpression
* <p>Numeric function, indicating hardness of a block.</p>
* <h3><code>blast_resistance(pos)</code></h3>
* <p>Numeric function, indicating blast_resistance of a block.</p>
* <h3><code>in_slime_chunk(pos)</code></h3>
* <p>Boolean indicating if the given block position is in a slime chunk.</p>
* <h3><code>top(type, pos)</code></h3>
* <p>Returns the Y value of the topmost block at given x, z coords (y value of a block is not important), according to the
@@ -624,7 +627,7 @@ public class CarpetExpression
* top('ocean_floor', x, y, z) =&gt; 41
* </pre>
* <h3><code>loaded(pos)</code></h3>
* <p>Boolean function, true if the block is accessible forthe game mechanics.
* <p>Boolean function, true if the block is accessible for the game mechanics.
* Normally <code>scarpet</code> doesn't check if operates on
* loaded area - the game will automatically load missing blocks. We see this as advantage.
* Vanilla <code>fill/clone</code> commands only check the specified corners for loadness.</p>
@@ -1019,6 +1022,19 @@ public class CarpetExpression
this.expr.addLazyFunction("blast_resistance", -1, (c, t, lv) ->
genericStateTest(c, "blast_resistance", lv, (s, p, w) -> new NumericValue(s.getBlock().getBlastResistance())));
this.expr.addLazyFunction("in_slime_chunk", -1, (c, t, lv) ->
{
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
ChunkPos chunkPos = new ChunkPos(pos);
Value ret = new NumericValue(ChunkRandom.create(
chunkPos.x, chunkPos.z,
((CarpetContext)c).s.getWorld().getSeed(),
987234911L
).nextInt(10) == 0);
return (_c, _t) -> ret;
});
this.expr.addLazyFunction("top", -1, (c, t, lv) ->
{
String type = lv.get(0).evalValue(c).getString().toLowerCase(Locale.ROOT);
@@ -2959,6 +2975,8 @@ public class CarpetExpression
* loop(1000,game_tick()) // runs the game as fast as it can for 1000 ticks
* loop(1000,game_tick(100)) // runs the game twice as slow for 1000 ticks
* </pre>
* <h3><code>seed()</code></h3>
* <p>Returns current world seed.</p>
* <h3><code>current_dimension()</code></h3>
* <p>Returns current dimension that the script runs in.</p>
* <h3><code>in_dimension(smth, expr)</code></h3>
@@ -3018,9 +3036,9 @@ public class CarpetExpression
* <li><code>igloo</code>: Igloo</li>
* <li><code>shipwreck</code>: Shipwreck, version1?</li>
* <li><code>shipwreck2</code>: Shipwreck, version2?</li>
* <li><code>witchhut</code></li>
* <li><code>oceanruin, oceanruin_small, oceanruin_tall</code>: Stone variants of ocean ruins.</li>
* <li><code>oceanruin_warm, oceanruin_warm_small, oceanruin_warm_tall</code>: Sandstone variants of ocean ruins.</li>
* <li><code>witch_hut</code></li>
* <li><code>ocean_ruin, ocean_ruin_small, ocean_ruin_tall</code>: Stone variants of ocean ruins.</li>
* <li><code>ocean_ruin_warm, ocean_ruin_warm_small, ocean_ruin_warm_tall</code>: Sandstone variants of ocean ruins.</li>
* <li><code>treasure</code>: A treasure chest. Yes, its a whole structure.</li>
* <li><code>pillager_outpost</code>: A pillager outpost.</li>
* <li><code>mineshaft</code>: A mineshaft.</li>
@@ -3401,6 +3419,12 @@ public class CarpetExpression
return (cc, tt) -> Value.TRUE;
});
this.expr.addLazyFunction("seed", -1, (c, t, lv) -> {
ServerCommandSource s = ((CarpetContext)c).s;
Value ret = new NumericValue(s.getWorld().getSeed());
return (cc, tt) -> ret;
});
this.expr.addLazyFunction("current_dimension", 0, (c, t, lv) -> {
ServerCommandSource s = ((CarpetContext)c).s;
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.DIMENSION_TYPE.getId(s.getWorld().dimension.getType())));