3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-02 17:40:09 +01:00

Send chunks if they're in the paper no-tick-distance

Fixes #766 and #677
Dieser Commit ist enthalten in:
dordsor21 2020-12-11 15:36:42 +00:00
Ursprung 3717351d61
Commit 56cf49c167
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
7 geänderte Dateien mit 92 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -39,9 +39,15 @@ dependencies {
"api"(project(":worldedit-core"))
"api"(project(":worldedit-libs:bukkit"))
"compile"(":worldedit-adapters:")
// Paper-patched NMS jars
"compile"("com.destroystokyo.paperv1_15_r1:paperv1_15_r1:1_15_r1")
"compile"("com.destroystokyo.paperv1_16_r1:paperv1_16_r1:1_16_r1")
"compile"("com.destroystokyo.paperv1_16_r2:paperv1_16_r2:1_16_r2")
"compile"("com.destroystokyo.paperv1_16_r3:paperv1_16_r3:1_16_r3")
"compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1")
"compile"("org.spigotmcv1_16_r1:spigotmcv1_16_r1:1_16_r1")
"compile"("org.spigotmcv1_16_r2:spigotmcv1_16_r2:1_16_r2")
"compile"("org.spigotmcv1_16_r3:spigotmcv1_16_r3:1_16_r3")
"implementation"("it.unimi.dsi:fastutil:${Versions.FAST_UTIL}")
"api"("com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT") {
exclude("junit", "junit")

Datei anzeigen

@ -9,6 +9,7 @@ import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
import com.mojang.datafixers.util.Either;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
@ -25,6 +26,7 @@ import net.minecraft.server.v1_16_R2.DataBits;
import net.minecraft.server.v1_16_R2.DataPalette;
import net.minecraft.server.v1_16_R2.DataPaletteBlock;
import net.minecraft.server.v1_16_R2.DataPaletteLinear;
import net.minecraft.server.v1_16_R2.EntityPlayer;
import net.minecraft.server.v1_16_R2.GameProfileSerializer;
import net.minecraft.server.v1_16_R2.IBlockData;
import net.minecraft.server.v1_16_R2.PacketPlayOutLightUpdate;
@ -205,7 +207,6 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
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)
@ -214,6 +215,33 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
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;
});
}

Datei anzeigen

@ -9,6 +9,7 @@ import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
import com.mojang.datafixers.util.Either;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
@ -25,6 +26,7 @@ import net.minecraft.server.v1_16_R3.DataBits;
import net.minecraft.server.v1_16_R3.DataPalette;
import net.minecraft.server.v1_16_R3.DataPaletteBlock;
import net.minecraft.server.v1_16_R3.DataPaletteLinear;
import net.minecraft.server.v1_16_R3.EntityPlayer;
import net.minecraft.server.v1_16_R3.GameProfileSerializer;
import net.minecraft.server.v1_16_R3.IBlockData;
import net.minecraft.server.v1_16_R3.PacketPlayOutLightUpdate;
@ -205,7 +207,6 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
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)
@ -214,6 +215,33 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
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;
});
}

Datei anzeigen

@ -505,5 +505,9 @@ public class Regen_v1_15_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
@Override
public void b() {
}
@Override
public void setChunkRadius(int i) {
}
}
}

Datei anzeigen

@ -551,5 +551,9 @@ public class Regen_v1_16_R1 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
@Override
public void b() {
}
@Override
public void setChunkRadius(int i) {
}
}
}

Datei anzeigen

@ -574,5 +574,9 @@ public class Regen_v1_16_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
@Override
public void b() {
}
@Override
public void setChunkRadius(int i) {
}
}
}

Datei anzeigen

@ -575,5 +575,9 @@ public class Regen_v1_16_R3 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
@Override
public void b() {
}
@Override
public void setChunkRadius(int i) {
}
}
}