在我的mod中,我更新了特定列的生物群系。它似乎工作得很好 - 生物群系立即改变。冰原变成地狱,雪傀儡死亡,猪人产卵。但是,F3调试屏幕不会更新,草的颜色也不会改变。
关闭并重新打开Minecraft应用程序会正确刷新F3调试屏幕和草色,但我觉得应该有办法让它立即生效。
FWIW - 这是进行更改的方法。
private static void setBiome (WorldServer world, BlockPos center, int radius, byte biomeID) {
// First create a list of chunks that include the full radius
int minX = center.getX() - radius;
int maxX = center.getX() + radius;
int minZ = center.getZ() - radius;
int maxZ = center.getZ() + radius;
for (int x=(int)Math.floor(minX/16D); x<=(int)Math.floor(maxX/16D); x++) {
for (int z=(int)Math.floor(minZ/16D); z<=(int)Math.floor(maxZ/16D); z++) {
byte[] biomeArray = world.getChunkFromChunkCoords(x,z).getBiomeArray();
//Second crawl through the array comparing each one to the inside of the radius
for (int i = 0; i < biomeArray.length; i++) {
int arrX = Math.floorMod(i,16)+16*x;
int arrZ = (int)Math.floor(i/16)+16*z;
if (minX <= arrX && arrX <=maxX && minZ <= arrZ && arrZ <= maxZ) {
//Do the biome change
world.getChunkFromChunkCoords(x,z).getBiomeArray()[i] = biomeID;
}
}
}
}
}
在Draco18s的建议中,我通过做world.notifyBlockUpdate来尝试同步,但它似乎没有用。我还尝试了world.notify(),导致了IllegalMonitorStateException。
运行forgeSrc 2655 for 1.12.2