Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 20:10:06 +01:00
add chunk tickets and don't force sync sending chunk packets
Dieser Commit ist enthalten in:
Ursprung
39b0da2b99
Commit
580cb4a91e
@ -9,6 +9,7 @@ import com.boydti.fawe.object.collection.BitArray;
|
|||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
@ -154,25 +155,33 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
|
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
|
return nmsChunkMain;
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
final CraftChunk chunk = (CraftChunk) future.get();
|
||||||
|
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
return TaskManager.IMP.sync(() -> {
|
||||||
|
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
|
return chunk;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
||||||
@ -190,37 +199,32 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playerChunk.hasBeenLoaded()) {
|
if (playerChunk.hasBeenLoaded()) {
|
||||||
TaskManager.IMP.sync(() -> {
|
try {
|
||||||
try {
|
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
||||||
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
if (dirtyBits == 0) {
|
||||||
if (dirtyBits == 0) {
|
nmsWorld.getChunkProvider().playerChunkMap.a(playerChunk);
|
||||||
nmsWorld.getChunkProvider().playerChunkMap.a(playerChunk);
|
|
||||||
}
|
|
||||||
if (mask == 0) {
|
|
||||||
dirtyBits = 65535;
|
|
||||||
} else {
|
|
||||||
dirtyBits |= mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldDirtyBits.set(playerChunk, dirtyBits);
|
|
||||||
fieldDirtyCount.set(playerChunk, 64);
|
|
||||||
|
|
||||||
if (lighting) {
|
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine());
|
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
|
||||||
p.playerConnection.sendPacket(packet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
if (mask == 0) {
|
||||||
});
|
dirtyBits = 65535;
|
||||||
return;
|
} else {
|
||||||
|
dirtyBits |= mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldDirtyBits.set(playerChunk, dirtyBits);
|
||||||
|
fieldDirtyCount.set(playerChunk, 64);
|
||||||
|
|
||||||
|
if (lighting) {
|
||||||
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine());
|
||||||
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
|
p.playerConnection.sendPacket(packet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -607,6 +607,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) {
|
if (finalizer != null) {
|
||||||
finalizer.run();
|
finalizer.run();
|
||||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
|||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
@ -151,25 +152,33 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
|
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
|
return nmsChunkMain;
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
final CraftChunk chunk = (CraftChunk) future.get();
|
||||||
|
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
return TaskManager.IMP.sync(() -> {
|
||||||
|
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
|
return chunk;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
||||||
@ -187,35 +196,32 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playerChunk.hasBeenLoaded()) {
|
if (playerChunk.hasBeenLoaded()) {
|
||||||
TaskManager.IMP.sync(() -> {
|
try {
|
||||||
try {
|
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
||||||
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
if (dirtyBits == 0) {
|
||||||
if (dirtyBits == 0) {
|
nmsWorld.getChunkProvider().playerChunkMap.a(playerChunk);
|
||||||
nmsWorld.getChunkProvider().playerChunkMap.a(playerChunk);
|
|
||||||
}
|
|
||||||
if (mask == 0) {
|
|
||||||
dirtyBits = 65535;
|
|
||||||
} else {
|
|
||||||
dirtyBits |= mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldDirtyBits.set(playerChunk, dirtyBits);
|
|
||||||
fieldDirtyCount.set(playerChunk, 64);
|
|
||||||
|
|
||||||
if (lighting) {
|
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
|
||||||
boolean trustEdges = false; //Added in 1.16.1 Not sure what it does.
|
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
|
||||||
p.playerConnection.sendPacket(packet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
if (mask == 0) {
|
||||||
});
|
dirtyBits = 65535;
|
||||||
|
} else {
|
||||||
|
dirtyBits |= mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldDirtyBits.set(playerChunk, dirtyBits);
|
||||||
|
fieldDirtyCount.set(playerChunk, 64);
|
||||||
|
|
||||||
|
if (lighting) {
|
||||||
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
|
boolean trustEdges = false; //Added in 1.16.1 Not sure what it does.
|
||||||
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
|
p.playerConnection.sendPacket(packet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,6 +609,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) {
|
if (finalizer != null) {
|
||||||
finalizer.run();
|
finalizer.run();
|
||||||
|
@ -11,6 +11,7 @@ import com.boydti.fawe.util.ReflectionUtils;
|
|||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
@ -163,25 +164,33 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
|
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
|
return nmsChunkMain;
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
final CraftChunk chunk = (CraftChunk) future.get();
|
||||||
|
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
return TaskManager.IMP.sync(() -> {
|
||||||
|
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
|
return chunk;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {
|
||||||
@ -199,51 +208,49 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playerChunk.hasBeenLoaded()) {
|
if (playerChunk.hasBeenLoaded()) {
|
||||||
TaskManager.IMP.sync(() -> {
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
||||||
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
if (optional.isPresent()) {
|
||||||
if (optional.isPresent()) {
|
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
||||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
|
p.playerConnection.sendPacket(chunkpacket);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lighting) {
|
||||||
|
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
|
boolean trustEdges = true;
|
||||||
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
p.playerConnection.sendPacket(packet);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else if (PaperLib.isPaper()) {
|
||||||
|
//Require generic here to work with multiple dependencies trying to take control.
|
||||||
|
PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<?> objects =
|
||||||
|
nmsWorld.getChunkProvider().playerChunkMap.playerViewDistanceNoTickMap.getObjectsInRange(chunkX, chunkZ);
|
||||||
|
if (objects == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Object obj : objects.getBackingSet()) {
|
||||||
|
if (obj == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EntityPlayer p = (EntityPlayer) obj;
|
||||||
|
Chunk chunk = nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
||||||
|
if (chunk != null) {
|
||||||
|
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(chunk, 65535);
|
||||||
|
p.playerConnection.sendPacket(chunkpacket);
|
||||||
|
|
||||||
if (lighting) {
|
if (lighting) {
|
||||||
boolean trustEdges = true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
boolean trustEdges = true;
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
PacketPlayOutLightUpdate packet =
|
||||||
|
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
p.playerConnection.sendPacket(packet);
|
p.playerConnection.sendPacket(packet);
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (PaperLib.isPaper()) {
|
|
||||||
//Require generic here to work with multiple dependencies trying to take control.
|
|
||||||
PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<?> objects =
|
|
||||||
nmsWorld.getChunkProvider().playerChunkMap.playerViewDistanceNoTickMap.getObjectsInRange(chunkX, chunkZ);
|
|
||||||
if (objects == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (Object obj : objects.getBackingSet()) {
|
|
||||||
if (obj == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
EntityPlayer p = (EntityPlayer) obj;
|
|
||||||
Chunk chunk = nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
|
||||||
if (chunk != null) {
|
|
||||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(chunk, 65535);
|
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
|
||||||
|
|
||||||
if (lighting) {
|
|
||||||
boolean trustEdges =
|
|
||||||
true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
|
||||||
PacketPlayOutLightUpdate packet =
|
|
||||||
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
|
||||||
p.playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) {
|
if (finalizer != null) {
|
||||||
finalizer.run();
|
finalizer.run();
|
||||||
|
@ -5,12 +5,14 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.bukkit.adapter.DelegateLock;
|
import com.boydti.fawe.bukkit.adapter.DelegateLock;
|
||||||
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
|
import com.boydti.fawe.bukkit.adapter.NMSAdapter;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
@ -163,25 +165,33 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
|
TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
|
return nmsChunkMain;
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
final CraftChunk chunk = (CraftChunk) future.get();
|
||||||
|
TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance()));
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
return TaskManager.IMP.sync(() -> {
|
||||||
|
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
|
chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
|
return chunk;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {
|
||||||
@ -199,51 +209,52 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (playerChunk.hasBeenLoaded()) {
|
if (playerChunk.hasBeenLoaded()) {
|
||||||
TaskManager.IMP.sync(() -> {
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
||||||
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
if (optional.isPresent()) {
|
||||||
if (optional.isPresent()) {
|
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
||||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
|
p.playerConnection.sendPacket(chunkpacket);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lighting) {
|
||||||
|
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
|
boolean trustEdges = true;
|
||||||
|
PacketPlayOutLightUpdate packet =
|
||||||
|
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(),
|
||||||
|
trustEdges);
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
p.playerConnection.sendPacket(packet);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else if (PaperLib.isPaper()) {
|
||||||
|
//Require generic here to work with multiple dependencies trying to take control.
|
||||||
|
PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<?> objects =
|
||||||
|
nmsWorld.getChunkProvider().playerChunkMap.playerViewDistanceNoTickMap
|
||||||
|
.getObjectsInRange(chunkX, chunkZ);
|
||||||
|
if (objects == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Object obj : objects.getBackingSet()) {
|
||||||
|
if (obj == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EntityPlayer p = (EntityPlayer) obj;
|
||||||
|
Chunk chunk = nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
||||||
|
if (chunk != null) {
|
||||||
|
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(chunk, 65535);
|
||||||
|
p.playerConnection.sendPacket(chunkpacket);
|
||||||
|
|
||||||
if (lighting) {
|
if (lighting) {
|
||||||
boolean trustEdges = true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
boolean trustEdges = true;
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair,
|
||||||
|
nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
p.playerConnection.sendPacket(packet);
|
p.playerConnection.sendPacket(packet);
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (PaperLib.isPaper()) {
|
|
||||||
//Require generic here to work with multiple dependencies trying to take control.
|
|
||||||
PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<?> objects =
|
|
||||||
nmsWorld.getChunkProvider().playerChunkMap.playerViewDistanceNoTickMap.getObjectsInRange(chunkX, chunkZ);
|
|
||||||
if (objects == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (Object obj : objects.getBackingSet()) {
|
|
||||||
if (obj == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
EntityPlayer p = (EntityPlayer) obj;
|
|
||||||
Chunk chunk = nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
|
||||||
if (chunk != null) {
|
|
||||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(chunk, 65535);
|
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
|
||||||
|
|
||||||
if (lighting) {
|
|
||||||
boolean trustEdges =
|
|
||||||
true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
|
||||||
PacketPlayOutLightUpdate packet =
|
|
||||||
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
|
||||||
p.playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
|
|||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance());
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) {
|
if (finalizer != null) {
|
||||||
finalizer.run();
|
finalizer.run();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren