diff --git a/docs/scarpet/Full.md b/docs/scarpet/Full.md index dba29bf2..e73d99ad 100644 --- a/docs/scarpet/Full.md +++ b/docs/scarpet/Full.md @@ -1690,9 +1690,10 @@ If type is `null`, POI at position is removed. In any case, previous POI is also Interestingly, `unemployed`, and `nitwit` are not used in the game, meaning, they could be used as permanent spatial markers for scarpet apps. `meeting` is the only one with increased max occupancy of 32. -### `set_biome(pos, biome_name)` +### `set_biome(pos, biome_name, update=true)` -Changes the biome at that block position. +Changes the biome at that block position. if update is specified and false, then chunk will not be refreshed +on the clients. Biome changes can only be send to clients with the entire data from the chunk. ### `update(pos)` @@ -2249,6 +2250,10 @@ Feature list: * `twisting_vines` (1.16) * `basalt_pillar` (1.16) +### `reload_chunk(pos)` + +Sends full chunk data to clients. Useful when lots stuff happened and you want to refresh it on the clients. + ### `reset_chunk(pos)`, `reset_chunk(from_pos, to_pos)`, `reset_chunk(l(pos, ...))` Removes and resets the chunk, all chunks in the specified area or all chunks in a list at once, removing all previous blocks and entities, and replacing it with a new generation. For all currently loaded chunks, they will be brought diff --git a/docs/scarpet/api/BlocksAndWorldAccess.md b/docs/scarpet/api/BlocksAndWorldAccess.md index 9750cf1a..17f16470 100644 --- a/docs/scarpet/api/BlocksAndWorldAccess.md +++ b/docs/scarpet/api/BlocksAndWorldAccess.md @@ -134,9 +134,10 @@ If type is `null`, POI at position is removed. In any case, previous POI is also Interestingly, `unemployed`, and `nitwit` are not used in the game, meaning, they could be used as permanent spatial markers for scarpet apps. `meeting` is the only one with increased max occupancy of 32. -### `set_biome(pos, biome_name)` +### `set_biome(pos, biome_name, update=true)` -Changes the biome at that block position. +Changes the biome at that block position. if update is specified and false, then chunk will not be refreshed +on the clients. Biome changes can only be send to clients with the entire data from the chunk. ### `update(pos)` @@ -693,6 +694,10 @@ Feature list: * `twisting_vines` (1.16) * `basalt_pillar` (1.16) +### `reload_chunk(pos)` + +Sends full chunk data to clients. Useful when lots stuff happened and you want to refresh it on the clients. + ### `reset_chunk(pos)`, `reset_chunk(from_pos, to_pos)`, `reset_chunk(l(pos, ...))` Removes and resets the chunk, all chunks in the specified area or all chunks in a list at once, removing all previous blocks and entities, and replacing it with a new generation. For all currently loaded chunks, they will be brought diff --git a/docs/scarpet/resources/editors/idea/2.txt b/docs/scarpet/resources/editors/idea/2.txt index 15f9ee89..e62bf3e0 100644 --- a/docs/scarpet/resources/editors/idea/2.txt +++ b/docs/scarpet/resources/editors/idea/2.txt @@ -66,6 +66,7 @@ property query random_tick rect +reload_chunk remove_all_markers reset_chunk run diff --git a/docs/scarpet/resources/editors/npp/scarpet.xml b/docs/scarpet/resources/editors/npp/scarpet.xml index cfcde776..8491a743 100644 --- a/docs/scarpet/resources/editors/npp/scarpet.xml +++ b/docs/scarpet/resources/editors/npp/scarpet.xml @@ -55,7 +55,7 @@ set without_updates blocks_movement block_sound material map_colour property block_properties block_data poi set_poi place_item set_biome biome loaded_status generation_status inhabited_time spawn_potential chunk_tickets - structure_eligibility structures structure_references set_structure reset_chunk + structure_eligibility structures structure_references set_structure reset_chunk reload_chunk scoreboard scoreboard_add scoreboard_remove scoreboard_display diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 1e542cf1..700dc977 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -1127,12 +1127,23 @@ public class CarpetExpression Biome biome = Registry.BIOME.get(new Identifier(biomeName)); if (biome == null) throw new InternalExpressionException("Unknown biome: "+biomeName); + boolean doImmediateUpdate = true; + if (lv.size() > locator.offset+1) + { + doImmediateUpdate = lv.get(locator.offset+1).evalValue(c).getBoolean(); + } ServerWorld world = cc.s.getWorld(); BlockPos pos = locator.block.getPos(); Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.BIOMES); ((BiomeArrayInterface)chunk.getBiomeArray()).setBiomeAtIndex(pos, world, biome); - this.forceChunkUpdate(pos, world); - return LazyValue.NULL; + if (doImmediateUpdate) this.forceChunkUpdate(pos, world); + return LazyValue.TRUE; + }); + + this.expr.addLazyFunction("reload_chunk", -1, (c, t, lv) -> { + CarpetContext cc = (CarpetContext)c; + this.forceChunkUpdate(BlockArgument.findIn(cc, lv, 0).block.getPos(), cc.s.getWorld()); + return LazyValue.TRUE; }); this.expr.addLazyFunction("structure_references", -1, (c, t, lv) -> {