proper block updating
This commit is contained in:
1 parent
a62d4d73af
commit
6871ac027c
2 files changed
+12
-18
No files matched your search
@@ -949,16 +949,26 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("set_biome", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
if (lv.size() == locator.offset)
|
||||
throw new InternalExpressionException("set_biome needs a biome name as an argument");
|
||||
String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
|
||||
Biome biome = Registry.BIOME.get(new Identifier(biomeName));
|
||||
if (biome == null)
|
||||
throw new InternalExpressionException("Unknown biome: "+biomeName);
|
||||
byte biomeId = (byte) (Registry.BIOME.getRawId(biome) & 255);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Chunk chunk = world.getChunk(pos);
|
||||
chunk.getBiomeArray()[(pos.getX() & 15) | (pos.getZ() & 15) << 4] = biome;
|
||||
chunk.setShouldSave(true);
|
||||
//world.method_14178().markForUpdate(pos);
|
||||
CarpetServer.scriptServer.markChunkForUpdate(world, pos);
|
||||
for (int i = 0; i<16; i++)
|
||||
{
|
||||
BlockPos section = new BlockPos((pos.getX()>>4 <<4)+8, 16*i, (pos.getZ()>>4 <<4)+8);
|
||||
world.method_14178().markForUpdate(section);
|
||||
world.method_14178().markForUpdate(section.east());
|
||||
world.method_14178().markForUpdate(section.west());
|
||||
world.method_14178().markForUpdate(section.north());
|
||||
}
|
||||
return LazyValue.NULL;
|
||||
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ public class CarpetScriptServer
|
||||
public boolean stopAll;
|
||||
Set<String> holyMoly;
|
||||
public CarpetEventServer events;
|
||||
private Set<Pair<ServerWorld,ChunkPos>> modifiedChunks = new HashSet<>();
|
||||
|
||||
public static List<ModuleInterface> bundledModuleData = new ArrayList<ModuleInterface>(){{
|
||||
add(new CameraPathModule());
|
||||
@@ -332,23 +331,8 @@ public class CarpetScriptServer
|
||||
return true;
|
||||
}
|
||||
|
||||
void markChunkForUpdate(ServerWorld world, BlockPos pos)
|
||||
{
|
||||
modifiedChunks.add(Pair.of(world, new ChunkPos(pos)));
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
for (Pair<ServerWorld,ChunkPos> tuple : modifiedChunks)
|
||||
{
|
||||
//ChunkDataS2CPacket
|
||||
ServerWorld world = tuple.getLeft();
|
||||
ChunkPos chpos = tuple.getRight();
|
||||
Chunk chunk = world.getChunk(chpos.x, chpos.z);
|
||||
//.....
|
||||
|
||||
}
|
||||
modifiedChunks.clear();
|
||||
events.tick();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user