mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Send chunks if they're in the paper no-tick-distance
Fixes #766 and #677
This commit is contained in:
parent
3717351d61
commit
56cf49c167
@ -39,9 +39,15 @@ dependencies {
|
|||||||
"api"(project(":worldedit-core"))
|
"api"(project(":worldedit-core"))
|
||||||
"api"(project(":worldedit-libs:bukkit"))
|
"api"(project(":worldedit-libs:bukkit"))
|
||||||
"compile"(":worldedit-adapters:")
|
"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_15_r1:spigotmcv1_15_r1:1_15_r1")
|
||||||
"compile"("org.spigotmcv1_16_r1:spigotmcv1_16_r1:1_16_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_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}")
|
"implementation"("it.unimi.dsi:fastutil:${Versions.FAST_UTIL}")
|
||||||
"api"("com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT") {
|
"api"("com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT") {
|
||||||
exclude("junit", "junit")
|
exclude("junit", "junit")
|
||||||
|
@ -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.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
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;
|
||||||
@ -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.DataPalette;
|
||||||
import net.minecraft.server.v1_16_R2.DataPaletteBlock;
|
import net.minecraft.server.v1_16_R2.DataPaletteBlock;
|
||||||
import net.minecraft.server.v1_16_R2.DataPaletteLinear;
|
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.GameProfileSerializer;
|
||||||
import net.minecraft.server.v1_16_R2.IBlockData;
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
import net.minecraft.server.v1_16_R2.PacketPlayOutLightUpdate;
|
import net.minecraft.server.v1_16_R2.PacketPlayOutLightUpdate;
|
||||||
@ -205,14 +207,40 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
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)
|
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);
|
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(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;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -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.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
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;
|
||||||
@ -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.DataPalette;
|
||||||
import net.minecraft.server.v1_16_R3.DataPaletteBlock;
|
import net.minecraft.server.v1_16_R3.DataPaletteBlock;
|
||||||
import net.minecraft.server.v1_16_R3.DataPaletteLinear;
|
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.GameProfileSerializer;
|
||||||
import net.minecraft.server.v1_16_R3.IBlockData;
|
import net.minecraft.server.v1_16_R3.IBlockData;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutLightUpdate;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutLightUpdate;
|
||||||
@ -205,14 +207,40 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
|
|||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
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)
|
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);
|
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(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;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -505,5 +505,9 @@ public class Regen_v1_15_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void b() {
|
public void b() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChunkRadius(int i) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,5 +551,9 @@ public class Regen_v1_16_R1 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void b() {
|
public void b() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChunkRadius(int i) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,5 +574,9 @@ public class Regen_v1_16_R2 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void b() {
|
public void b() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChunkRadius(int i) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,5 +575,9 @@ public class Regen_v1_16_R3 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
|||||||
@Override
|
@Override
|
||||||
public void b() {
|
public void b() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChunkRadius(int i) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user