From 2c18d2643820e9621b7bc2aedf715436fd859629 Mon Sep 17 00:00:00 2001 From: Sotr Date: Sun, 19 Aug 2018 14:12:03 +0800 Subject: [PATCH] Upstream Paper --- .../api/internal/mixin/IMixinWorldServer.java | 5 +-- .../server/mixin/bootstrap/Watchcat.java | 17 +++++--- .../mixin/core/MixinMinecraftServer.java | 23 ++++++---- .../server/mixin/core/MixinWorldManager.java | 6 +-- .../server/mixin/core/MixinWorldServer.java | 12 ++---- .../java/net/minecraft/server/Entity.java | 2 + .../net/minecraft/server/EntityPlayer.java | 5 ++- .../net/minecraft/server/EntityTracker.java | 40 ++++++++--------- .../net/minecraft/server/PlayerChunkMap.java | 43 ++++++++++--------- .../net/minecraft/server/WorldServer.java | 15 +++---- .../craftbukkit/entity/CraftPlayer.java | 8 ++-- work/Paper | 2 +- 12 files changed, 93 insertions(+), 85 deletions(-) diff --git a/sources/src/main/java/io/akarin/api/internal/mixin/IMixinWorldServer.java b/sources/src/main/java/io/akarin/api/internal/mixin/IMixinWorldServer.java index 7b9347840..7d7a11dca 100644 --- a/sources/src/main/java/io/akarin/api/internal/mixin/IMixinWorldServer.java +++ b/sources/src/main/java/io/akarin/api/internal/mixin/IMixinWorldServer.java @@ -1,10 +1,9 @@ package io.akarin.api.internal.mixin; import java.util.Random; -import java.util.concurrent.locks.ReentrantReadWriteLock; public interface IMixinWorldServer { - public Object lock(); + public Object tickLock(); public Random rand(); - public ReentrantReadWriteLock trackerLock(); + public Object trackLock(); } \ No newline at end of file diff --git a/sources/src/main/java/io/akarin/server/mixin/bootstrap/Watchcat.java b/sources/src/main/java/io/akarin/server/mixin/bootstrap/Watchcat.java index 1e901e9c2..8cb8eba3c 100644 --- a/sources/src/main/java/io/akarin/server/mixin/bootstrap/Watchcat.java +++ b/sources/src/main/java/io/akarin/server/mixin/bootstrap/Watchcat.java @@ -41,13 +41,12 @@ public abstract class Watchcat extends Thread { @Overwrite public void run() { while (!stopping) { - // - long currentTime = System.currentTimeMillis(); // Paper - do we REALLY need to call this method multiple times? - if (lastTick != 0 && currentTime > lastTick + earlyWarningEvery && !Boolean.getBoolean("disable.watchdog")) // Paper - Add property to disable and short timeout + // Paper start + long currentTime = System.currentTimeMillis(); + if ( lastTick != 0 && currentTime > lastTick + earlyWarningEvery && !Boolean.getBoolean("disable.watchdog") ) { - // Paper start boolean isLongTimeout = currentTime > lastTick + timeoutTime; - // Don't spam short dumps + // Don't spam early warning dumps if (!isLongTimeout && (earlyWarningEvery <= 0 || !hasStarted || currentTime < lastEarlyWarning + earlyWarningEvery || currentTime < lastTick + earlyWarningDelay)) continue; lastEarlyWarning = currentTime; @@ -77,7 +76,8 @@ public abstract class Watchcat extends Thread { } // Paper end } else { - log.log(Level.SEVERE, "The server has not responded for " + earlyWarningEvery / 1000 + " seconds! Creating thread dump"); + // log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---"); // Akarin + log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump"); } // Paper end - Different message for short timeout log.log(Level.SEVERE, "------------------------------"); @@ -92,8 +92,13 @@ public abstract class Watchcat extends Thread { for (ThreadInfo thread : threads) { dumpThread(thread, log); } + } else { + // log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---"); // Akarin + } log.log(Level.SEVERE, "------------------------------"); + if ( isLongTimeout ) + { if (restart) { RestartCommand.restart(); } diff --git a/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java b/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java index 37ae2e9ba..a29789cc8 100644 --- a/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java +++ b/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java @@ -1,12 +1,16 @@ package io.akarin.server.mixin.core; +import java.lang.reflect.Field; import java.util.List; import java.util.Queue; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; +import javax.activation.FileDataSource; + import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; +import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -29,6 +33,7 @@ import net.minecraft.server.MojangStatisticsGenerator; import net.minecraft.server.ReportedException; import net.minecraft.server.ServerConnection; import net.minecraft.server.SystemUtils; +import net.minecraft.server.TileEntityHopper; import net.minecraft.server.WorldServer; @Mixin(value = MinecraftServer.class, remap = false) @@ -46,17 +51,17 @@ public abstract class MixinMinecraftServer { target = "net/minecraft/server/SystemUtils.b()J", shift = At.Shift.BEFORE )) - private void prerun(CallbackInfo info) { + private void prerun(CallbackInfo info) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { primaryThread.setPriority(AkarinGlobalConfig.primaryThreadPriority < Thread.NORM_PRIORITY ? Thread.NORM_PRIORITY : (AkarinGlobalConfig.primaryThreadPriority > Thread.MAX_PRIORITY ? 10 : AkarinGlobalConfig.primaryThreadPriority)); Akari.resizeTickExecutors((cachedWorldSize = worlds.size())); - /* + Field skipHopperEvents = TileEntityHopper.class.getDeclaredField("skipHopperEvents"); // No idea why static but check each world + skipHopperEvents.setAccessible(true); for (int i = 0; i < worlds.size(); ++i) { WorldServer world = worlds.get(i); - TileEntityHopper.skipHopperEvents = world.paperConfig.disableHopperMoveEvents || InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; + skipHopperEvents.set(null, world.paperConfig.disableHopperMoveEvents || InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0); } - */ AkarinSlackScheduler.get().boot(); } @@ -161,7 +166,7 @@ public abstract class MixinMinecraftServer { int interlace = i + 1; WorldServer entityWorld = worlds.get(interlace < cachedWorldSize ? interlace : 0); Akari.STAGE_TICK.submit(() -> { - synchronized (((IMixinWorldServer) entityWorld).lock()) { + synchronized (((IMixinWorldServer) entityWorld).tickLock()) { tickEntities(entityWorld); } }, null/*new TimingSignal(entityWorld, true)*/); @@ -170,7 +175,7 @@ public abstract class MixinMinecraftServer { int fi = i; Akari.STAGE_TICK.submit(() -> { WorldServer world = worlds.get(fi); - synchronized (((IMixinWorldServer) world).lock()) { + synchronized (((IMixinWorldServer) world).tickLock()) { tickWorld(world); } }, null); @@ -181,7 +186,7 @@ public abstract class MixinMinecraftServer { Akari.STAGE_TICK.submit(() -> { for (int i = 0; i < cachedWorldSize; i++) { WorldServer world = worlds.get(i); - synchronized (((IMixinWorldServer) world).lock()) { + synchronized (((IMixinWorldServer) world).tickLock()) { tickWorld(world); } } @@ -203,7 +208,7 @@ public abstract class MixinMinecraftServer { Akari.STAGE_TICK.submit(() -> { for (int i = 1; i <= cachedWorldSize; ++i) { WorldServer world = worlds.get(i < cachedWorldSize ? i : 0); - synchronized (((IMixinWorldServer) world).lock()) { + synchronized (((IMixinWorldServer) world).tickLock()) { tickEntities(world); } } @@ -212,7 +217,7 @@ public abstract class MixinMinecraftServer { Akari.STAGE_TICK.submit(() -> { for (int i = 0; i < cachedWorldSize; ++i) { WorldServer world = worlds.get(i); - synchronized (((IMixinWorldServer) world).lock()) { + synchronized (((IMixinWorldServer) world).tickLock()) { tickWorld(world); } } diff --git a/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldManager.java b/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldManager.java index 5ca57f7ea..8438da108 100644 --- a/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldManager.java +++ b/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldManager.java @@ -17,9 +17,9 @@ public abstract class MixinWorldManager { @Overwrite public void a(Entity entity) { - ((IMixinWorldServer) this.world).trackerLock().writeLock().lock(); // Akarin - this.world.getTracker().track(entity); - ((IMixinWorldServer) this.world).trackerLock().writeLock().unlock(); // Akarin + synchronized (((IMixinWorldServer) this.world).trackLock()) { // Akarin + this.world.getTracker().track(entity); + } if (entity instanceof EntityPlayer) { this.world.worldProvider.a((EntityPlayer) entity); diff --git a/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldServer.java b/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldServer.java index 6ff8e9985..b0b6438c2 100644 --- a/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldServer.java +++ b/sources/src/main/java/io/akarin/server/mixin/core/MixinWorldServer.java @@ -1,13 +1,9 @@ package io.akarin.server.mixin.core; import java.util.Random; -import java.util.concurrent.locks.ReentrantReadWriteLock; - import org.apache.logging.log4j.LogManager; import org.spongepowered.asm.mixin.Mixin; -import com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock; - import io.akarin.api.internal.mixin.IMixinWorldServer; import net.minecraft.server.WorldServer; @@ -16,7 +12,7 @@ public abstract class MixinWorldServer implements IMixinWorldServer { private final Object tickLock = new Object(); @Override - public Object lock() { + public Object tickLock() { return tickLock; } @@ -39,10 +35,10 @@ public abstract class MixinWorldServer implements IMixinWorldServer { return sharedRandom; } - public final ReentrantReadWriteLock trackerLock = new ReentrantReadWriteLock(); + public final Object trackLock = new Object(); @Override - public ReentrantReadWriteLock trackerLock() { - return trackerLock; + public Object trackLock() { + return trackLock; } } diff --git a/sources/src/main/java/net/minecraft/server/Entity.java b/sources/src/main/java/net/minecraft/server/Entity.java index c576afa88..480a28664 100644 --- a/sources/src/main/java/net/minecraft/server/Entity.java +++ b/sources/src/main/java/net/minecraft/server/Entity.java @@ -128,6 +128,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke private boolean az; public boolean dead; public boolean shouldBeRemoved; // Paper + public boolean hasBeenCounted = false; // Paper public float width; public float length; public float J; @@ -1372,6 +1373,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke this.lastYaw -= 360.0F; } + world.getChunkAt((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); // Paper - ensure chunk is always loaded this.setPosition(this.locX, this.locY, this.locZ); this.setYawPitch(f, f1); } diff --git a/sources/src/main/java/net/minecraft/server/EntityPlayer.java b/sources/src/main/java/net/minecraft/server/EntityPlayer.java index d2eccf099..f09710bc7 100644 --- a/sources/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/sources/src/main/java/net/minecraft/server/EntityPlayer.java @@ -763,9 +763,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (entity instanceof EntityPlayer) { WorldServer worldServer = (WorldServer) entity.getWorld(); worldServer.tracker.untrackEntity(this); - ((IMixinWorldServer) worldServer).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) worldServer).trackLock()) { // Akarin + worldServer.tracker.track(this); + } worldServer.tracker.track(this); - ((IMixinWorldServer) worldServer).trackerLock().writeLock().unlock(); // Akarin } // Paper end diff --git a/sources/src/main/java/net/minecraft/server/EntityTracker.java b/sources/src/main/java/net/minecraft/server/EntityTracker.java index 8e9db846f..363267f60 100644 --- a/sources/src/main/java/net/minecraft/server/EntityTracker.java +++ b/sources/src/main/java/net/minecraft/server/EntityTracker.java @@ -2,8 +2,6 @@ package net.minecraft.server; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock; - import io.akarin.api.internal.mixin.IMixinWorldServer; import java.util.ArrayList; @@ -161,7 +159,7 @@ public class EntityTracker { public void untrackEntity(Entity entity) { org.spigotmc.AsyncCatcher.catchOp( "entity untrack"); // Spigot - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin if (entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; Iterator iterator = this.c.iterator(); @@ -180,14 +178,14 @@ public class EntityTracker { entitytrackerentry1.a(); } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } public void updatePlayers() { ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.c.iterator(); world.timings.tracker1.startTiming(); // Spigot - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin while (iterator.hasNext()) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); @@ -215,14 +213,14 @@ public class EntityTracker { } } } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin world.timings.tracker2.stopTiming(); // Spigot } public void a(EntityPlayer entityplayer) { Iterator iterator = this.c.iterator(); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin while (iterator.hasNext()) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); @@ -234,13 +232,14 @@ public class EntityTracker { } } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } public void a(Entity entity, Packet packet) { - ((IMixinWorldServer) world).trackerLock().readLock().lock(); // Akarin - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); - ((IMixinWorldServer) world).trackerLock().readLock().unlock(); // Akarin + EntityTrackerEntry entitytrackerentry; // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin + entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); + } // Akarin if (entitytrackerentry != null) { entitytrackerentry.broadcast(packet); @@ -249,9 +248,10 @@ public class EntityTracker { } public void sendPacketToEntity(Entity entity, Packet packet) { - ((IMixinWorldServer) world).trackerLock().readLock().lock(); // Akarin - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); - ((IMixinWorldServer) world).trackerLock().readLock().unlock(); // Akarin + EntityTrackerEntry entitytrackerentry; // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin + entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); + } // Akarin if (entitytrackerentry != null) { entitytrackerentry.broadcastIncludingSelf(packet); @@ -261,7 +261,7 @@ public class EntityTracker { public void untrackPlayer(EntityPlayer entityplayer) { Iterator iterator = this.c.iterator(); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin while (iterator.hasNext()) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); @@ -269,14 +269,14 @@ public class EntityTracker { entitytrackerentry.clear(entityplayer); } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } public void a(EntityPlayer entityplayer, Chunk chunk) { ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist1 = Lists.newArrayList(); Iterator iterator = this.c.iterator(); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin while (iterator.hasNext()) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); @@ -293,7 +293,7 @@ public class EntityTracker { } } } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin Entity entity1; @@ -320,7 +320,7 @@ public class EntityTracker { public void a(int i) { this.e = (i - 1) * 16; Iterator iterator = this.c.iterator(); - ((IMixinWorldServer) world).trackerLock().readLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin while (iterator.hasNext()) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); @@ -328,6 +328,6 @@ public class EntityTracker { entitytrackerentry.a(this.e); } - ((IMixinWorldServer) world).trackerLock().readLock().unlock(); // Akarin + } // Akarin } } \ No newline at end of file diff --git a/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java b/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java index 31fffbde1..5c08a2a0d 100644 --- a/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -97,7 +97,7 @@ public class PlayerChunkMap { long i = this.world.getTime(); int j; PlayerChunk playerchunk; - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin if (i - this.k > 8000L) { try (Timing ignored = world.timings.doChunkMapUpdate.startTiming()) { // Paper @@ -214,23 +214,23 @@ public class PlayerChunkMap { } } // Paper timing } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } public boolean a(int i, int j) { long k = d(i, j); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); try { // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin return this.e.get(k) != null; - } finally { ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); } // Akarin + } // Akarin } @Nullable public PlayerChunk getChunk(int i, int j) { - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); try { // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin return (PlayerChunk) this.e.get(d(i, j)); - } finally { ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); } // Akarin + } // Akarin } private PlayerChunk c(int i, int j) { @@ -295,14 +295,14 @@ public class PlayerChunkMap { } Collections.sort(chunkList, new ChunkCoordComparator(entityplayer)); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin for (ChunkCoordIntPair pair : chunkList) { this.c(pair.x, pair.z).a(entityplayer); } // CraftBukkit end this.managedPlayers.add(entityplayer); - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin this.e(); } @@ -323,9 +323,9 @@ public class PlayerChunkMap { } } - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin this.managedPlayers.remove(entityplayer); - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin this.e(); } @@ -378,11 +378,11 @@ public class PlayerChunkMap { // CraftBukkit start - send nearest chunks first Collections.sort(chunksToLoad, new ChunkCoordComparator(entityplayer)); - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin for (ChunkCoordIntPair pair : chunksToLoad) { this.c(pair.x, pair.z).a(entityplayer); } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin // CraftBukkit end } } @@ -400,9 +400,10 @@ public class PlayerChunkMap { i = MathHelper.clamp(i, 3, 32); if (i != this.j) { int j = i - this.j; - ((IMixinWorldServer) world).trackerLock().readLock().lock(); // Akarin - ArrayList arraylist = Lists.newArrayList(this.managedPlayers); - ((IMixinWorldServer) world).trackerLock().readLock().unlock(); // Akarin + ArrayList arraylist; // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin + arraylist = Lists.newArrayList(this.managedPlayers); + } // Akarin Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { @@ -431,7 +432,7 @@ public class PlayerChunkMap { int i1; int j1; - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin if (j > 0) { for (i1 = k - i; i1 <= k + i; ++i1) { for (j1 = l - i; j1 <= l + i; ++j1) { @@ -454,7 +455,7 @@ public class PlayerChunkMap { this.e(); } } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } } // Paper end @@ -474,13 +475,13 @@ public class PlayerChunkMap { public void a(PlayerChunk playerchunk) { org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Add"); // Paper - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin this.f.add(playerchunk); - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } public void b(PlayerChunk playerchunk) { - ((IMixinWorldServer) world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) world).trackLock()) { // Akarin org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Remove"); // Paper ChunkCoordIntPair chunkcoordintpair = playerchunk.a(); long i = d(chunkcoordintpair.x, chunkcoordintpair.z); @@ -502,7 +503,7 @@ public class PlayerChunkMap { } // Paper end } - ((IMixinWorldServer) world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } diff --git a/sources/src/main/java/net/minecraft/server/WorldServer.java b/sources/src/main/java/net/minecraft/server/WorldServer.java index f35e99b2b..ded33901b 100644 --- a/sources/src/main/java/net/minecraft/server/WorldServer.java +++ b/sources/src/main/java/net/minecraft/server/WorldServer.java @@ -1090,7 +1090,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { } // CraftBukkit end if (super.strikeLightning(entity)) { - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension, // Paper - use world instead of dimension return true; } else { return false; @@ -1150,8 +1150,8 @@ public class WorldServer extends World implements IAsyncTaskHandler { BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst(); if (this.a(blockactiondata)) { - // CraftBukkit - this.worldProvider.dimension -> this.dimension - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d())); + // CraftBukkit - this.worldProvider.dimension -> this.dimension, // Paper - dimension -> world + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d())); } } @@ -1243,15 +1243,14 @@ public class WorldServer extends World implements IAsyncTaskHandler { return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6); } // Paper start - Particle API Expansion - // TODO: rework this, "flag" should probably be exposed as it was before public int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { - return sendParticles(this.players, sender, t0, d0, d1, d2, i, d3, d5, d5, d6); + return sendParticles(this.players, sender, t0, false, d0, d1, d2, i, d3, d5, d5, d6); } - public int sendParticles(List receivers, EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { - // Paper end + public int sendParticles(List receivers, EntityPlayer sender, T t0, boolean force, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { // CraftBukkit end - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i); + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i); + // Paper end int j = 0; for (EntityHuman entityhuman : receivers) { // Paper - Particle API Expansion diff --git a/sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index e4ac929e6..748bed397 100644 --- a/sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1199,12 +1199,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { EntityTracker tracker = ((WorldServer) entity.world).tracker; // Paper end - ((IMixinWorldServer) entity.world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) entity.world).trackLock()) { // Akarin EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId()); if (entry != null) { entry.clear(getHandle()); } - ((IMixinWorldServer) entity.world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin // Remove the hidden player from this player user list, if they're on it if (other.sentListPacket) { @@ -1251,12 +1251,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); - ((IMixinWorldServer) entity.world).trackerLock().writeLock().lock(); // Akarin + synchronized (((IMixinWorldServer) entity.world).trackLock()) { // Akarin EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId()); if (entry != null && !entry.trackedPlayers.contains(getHandle())) { entry.updatePlayer(getHandle()); } - ((IMixinWorldServer) entity.world).trackerLock().writeLock().unlock(); // Akarin + } // Akarin } // Paper start private void reregisterPlayer(EntityPlayer player) { diff --git a/work/Paper b/work/Paper index 0194a6179..83ba855ba 160000 --- a/work/Paper +++ b/work/Paper @@ -1 +1 @@ -Subproject commit 0194a6179847fa12de2f4e117dd795a886974078 +Subproject commit 83ba855ba6c1e3838c7eea8aa56f54490578c1c6