diff --git a/Spigot-Server-Patches/Add-World-Util-Methods.patch b/Spigot-Server-Patches/Add-World-Util-Methods.patch index 07da72cee2..ba9754ddf2 100644 --- a/Spigot-Server-Patches/Add-World-Util-Methods.patch +++ b/Spigot-Server-Patches/Add-World-Util-Methods.patch @@ -6,22 +6,22 @@ Subject: [PATCH] Add World Util Methods Methods that can be used for other patches to help improve logic. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 67cd4af4f5..3f9de7e55a 100644 +index c4103680d4..9433d04f43 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - } + return this.world.getChunkProvider().getLightEngine(); } + public final int getLightSubtracted(BlockPosition blockposition, int i) { return this.a(blockposition, i); } // Paper - OBFHELPER public int a(BlockPosition blockposition, int i) { - return this.a(blockposition, i, this.world.o().g()); + return this.a(blockposition, i, this.world.getWorldProvider().g()); } diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java -index 646c5a91b8..554825ec1f 100644 +index bac6c9d65b..0930552b1f 100644 --- a/src/main/java/net/minecraft/server/IWorldReader.java +++ b/src/main/java/net/minecraft/server/IWorldReader.java -@@ -0,0 +0,0 @@ public interface IWorldReader extends IBlockAccess { +@@ -0,0 +0,0 @@ public interface IWorldReader extends IIBlockAccess { } int getLightLevel(BlockPosition blockposition, int i); @@ -42,23 +42,23 @@ index 646c5a91b8..554825ec1f 100644 + } + // Paper end - boolean isChunkLoaded(int i, int j, boolean flag); - + @Nullable + IChunkAccess getChunkAt(int i, int j, ChunkStatus chunkstatus, boolean flag); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 6e7c0c9da4..fd45090685 100644 +index 55e8c7c7d4..e8831e2a40 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - public final List k = Lists.newArrayList(); - protected final IntHashMap entitiesById = new IntHashMap<>(); - private final long F = 16777215L; -- private int G; -+ private int G; public int getSkylightSubtracted() { return this.G; } public void setSkylightSubtracted(int value) { this.G = value;} // Paper - OBFHELPER - protected int m = (new Random()).nextInt(); - protected final int n = 1013904223; - protected float o; -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - return this.getType(blockposition).isAir(); +@@ -0,0 +0,0 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + protected final java.util.Set tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper + private final long b = 16777215L; + private final Thread c; +- private int d; ++ private int d; public int getSkylightSubtracted() { return this.d; } public void setSkylightSubtracted(int value) { this.d = value;} // Paper - OBFHELPER + protected int j = (new Random()).nextInt(); + protected final int k = 1013904223; + protected float l; +@@ -0,0 +0,0 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + return i < 0 || i >= 256; } + // Paper start diff --git a/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch b/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch index b0e072166b..50691020db 100644 --- a/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch +++ b/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add configurable portal search radius diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 05d2d50e54..3137128780 100644 +index be91b11242..320fd07c62 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -19,38 +19,21 @@ index 05d2d50e54..3137128780 100644 + } } diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java -index b911d830a0..aca4071420 100644 +index 1685e694ba..e7ca777c16 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java -@@ -0,0 +0,0 @@ import org.bukkit.util.Vector; - public class PortalTravelAgent { - - private static final BlockPortal a = (BlockPortal) Blocks.NETHER_PORTAL; -- private final WorldServer world; -+ public final WorldServer world; // Paper - private -> public - private final Random c; - private final Long2ObjectMap d = new Long2ObjectOpenHashMap(4096); - @@ -0,0 +0,0 @@ public class PortalTravelAgent { + } else { + double d2 = Double.MAX_VALUE; - public boolean b(Entity entity, float f) { - // CraftBukkit start - Modularize portal search process and entity teleportation -- BlockPosition found = this.findPortal(entity.locX, entity.locY, entity.locZ, 128); -+ BlockPosition found = this.findPortal(entity.locX, entity.locY, entity.locZ, world.paperConfig.portalSearchRadius); // Paper - Configurable search radius - if (found == null) { - return false; - } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java -index d4639c8221..e1eb3aa0f3 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java -@@ -0,0 +0,0 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent { - - public static TravelAgent DEFAULT = null; - -- private int searchRadius = 128; -+ private int searchRadius = world.paperConfig.portalSearchRadius; // Paper - Configurable search radius - private int creationRadius = 16; - private boolean canCreatePortal = true; +- for (int i = -128; i <= 128; ++i) { ++ int portalSearchRadius = world.paperConfig.portalSearchRadius; // Paper ++ for (int i = portalSearchRadius; i <= portalSearchRadius; ++i) { // Paper + BlockPosition blockposition2; +- for (int j = -128; j <= 128; ++j) { ++ for (int j = -world.paperConfig.portalSearchRadius; j <= world.paperConfig.portalSearchRadius; ++j) { // Paper + for (BlockPosition blockposition3 = blockposition.b(i, this.world.getHeight() - 1 - blockposition.getY(), j); blockposition3.getY() >= 0; blockposition3 = blockposition2) { + blockposition2 = blockposition3.down(); + if (this.world.getType(blockposition3).getBlock() == PortalTravelAgent.b) { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index 0d4bd196c1..fabef1b114 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -49,7 +49,7 @@ index 0000000000..f699ce18ca + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index cb56d067b9..67cd4af4f5 100644 +index 1cf5e388e4..c4103680d4 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ @@ -57,30 +57,22 @@ index cb56d067b9..67cd4af4f5 100644 +import com.destroystokyo.paper.exception.ServerInternalException; import com.google.common.collect.Maps; - import com.google.common.collect.Queues; import com.google.common.collect.Sets; -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - return this.getBlockData(i, j, k).b(this.world, new BlockPosition(i, j, k)); - } - -+ public IBlockData getBlockData(BlockPosition blockposition) { return getType(blockposition); } // Paper - public IBlockData getType(BlockPosition blockposition) { - return this.getBlockData(blockposition.getX(), blockposition.getY(), blockposition.getZ()); - } + import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { this.tileEntities.remove(blockposition); // Paper end } else { - System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ() - + " (" + getType(blockposition) + ") where there was no entity tile!"); -- System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); +- System.out.println("Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); - new Exception().printStackTrace(); + // Paper start + ServerInternalException e = new ServerInternalException( + "Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + + tileentity.position.getY() + "," + tileentity.position.getZ() -+ + " (" + getBlockData(blockposition) + ") where there was no entity tile!\n" + -+ "Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); ++ + " (" + getType(blockposition) + ") where there was no entity tile!\n" + ++ "Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); + e.printStackTrace(); + ServerInternalException.reportInternalException(e); + // Paper end @@ -88,38 +80,21 @@ index cb56d067b9..67cd4af4f5 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index c2ecc034e8..1ed7c7e2c9 100644 +index 4f0fbe4a0d..2dd1c28fab 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -0,0 +0,0 @@ import java.util.concurrent.CompletableFuture; +@@ -0,0 +0,0 @@ import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; - import java.util.function.Consumer; + import java.util.function.Supplier; import javax.annotation.Nullable; +import com.destroystokyo.paper.exception.ServerInternalException; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; ++import org.apache.logging.log4j.LogManager; ++import org.apache.logging.log4j.Logger; -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - ichunkaccess.setLastSaved(this.world.getTime()); - this.chunkLoader.saveChunk(this.world, ichunkaccess, unloaded); // Spigot - } catch (IOException ioexception) { -- ChunkProviderServer.a.error("Couldn't save chunk", ioexception); -+ // Paper start -+ String msg = "Couldn\'t save chunk"; -+ ChunkProviderServer.a.error(msg, ioexception); -+ ServerInternalException.reportInternalException(ioexception); - } catch (ExceptionWorldConflict exceptionworldconflict) { -- ChunkProviderServer.a.error("Couldn't save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); -+ ChunkProviderServer.a.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); -+ String msg = "Couldn\'t save chunk; already in use by another instance of Minecraft?"; -+ ChunkProviderServer.a.error(msg, exceptionworldconflict); -+ ServerInternalException.reportInternalException(exceptionworldconflict); -+ // Paper end - } + public class ChunkProviderServer extends IChunkProvider { - } diff --git a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java -index 09ef8729d9..bf67dbf54a 100644 +index 1dd793d2fb..61ea2818b1 100644 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -0,0 +0,0 @@ @@ -145,8 +120,28 @@ index 09ef8729d9..bf67dbf54a 100644 } } // CraftBukkit end +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index 528d0f0cd2..be903252be 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java ++++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + this.world.checkSession(); + } catch (ExceptionWorldConflict exceptionworldconflict) { + PlayerChunkMap.LOGGER.error("Couldn't save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exceptionworldconflict); // Paper + return; + } + +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + this.write(chunkcoordintpair, nbttagcompound); + } catch (Exception exception) { + PlayerChunkMap.LOGGER.error("Failed to save chunk {},{}", chunkcoordintpair.x, chunkcoordintpair.z, exception); ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper + } + + } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index ab151a14d0..0f1c74dd33 100644 +index d4a9af975d..88b5aa3a51 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ @@ -156,43 +151,24 @@ index ab151a14d0..0f1c74dd33 100644 import com.google.common.collect.Lists; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; -@@ -0,0 +0,0 @@ public class RegionFile { - } - } catch (IOException ioexception) { - ioexception.printStackTrace(); -+ ServerInternalException.reportInternalException(ioexception); // Paper - } - - } -@@ -0,0 +0,0 @@ public class RegionFile { - this.b(i, j, (int) (SystemUtils.getTimeMillis() / 1000L)); - } catch (IOException ioexception) { - ioexception.printStackTrace(); -+ ServerInternalException.reportInternalException(ioexception); // Paper - } - - } -diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index c5ca896919..e507a996f1 100644 ---- a/src/main/java/net/minecraft/server/RegionFileCache.java -+++ b/src/main/java/net/minecraft/server/RegionFileCache.java -@@ -0,0 +0,0 @@ - package net.minecraft.server; - -+import com.destroystokyo.paper.exception.ServerInternalException; - import com.google.common.collect.Maps; - import java.io.DataInputStream; - import java.io.DataOutputStream; -@@ -0,0 +0,0 @@ public class RegionFileCache { +@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { } - } catch (IOException ioexception) { - ioexception.printStackTrace(); -+ ServerInternalException.reportInternalException(ioexception); // Paper } + } catch (IOException ioexception) { ++ ServerInternalException.reportInternalException(ioexception); // Paper + return null; + } + } +@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { + this.b(chunkcoordintpair, (int) (SystemUtils.getTimeMillis() / 1000L)); + } catch (IOException ioexception) { + ioexception.printStackTrace(); ++ ServerInternalException.reportInternalException(ioexception); // Paper } + } diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index 6720a9648e..2aa0db5c22 100644 +index 9d4febfbb6..7e58e4714a 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; @@ -200,27 +176,27 @@ index 6720a9648e..2aa0db5c22 100644 // CraftBukkit start +import com.destroystokyo.paper.exception.ServerInternalException; - import org.bukkit.craftbukkit.util.LongHash; - import org.bukkit.craftbukkit.util.LongHashSet; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -@@ -0,0 +0,0 @@ public final class SpawnerCreature { - entityinsentient = (EntityInsentient) biomebase_biomemeta.b.a((World) worldserver); - } catch (Exception exception) { - SpawnerCreature.a.warn("Failed to create mob", exception); -+ ServerInternalException.reportInternalException(exception); // Paper - return j1; - } + // CraftBukkit end @@ -0,0 +0,0 @@ public final class SpawnerCreature { - entityinsentient = (EntityInsentient) biomebase_biomemeta.b.a(generatoraccess.getMinecraftWorld()); + entityinsentient = (EntityInsentient) entity; + } catch (Exception exception) { + SpawnerCreature.LOGGER.warn("Failed to create mob", exception); ++ ServerInternalException.reportInternalException(exception); // Paper + return; + } + +@@ -0,0 +0,0 @@ public final class SpawnerCreature { + entity = biomebase_biomemeta.b.a(generatoraccess.getMinecraftWorld()); } catch (Exception exception) { - SpawnerCreature.a.warn("Failed to create mob", exception); + SpawnerCreature.LOGGER.warn("Failed to create mob", exception); + ServerInternalException.reportInternalException(exception); // Paper continue; } diff --git a/src/main/java/net/minecraft/server/VillageSiege.java b/src/main/java/net/minecraft/server/VillageSiege.java -index 58122b18eb..0ac1fb53a4 100644 +index d004494aea..d3ed749e1c 100644 --- a/src/main/java/net/minecraft/server/VillageSiege.java +++ b/src/main/java/net/minecraft/server/VillageSiege.java @@ -0,0 +0,0 @@ @@ -229,73 +205,78 @@ index 58122b18eb..0ac1fb53a4 100644 +import com.destroystokyo.paper.exception.ServerInternalException; + import java.util.Iterator; - import java.util.List; import javax.annotation.Nullable; + @@ -0,0 +0,0 @@ public class VillageSiege { - entityzombie.prepare(this.a.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null); + entityzombie.prepare(this.a, this.a.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); } catch (Exception exception) { exception.printStackTrace(); + ServerInternalException.reportInternalException(exception); // Paper - return false; + return; } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 09cf98ccdd..6e7c0c9da4 100644 +index 25e5216e25..55e8c7c7d4 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -0,0 +0,0 @@ - package net.minecraft.server; +@@ -0,0 +0,0 @@ package net.minecraft.server; + import co.aikar.timings.Timing; import co.aikar.timings.Timings; ++<<<<<<< HEAD ++======= +import com.destroystokyo.paper.event.server.ServerExceptionEvent; +import com.destroystokyo.paper.exception.ServerInternalException; - import com.google.common.base.MoreObjects; ++import com.google.common.base.MoreObjects; ++>>>>>>> Add exception reporting event import com.google.common.collect.Lists; - import it.unimi.dsi.fastutil.longs.LongSet; -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - } catch (Throwable throwable1) { - entity.tickTimer.stopTiming(); - // Paper start - Prevent tile entity and entity crashes -- System.err.println("Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX + "," + entity.locY + "," + entity.locZ); -+ String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX + "," + entity.locY + "," + entity.locZ; -+ System.err.println(msg); - throwable1.printStackTrace(); -+ getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable1))); - entity.dead = true; - continue; - // Paper end -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - this.methodProfiler.exit(); - } catch (Throwable throwable2) { + import java.io.IOException; + import java.util.Collection; +@@ -0,0 +0,0 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + gameprofilerfiller.exit(); + } catch (Throwable throwable) { // Paper start - Prevent tile entity and entity crashes - System.err.println("TileEntity threw exception at " + tileentity.world.getWorld().getName() + ":" + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ()); + String msg = "TileEntity threw exception at " + tileentity.world.getWorld().getName() + ":" + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ(); + System.err.println(msg); - throwable2.printStackTrace(); -+ getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable2))); + throwable.printStackTrace(); ++ getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); ++ // Paper end tilesThisCycle--; this.tileEntityListTick.remove(tileTickPosition--); continue; +@@ -0,0 +0,0 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + consumer.accept(entity); + } catch (Throwable throwable) { + // Paper start - Prevent tile entity and entity crashes +- System.err.println("Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX + "," + entity.locY + "," + entity.locZ); ++ String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX + "," + entity.locY + "," + entity.locZ; ++ System.err.println(msg); + throwable.printStackTrace(); ++ getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); + entity.dead = true; + return; + // Paper end diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java -index 478bf49976..8d51af2867 100644 +index 3c5b3fe101..47a4ea9985 100644 --- a/src/main/java/net/minecraft/server/WorldPersistentData.java +++ b/src/main/java/net/minecraft/server/WorldPersistentData.java @@ -0,0 +0,0 @@ public class WorldPersistentData { - - nbttagcompound = GameProfileSerializer.a(idatamanager.i(), DataFixTypes.SAVED_DATA, nbttagcompound1, j, i); - } catch (Throwable throwable1) { -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable1); // Paper - throwable = throwable1; - throw throwable1; + nbttagcompound = GameProfileSerializer.a(this.c, DataFixTypes.SAVED_DATA, nbttagcompound1, j, i); + } catch (Throwable throwable4) { + throwable = throwable4; ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); // Paper + throw throwable4; } finally { + if (pushbackinputstream != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index d75cc42e11..0e9d5fe3a7 100644 +index d99634062b..86a5ee8aac 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -@@ -0,0 +0,0 @@ import java.util.function.Consumer; +@@ -0,0 +0,0 @@ import java.util.concurrent.atomic.AtomicInteger; + import java.util.concurrent.atomic.AtomicReference; + import java.util.function.Consumer; import java.util.logging.Level; - - import co.aikar.timings.MinecraftTimings; // Paper +import com.destroystokyo.paper.ServerSchedulerReportingWrapper; +import com.destroystokyo.paper.event.server.ServerExceptionEvent; +import com.destroystokyo.paper.exception.ServerSchedulerException; diff --git a/Spigot-Server-Patches/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/Spigot-Server-Patches/Add-methods-for-working-with-arrows-stuck-in-living-.patch index 2626ead731..6acc0bdd8f 100644 --- a/Spigot-Server-Patches/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/Spigot-Server-Patches/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add methods for working with arrows stuck in living entities diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 5f14fb8501..716eda9902 100644 +index defcfc9337..424b2b7088 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { diff --git a/Spigot-Server-Patches/Add-velocity-warnings.patch b/Spigot-Server-Patches/Add-velocity-warnings.patch index 5d4e7d3645..fa383a1611 100644 --- a/Spigot-Server-Patches/Add-velocity-warnings.patch +++ b/Spigot-Server-Patches/Add-velocity-warnings.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add velocity warnings diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 19fef2496e..54864fe761 100644 +index 1c96beab7d..01d5a49cf7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { @@ -14,26 +14,23 @@ index 19fef2496e..54864fe761 100644 public int reloadCount; + public static Exception excessiveVelEx; // Paper - Velocity warnings - private final class BooleanWrapper { - private boolean value = true; + static { + ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 660e59ba15..466750f779 100644 +index 852de0d625..5d9b4a58e2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public void setVelocity(Vector velocity) { Preconditions.checkArgument(velocity != null, "velocity"); velocity.checkFinite(); -+ + // Paper start - Warn server owners when plugins try to set super high velocities + if (!(this instanceof org.bukkit.entity.Projectile) && isUnsafeVelocity(velocity)) { + CraftServer.excessiveVelEx = new Exception("Excessive velocity set detected: tried to set velocity of entity " + entity.getName() + " id #" + getEntityId() + " to (" + velocity.getX() + "," + velocity.getY() + "," + velocity.getZ() + ")."); + } + // Paper end + - entity.motX = velocity.getX(); - entity.motY = velocity.getY(); - entity.motZ = velocity.getZ(); + entity.setMot(CraftVector.toNMS(velocity)); entity.velocityChanged = true; } @@ -64,9 +61,9 @@ index 660e59ba15..466750f779 100644 + @Override public double getHeight() { - return getHandle().length; + return getHandle().getHeight(); diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index 8e32c4e2cd..c080a61185 100644 +index 70b187190f..56f5f54bd1 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread @@ -88,6 +85,6 @@ index 8e32c4e2cd..c080a61185 100644 + } + // Paper end log.log( Level.SEVERE, "------------------------------" ); - log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); - dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().primaryThread.getId(), Integer.MAX_VALUE ), log ); + log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper + dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch b/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch index 092dd6b05e..5d257b2708 100644 --- a/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch +++ b/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Allow Reloading of Custom Permissions https://github.com/PaperMC/Paper/issues/49 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6f2d74cf1c..c291bceedd 100644 +index b2861fd0ba..591d3702b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { diff --git a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch b/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch deleted file mode 100644 index 02865abad8..0000000000 --- a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: CullanP -Date: Thu, 3 Mar 2016 02:13:38 -0600 -Subject: [PATCH] Avoid hopper searches if there are no items - -Hoppers searching for items and minecarts is the most expensive part of hopper ticking. -We keep track of the number of minecarts and items in a chunk. -If there are no items in the chunk, we skip searching for items. -If there are no minecarts in the chunk, we skip searching for them. - -Usually hoppers aren't near items, so we can skip most item searches. -And since minecart hoppers are used _very_ rarely near we can avoid alot of searching there. - -Combined, this adds up a lot. - -diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index a9aa13fbf8..cb56d067b9 100644 ---- a/src/main/java/net/minecraft/server/Chunk.java -+++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - } - } - final PaperLightingQueue.LightingQueue lightingQueue = new PaperLightingQueue.LightingQueue(this); -+ // Track the number of minecarts and items -+ // Keep this synced with entitySlices.add() and entitySlices.remove() -+ private final int[] itemCounts = new int[16]; -+ private final int[] inventoryEntityCounts = new int[16]; - // Paper end - public boolean areNeighborsLoaded(final int radius) { - switch (radius) { -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; - entity.chunkZ = this.locZ; - this.entitySlices[k].add(entity); -+ // Paper start -+ if (entity instanceof EntityItem) { -+ itemCounts[k]++; -+ } else if (entity instanceof IInventory) { -+ inventoryEntityCounts[k]++; -+ } -+ // Paper end - } - - public void a(HeightMap.Type heightmap_type, long[] along) { -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - if (!this.entitySlices[i].remove(entity)) { - return; - } -+ if (entity instanceof EntityItem) { -+ itemCounts[i]--; -+ } else if (entity instanceof IInventory) { -+ inventoryEntityCounts[i]--; -+ } - entityCounts.decrement(entity.getMinecraftKeyString()); - // Paper end - } -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - if (!this.entitySlices[k].isEmpty()) { - Iterator iterator = this.entitySlices[k].iterator(); - -+ // Paper start - Don't search for inventories if we have none, and that is all we want -+ /* -+ * We check if they want inventories by seeing if it is the static `IEntitySelector.c` -+ * -+ * Make sure the inventory selector stays in sync. -+ * It should be the one that checks `var1 instanceof IInventory && var1.isAlive()` -+ */ -+ if (predicate == IEntitySelector.isInventory() && inventoryEntityCounts[k] <= 0) continue; -+ // Paper end - while (iterator.hasNext()) { - Entity entity1 = (Entity) iterator.next(); - -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - i = MathHelper.clamp(i, 0, this.entitySlices.length - 1); - j = MathHelper.clamp(j, 0, this.entitySlices.length - 1); - -+ // Paper start -+ int[] counts; -+ if (EntityItem.class.isAssignableFrom(oclass)) { -+ counts = itemCounts; -+ } else if (IInventory.class.isAssignableFrom(oclass)) { -+ counts = inventoryEntityCounts; -+ } else { -+ counts = null; -+ } -+ // Paper end - for (int k = i; k <= j; ++k) { -+ if (counts != null && counts[k] <= 0) continue; // Paper - Don't check a chunk if it doesn't have the type we are looking for - Iterator iterator = this.entitySlices[k].iterator(); // Spigot - - while (iterator.hasNext()) { -diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index bbcbb62325..f6916fd455 100644 ---- a/src/main/java/net/minecraft/server/IEntitySelector.java -+++ b/src/main/java/net/minecraft/server/IEntitySelector.java -@@ -0,0 +0,0 @@ public final class IEntitySelector { - public static final Predicate c = (entity) -> { - return entity.isAlive() && !entity.isVehicle() && !entity.isPassenger(); - }; -+ public static final Predicate isInventory() { return d; } // Paper - OBFHELPER - public static final Predicate d = (entity) -> { - return entity instanceof IInventory && entity.isAlive(); - }; --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Be-a-bit-more-informative-in-maxHealth-exception.patch b/Spigot-Server-Patches/Be-a-bit-more-informative-in-maxHealth-exception.patch index 50b280299b..ada8af6ef8 100644 --- a/Spigot-Server-Patches/Be-a-bit-more-informative-in-maxHealth-exception.patch +++ b/Spigot-Server-Patches/Be-a-bit-more-informative-in-maxHealth-exception.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Be a bit more informative in maxHealth exception diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 3a15b47dd6..5f14fb8501 100644 +index d01e06f1b9..defcfc9337 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { diff --git a/Spigot-Server-Patches/Catch-Async-PlayerChunkMap-operations.patch b/Spigot-Server-Patches/Catch-Async-PlayerChunkMap-operations.patch deleted file mode 100644 index 69c16d95f6..0000000000 --- a/Spigot-Server-Patches/Catch-Async-PlayerChunkMap-operations.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Ennis -Date: Sun, 20 Mar 2016 15:22:42 -0400 -Subject: [PATCH] Catch Async PlayerChunkMap operations - - -diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 55161af9c9..2064576501 100644 ---- a/src/main/java/net/minecraft/server/PlayerChunkMap.java -+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -0,0 +0,0 @@ public class PlayerChunkMap { - } - - public void a(PlayerChunk playerchunk) { -+ org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Add"); // Paper - this.f.add(playerchunk); - } - - public void b(PlayerChunk playerchunk) { -+ org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Remove"); // Paper - ChunkCoordIntPair chunkcoordintpair = playerchunk.a(); - long i = d(chunkcoordintpair.x, chunkcoordintpair.z); - --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch index 0d4d4a4611..019245758e 100644 --- a/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch +++ b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch @@ -6,49 +6,16 @@ Subject: [PATCH] Change implementation of (tile)entity removal list use sets for faster removal diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index a80acbb6a5..09cf98ccdd 100644 +index 48360c2b47..25e5216e25 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - } - }; - // Spigot end -- protected final List g = Lists.newArrayList(); -+ protected final Set g = com.google.common.collect.Sets.newHashSet(); // Paper +@@ -0,0 +0,0 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose public final List tileEntityList = Lists.newArrayList(); public final List tileEntityListTick = Lists.newArrayList(); - private final List c = Lists.newArrayList(); -- private final List tileEntityListUnload = Lists.newArrayList(); -+ private final Set tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper - public final List players = Lists.newArrayList(); - public final List k = Lists.newArrayList(); - protected final IntHashMap entitiesById = new IntHashMap<>(); -@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - this.entityList.removeAll(this.g); - - int j; -- -- for (i = 0; i < this.g.size(); ++i) { -- entity = (Entity) this.g.get(i); -+ // Paper start - Set based removal lists -+ for (Iterator it = this.g.iterator(); it.hasNext() ; ) { -+ entity = it.next(); // Paper - int k = entity.chunkX; - - j = entity.chunkZ; - if (entity.inChunk && this.isChunkLoaded(k, j, true)) { - this.getChunkAt(k, j).b(entity); - } -- } -+ //} // Paper - merge - -- for (i = 0; i < this.g.size(); ++i) { -- this.c((Entity) this.g.get(i)); -+ //for (Entity e : this.g) { // Paper - merge -+ this.c(entity); // Paper use entity - } -+ // Paper end - - this.g.clear(); - this.p_(); + protected final List tileEntityListPending = Lists.newArrayList(); +- protected final List tileEntityListUnload = Lists.newArrayList(); ++ protected final java.util.Set tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper + private final long b = 16777215L; + private final Thread c; + private int d; -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Chunk-Save-Reattempt.patch b/Spigot-Server-Patches/Chunk-Save-Reattempt.patch index 98d0d7aa26..b130299f3c 100644 --- a/Spigot-Server-Patches/Chunk-Save-Reattempt.patch +++ b/Spigot-Server-Patches/Chunk-Save-Reattempt.patch @@ -6,12 +6,12 @@ Subject: [PATCH] Chunk Save Reattempt We commonly have "Stream Closed" errors on chunk saving, so this code should re-try to save the chunk in the event of failure and hopefully prevent rollbacks. diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 0f1c74dd33..9626396745 100644 +index 88b5aa3a51..b062a31c49 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java -@@ -0,0 +0,0 @@ public class RegionFile { +@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { - this.b(i, j, (int) (SystemUtils.getTimeMillis() / 1000L)); + this.b(chunkcoordintpair, (int) (SystemUtils.getTimeMillis() / 1000L)); } catch (IOException ioexception) { - ioexception.printStackTrace(); - ServerInternalException.reportInternalException(ioexception); // Paper @@ -20,37 +20,31 @@ index 0f1c74dd33..9626396745 100644 } diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index e507a996f1..5dbd1d517a 100644 +index ad76ed27dc..75731c9195 100644 --- a/src/main/java/net/minecraft/server/RegionFileCache.java +++ b/src/main/java/net/minecraft/server/RegionFileCache.java -@@ -0,0 +0,0 @@ public class RegionFileCache { +@@ -0,0 +0,0 @@ public abstract class RegionFileCache implements AutoCloseable { + } - @Nullable - public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { + protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { + int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper - RegionFile regionfile = a(file, i, j); + RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit + DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair); + Throwable throwable = null; +@@ -0,0 +0,0 @@ public abstract class RegionFileCache implements AutoCloseable { - DataOutputStream dataoutputstream = regionfile.c(i & 31, j & 31); - NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream); - dataoutputstream.close(); -+ // Paper start -+ laste = null; break; // Paper -+ } catch (Exception exception) { -+ //ChunkRegionLoader.a.error("Failed to save chunk", exception); // Paper -+ laste = exception; // Paper -+ } -+ try { -+ Thread.sleep(10); -+ } catch (InterruptedException e) { -+ e.printStackTrace(); -+ } + } + ++ } catch (Exception ex) { ++ laste = ex; + } ++ } ++ + if (laste != null) { + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); + MinecraftServer.LOGGER.error("Failed to save chunk", laste); + } -+ // Paper end } - public static synchronized boolean chunkExists(File file, int i, int j) { + public void close() throws IOException { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch b/Spigot-Server-Patches/Chunk-save-queue-improvements.patch deleted file mode 100644 index c0b66e98eb..0000000000 --- a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch +++ /dev/null @@ -1,204 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Fri, 4 Mar 2016 18:18:37 -0600 -Subject: [PATCH] Chunk save queue improvements - -For some unknown reason, Minecraft is sleeping 10ms between every single chunk being saved to disk. -Under high chunk load/unload activity (lots of movement / teleporting), this causes the chunk unload queue -to build up in size. - -This has multiple impacts: -1) Performance of the unload queue itself - The save thread is pretty ineffecient for how it accesses it - By letting the queue get larger, checking and popping work off the queue can get less performant. -2) Performance of chunk loading - As with #1, chunk loads also have to check this queue when loading - chunk data so that it doesn't load stale data if new data is pending write to disk. -3) Memory Usage - The entire chunk has been serialized to NBT, and now sits in this queue. This leads to - elevated memory usage, and then the objects used in the serialization sit around longer than needed, - resulting in promotion to Old Generation instead of dying young. - -To optimize this, we change the entire unload queue to be a proper queue. This improves the behavior of popping -the first queued chunk off, instead of abusing iterators like Mojang was doing. - -This also improves reliability of chunk saving, as the previous hack job had a race condition that could -fail to save some chunks. - -Then finally, Sleeping will by default be removed, but due to known issues with 1.9, a config option was added. -But if sleeps are to remain enabled, we at least lower the sleep interval so it doesn't have as much negative impact. - -diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index cfcc244672..4e932ea235 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperConfig.java -+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java -@@ -0,0 +0,0 @@ public class PaperConfig { - " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) + - " - Length: " + timeSummary(Timings.getHistoryLength() / 20)); - } -+ -+ public static boolean enableFileIOThreadSleep; -+ private static void enableFileIOThreadSleep() { -+ enableFileIOThreadSleep = getBoolean("settings.sleep-between-chunk-saves", false); -+ if (enableFileIOThreadSleep) Bukkit.getLogger().info("Enabled sleeping between chunk saves, beware of memory issues"); -+ } - } -diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java -index b0c004b1f2..d2cece2651 100644 ---- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java -+++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java -@@ -0,0 +0,0 @@ public class ChunkCoordIntPair { - this.z = (int) (i >> 32); - } - -+ public long asLong() { return a(); } // Paper - public long a() { - return a(this.x, this.z); - } -diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 35976a26f3..21ee154a57 100644 ---- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java -+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -@@ -0,0 +0,0 @@ import java.util.Map.Entry; - import java.util.function.Consumer; - import java.util.function.Function; - import javax.annotation.Nullable; -+import java.util.concurrent.ConcurrentLinkedQueue; // Paper - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - // Spigot start -@@ -0,0 +0,0 @@ import org.spigotmc.SupplierUtils; - - public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - -+ // Paper start - Chunk queue improvements -+ private static class QueuedChunk { -+ public ChunkCoordIntPair coords; -+ public Supplier compoundSupplier; -+ public Runnable onSave; -+ -+ public QueuedChunk(Runnable run) { -+ this.coords = null; -+ this.compoundSupplier = null; -+ this.onSave = run; -+ } -+ -+ public QueuedChunk(ChunkCoordIntPair coords, Supplier compoundSupplier) { -+ this.coords = coords; -+ this.compoundSupplier = compoundSupplier; -+ } -+ } -+ final private ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue<>(); -+ // Paper end -+ - private static final Logger a = LogManager.getLogger(); -- private final Map> b = Maps.newHashMap(); -+ private final it.unimi.dsi.fastutil.longs.Long2ObjectMap> saveMap = it.unimi.dsi.fastutil.longs.Long2ObjectMaps.synchronize(new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>()); // Paper - private final File c; - private final DataFixer d; - private PersistentStructureLegacy e; -@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - return null; - } - // CraftBukkit end -- NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.b.get(new ChunkCoordIntPair(i, j))); // Spigot -+ NBTTagCompound nbttagcompound = SupplierUtils.getIfExists(this.saveMap.get(ChunkCoordIntPair.asLong(i, j))); // Spigot // Paper - - if (nbttagcompound != null) { - return nbttagcompound; -@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - }; - } - -- this.a(chunkcoordintpair, SupplierUtils.createUnivaluedSupplier(completion, unloaded && this.b.size() < SAVE_QUEUE_TARGET_SIZE)); -+ this.a(chunkcoordintpair, SupplierUtils.createUnivaluedSupplier(completion, unloaded)); // Paper - Remove save queue target size - // Spigot end - } catch (Exception exception) { - ChunkRegionLoader.a.error("Failed to save chunk", exception); -@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - } - - protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier nbttagcompound) { // Spigot -- this.b.put(chunkcoordintpair, nbttagcompound); -+ this.saveMap.put(chunkcoordintpair.asLong(), nbttagcompound); // Paper -+ queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements - FileIOThread.a().a(this); - } - -@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - } - - private boolean processSaveQueueEntry(boolean logCompletion) { -- Iterator>> iterator = this.b.entrySet().iterator(); // Spigot -- -- if (!iterator.hasNext()) { -+ // Paper start - Chunk queue improvements -+ QueuedChunk chunk = queue.poll(); -+ if (chunk == null) { -+ // Paper - end - if (logCompletion) { // CraftBukkit - ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName()); - } - - return false; - } else { -- Entry entry = (Entry) iterator.next(); -- -- iterator.remove(); -- ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) entry.getKey(); -- Supplier nbttagcompound = (Supplier) entry.getValue(); // Spigot -+ // Paper start -+ if (chunk.onSave != null) { -+ chunk.onSave.run(); -+ return true; -+ } -+ // Paper end -+ ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements -+ Supplier nbttagcompound = chunk.compoundSupplier; // Spigot // Paper - - if (nbttagcompound == null) { - return true; -@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - // CraftBukkit start - RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z, SupplierUtils.getIfExists(nbttagcompound)); // Spigot - -+ // Paper start remove from map only if this was the latest version of the chunk -+ synchronized (this.saveMap) { -+ long k = chunkcoordintpair.asLong(); -+ // This will not equal if a newer version is still pending - wait until newest is saved to remove -+ if (this.saveMap.get(k) == chunk.compoundSupplier) { -+ this.saveMap.remove(k); -+ } -+ } -+ // Paper end - /* - NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); - dataoutputstream.close(); -diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java -index 8c3537ab8d..3c688f546c 100644 ---- a/src/main/java/net/minecraft/server/FileIOThread.java -+++ b/src/main/java/net/minecraft/server/FileIOThread.java -@@ -0,0 +0,0 @@ public class FileIOThread implements Runnable { - IAsyncChunkSaver iasyncchunksaver = (IAsyncChunkSaver) this.c.get(i); - boolean flag; - -- synchronized (iasyncchunksaver) { -+ //synchronized (iasyncchunksaver) { // Paper - remove synchronized - flag = iasyncchunksaver.a(); -- } -+ //} // Paper - - if (!flag) { - this.c.remove(i--); - ++this.e; - } - -+ if (com.destroystokyo.paper.PaperConfig.enableFileIOThreadSleep) { // Paper - try { -- Thread.sleep(this.f ? 0L : 10L); -+ Thread.sleep(this.f ? 0L : 1L); // Paper - } catch (InterruptedException interruptedexception) { - interruptedexception.printStackTrace(); -- } -+ }} // Paper - } - - if (this.c.isEmpty()) { --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Complete-resource-pack-API.patch b/Spigot-Server-Patches/Complete-resource-pack-API.patch index a5d378f812..aa9e9de78d 100644 --- a/Spigot-Server-Patches/Complete-resource-pack-API.patch +++ b/Spigot-Server-Patches/Complete-resource-pack-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Complete resource pack API diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 9a83e5fc0b..8a403354d9 100644 +index 9d7bbafe02..e83ebaf4f4 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java -@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { // CraftBukkit start public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) { PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.getWorldServer()); @@ -22,7 +22,7 @@ index 9a83e5fc0b..8a403354d9 100644 // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 237210cc89..5b9f2dd4a6 100644 +index b993d236b5..326200fd58 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/Configurable-Non-Player-Arrow-Despawn-Rate.patch b/Spigot-Server-Patches/Configurable-Non-Player-Arrow-Despawn-Rate.patch index 5bbe541323..c6327d6532 100644 --- a/Spigot-Server-Patches/Configurable-Non-Player-Arrow-Despawn-Rate.patch +++ b/Spigot-Server-Patches/Configurable-Non-Player-Arrow-Despawn-Rate.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Non Player Arrow Despawn Rate Can set a much shorter despawn rate for arrows that players can not pick up. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 66243835a5..803e680894 100644 +index 89556dc94a..98049567f4 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -30,12 +30,12 @@ index 66243835a5..803e680894 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java -index e8ce99eb96..feafb82dd3 100644 +index bc391812d3..b5b569ef95 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile { - protected void f() { + protected void i() { ++this.despawnCounter; - if (this.despawnCounter >= world.spigotConfig.arrowDespawnRate) { // Spigot + if (this.despawnCounter >= (fromPlayer == PickupStatus.CREATIVE_ONLY ? world.paperConfig.creativeArrowDespawnRate : (fromPlayer == PickupStatus.DISALLOWED ? world.paperConfig.nonPlayerArrowDespawnRate : world.spigotConfig.arrowDespawnRate))) { // Spigot // Paper diff --git a/Spigot-Server-Patches/Configurable-inter-world-teleportation-safety.patch b/Spigot-Server-Patches/Configurable-inter-world-teleportation-safety.patch index 659d7502cc..9d911e1f31 100644 --- a/Spigot-Server-Patches/Configurable-inter-world-teleportation-safety.patch +++ b/Spigot-Server-Patches/Configurable-inter-world-teleportation-safety.patch @@ -16,7 +16,7 @@ The wanted destination was on top of the emerald block however the player ended This only is the case if the player is teleporting between worlds. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 3137128780..40b54191e6 100644 +index 320fd07c62..94f5c90b3c 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -30,7 +30,7 @@ index 3137128780..40b54191e6 100644 + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index b8400876e5..237210cc89 100644 +index d56fbdf80b..b993d236b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/Configurable-spawn-chances-for-skeleton-horses.patch b/Spigot-Server-Patches/Configurable-spawn-chances-for-skeleton-horses.patch index 374c7f69ef..c6a352fcee 100644 --- a/Spigot-Server-Patches/Configurable-spawn-chances-for-skeleton-horses.patch +++ b/Spigot-Server-Patches/Configurable-spawn-chances-for-skeleton-horses.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable spawn chances for skeleton horses diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 803e680894..be380ac75e 100644 +index 98049567f4..2a71381dae 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -22,16 +22,16 @@ index 803e680894..be380ac75e 100644 + } } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index ed6f3afcfe..aaeb888a8c 100644 +index e176c63fed..9a4a558467 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { - blockposition = this.a(new BlockPosition(j + (l & 15), 0, k + (l >> 8 & 15))); - if (this.isRainingAt(blockposition)) { - DifficultyDamageScaler difficultydamagescaler = this.getDamageScaler(blockposition); -- boolean flag2 = this.getGameRules().getBoolean("doMobSpawning") && this.random.nextDouble() < (double) difficultydamagescaler.b() * 0.01D; -+ boolean flag2 = this.getGameRules().getBoolean("doMobSpawning") && this.random.nextDouble() < (double) difficultydamagescaler.b() * paperConfig.skeleHorseSpawnChance; // Paper +@@ -0,0 +0,0 @@ public class WorldServer extends World { + blockposition = this.a(this.a(j, 0, k, 15)); + if (this.isRainingAt(blockposition)) { + DifficultyDamageScaler difficultydamagescaler = this.getDamageScaler(blockposition); +- boolean flag1 = this.getGameRules().getBoolean("doMobSpawning") && this.random.nextDouble() < (double) difficultydamagescaler.b() * 0.01D; ++ boolean flag1 = this.getGameRules().getBoolean("doMobSpawning") && this.random.nextDouble() < (double) difficultydamagescaler.b() * paperConfig.skeleHorseSpawnChance; // Paper; - if (flag2) { - EntityHorseSkeleton entityhorseskeleton = new EntityHorseSkeleton(this); + if (flag1) { + EntityHorseSkeleton entityhorseskeleton = (EntityHorseSkeleton) EntityTypes.SKELETON_HORSE.a((World) this); -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Custom-replacement-for-eaten-items.patch b/Spigot-Server-Patches/Custom-replacement-for-eaten-items.patch index 472818e45c..1b57d74866 100644 --- a/Spigot-Server-Patches/Custom-replacement-for-eaten-items.patch +++ b/Spigot-Server-Patches/Custom-replacement-for-eaten-items.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Custom replacement for eaten items diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 0ba15fce63..a12cc1e92f 100644 +index e3613a8e67..44570edcae 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { @@ -33,9 +33,9 @@ index 0ba15fce63..a12cc1e92f 100644 + itemstack = CraftItemStack.asNMSCopy(event.getReplacement()); + } + // Paper end - this.a(this.cU(), itemstack); + this.a(this.getRaisedHand(), itemstack); // CraftBukkit end - this.da(); + this.dp(); + // Paper start - if the replacement is anything but the default, update the client inventory + if (this instanceof EntityPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) { + ((EntityPlayer) this).getBukkitEntity().updateInventory(); diff --git a/Spigot-Server-Patches/Default-loading-permissions.yml-before-plugins.patch b/Spigot-Server-Patches/Default-loading-permissions.yml-before-plugins.patch index d4fd6035f2..b3fce10ee5 100644 --- a/Spigot-Server-Patches/Default-loading-permissions.yml-before-plugins.patch +++ b/Spigot-Server-Patches/Default-loading-permissions.yml-before-plugins.patch @@ -16,12 +16,12 @@ modify that. Under the previous logic, plugins were unable (cleanly) override pe A config option has been added for those who depend on the previous behavior, but I don't expect that. diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 4e932ea235..e4ba7146d1 100644 +index 7691409f6c..809b3a1a4a 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ public class PaperConfig { - enableFileIOThreadSleep = getBoolean("settings.sleep-between-chunk-saves", false); - if (enableFileIOThreadSleep) Bukkit.getLogger().info("Enabled sleeping between chunk saves, beware of memory issues"); + " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) + + " - Length: " + timeSummary(Timings.getHistoryLength() / 20)); } + + public static boolean loadPermsBeforePlugins = true; @@ -30,7 +30,7 @@ index 4e932ea235..e4ba7146d1 100644 + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 54864fe761..6f2d74cf1c 100644 +index 01d5a49cf7..b2861fd0ba 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { diff --git a/Spigot-Server-Patches/Disable-Scoreboards-for-non-players-by-default.patch b/Spigot-Server-Patches/Disable-Scoreboards-for-non-players-by-default.patch index 55808fef8f..6f61a743a7 100644 --- a/Spigot-Server-Patches/Disable-Scoreboards-for-non-players-by-default.patch +++ b/Spigot-Server-Patches/Disable-Scoreboards-for-non-players-by-default.patch @@ -11,7 +11,7 @@ So avoid looking up scoreboards and short circuit to the "not on a team" logic which is most likely to be true. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 40b54191e6..06417c8250 100644 +index 94f5c90b3c..30f0dcfd51 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -25,7 +25,7 @@ index 40b54191e6..06417c8250 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index ad30cdd824..c7f83d4343 100644 +index 49245b5c5f..9ad8893943 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -37,7 +37,7 @@ index ad30cdd824..c7f83d4343 100644 } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index c5cc0b471b..0ba15fce63 100644 +index d85172e728..e3613a8e67 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { @@ -45,7 +45,7 @@ index c5cc0b471b..0ba15fce63 100644 String s = nbttagcompound.getString("Team"); ScoreboardTeam scoreboardteam = this.world.getScoreboard().getTeam(s); + if (!world.paperConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof EntityHuman)) { scoreboardteam = null; } // Paper - boolean flag = scoreboardteam != null && this.world.getScoreboard().addPlayerToTeam(this.bu(), scoreboardteam); + boolean flag = scoreboardteam != null && this.world.getScoreboard().addPlayerToTeam(this.getUniqueIDString(), scoreboardteam); if (!flag) { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch b/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch index 1ef54ce10e..b61fc94b0a 100644 --- a/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch +++ b/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Don't nest if we don't need to when cerealising text diff --git a/src/main/java/net/minecraft/server/PacketPlayOutChat.java b/src/main/java/net/minecraft/server/PacketPlayOutChat.java -index 28a2628350..eba6aadad7 100644 +index fa4eab5b0b..0ab611564e 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutChat.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java @@ -0,0 +0,0 @@ public class PacketPlayOutChat implements Packet { diff --git a/Spigot-Server-Patches/Don-t-teleport-dead-entities.patch b/Spigot-Server-Patches/Don-t-teleport-dead-entities.patch deleted file mode 100644 index c3b07259ad..0000000000 --- a/Spigot-Server-Patches/Don-t-teleport-dead-entities.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Tue, 22 Mar 2016 00:55:23 -0400 -Subject: [PATCH] Don't teleport dead entities - -Had some issue with this in past, and this is the vanilla logic. -Potentially an old CB change that's no longer needed. - -diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index cbbb243d1c..dba97f2305 100644 ---- a/src/main/java/net/minecraft/server/Entity.java -+++ b/src/main/java/net/minecraft/server/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - } - - public Entity teleportTo(Location exit, boolean portal) { -- if (true) { -+ if (!this.dead) { // Paper - WorldServer worldserver = ((CraftWorld) getBukkitEntity().getLocation().getWorld()).getHandle(); - WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); - DimensionManager dimensionmanager = worldserver1.dimension; --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Ensure-inv-drag-is-in-bounds.patch b/Spigot-Server-Patches/Ensure-inv-drag-is-in-bounds.patch index de742ee7f2..a73065b2f6 100644 --- a/Spigot-Server-Patches/Ensure-inv-drag-is-in-bounds.patch +++ b/Spigot-Server-Patches/Ensure-inv-drag-is-in-bounds.patch @@ -5,16 +5,16 @@ Subject: [PATCH] Ensure inv drag is in bounds diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java -index b06f229534..2f0f667ad6 100644 +index 7a27993476..a2805011df 100644 --- a/src/main/java/net/minecraft/server/Container.java +++ b/src/main/java/net/minecraft/server/Container.java @@ -0,0 +0,0 @@ public abstract class Container { - this.c(); + this.d(); } - } else if (this.g == 1) { + } else if (this.h == 1) { - Slot slot = (Slot) this.slots.get(i); + Slot slot = i < this.slots.size() ? this.slots.get(i) : null; // Paper - Ensure drag in bounds itemstack1 = playerinventory.getCarried(); - if (slot != null && a(slot, itemstack1, true) && slot.isAllowed(itemstack1) && (this.dragType == 2 || itemstack1.getCount() > this.h.size()) && this.b(slot)) { + if (slot != null && a(slot, itemstack1, true) && slot.isAllowed(itemstack1) && (this.dragType == 2 || itemstack1.getCount() > this.i.size()) && this.b(slot)) { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Expose-server-CommandMap.patch b/Spigot-Server-Patches/Expose-server-CommandMap.patch index 08674d5c3b..97a7ab644b 100644 --- a/Spigot-Server-Patches/Expose-server-CommandMap.patch +++ b/Spigot-Server-Patches/Expose-server-CommandMap.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Expose server CommandMap diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c6e6ae4fe7..19fef2496e 100644 +index 9c54d151df..1c96beab7d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { diff --git a/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch b/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch index b9cc92f671..fa84e89b24 100644 --- a/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch +++ b/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch @@ -18,7 +18,7 @@ For consistency, the old API methods now forward to use the ItemMeta API equivalents, and should deprecate the old API's. diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java -index a7fc148591..37d37f1f64 100644 +index aa6a58dd88..b643a41235 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -0,0 +0,0 @@ import com.mojang.brigadier.StringReader; @@ -72,23 +72,15 @@ index a7fc148591..37d37f1f64 100644 @@ -0,0 +0,0 @@ public final class ItemStack { nbttagcompound.setString("id", String.valueOf(IRegistry.ENCHANTMENT.getKey(enchantment))); nbttagcompound.setShort("lvl", (short) ((byte) i)); - nbttaglist.add((NBTBase) nbttagcompound); + nbttaglist.add(nbttagcompound); + processEnchantOrder(nbttagcompound); // Paper } public boolean hasEnchantments() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index f907d4f3b7..eeb2c5689e 100644 +index 9ed7f8ede4..6c00ca7378 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -0,0 +0,0 @@ import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS; - import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_ID; - import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_LVL; - -+import java.util.Iterator; - import java.util.Map; - - import net.minecraft.server.EnchantmentManager; @@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack { public void addUnsafeEnchantment(Enchantment ench, int level) { Validate.notNull(ench, "Cannot add null enchantment"); @@ -201,43 +193,43 @@ index f907d4f3b7..eeb2c5689e 100644 static Map getEnchantments(net.minecraft.server.ItemStack item) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index ef6437f380..2508cfcfa2 100644 +index e3ca978f89..b3f8249b06 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -0,0 +0,0 @@ import java.lang.reflect.Constructor; - import java.lang.reflect.InvocationTargetException; - import java.util.ArrayList; +@@ -0,0 +0,0 @@ import java.util.ArrayList; + import java.util.Arrays; import java.util.Collection; -+import java.util.Comparator; + import java.util.EnumSet; ++import java.util.Comparator; // Paper import java.util.HashMap; import java.util.Iterator; - import java.util.List; -@@ -0,0 +0,0 @@ import com.google.common.collect.SetMultimap; + import java.util.LinkedHashMap; +@@ -0,0 +0,0 @@ import java.util.Locale; + import java.util.Map; + import java.util.NoSuchElementException; + import java.util.Set; ++import java.util.TreeMap; // Paper + import java.util.logging.Level; + import java.util.logging.Logger; + import javax.annotation.Nonnull; +@@ -0,0 +0,0 @@ import net.minecraft.server.EnumChatFormat; import net.minecraft.server.EnumItemSlot; import net.minecraft.server.GenericAttributes; import net.minecraft.server.IChatBaseComponent; -+import com.google.common.collect.ImmutableSortedMap; ++import com.google.common.collect.ImmutableSortedMap; // Paper import net.minecraft.server.NBTBase; + import net.minecraft.server.NBTCompressedStreamTools; import net.minecraft.server.NBTTagCompound; - import net.minecraft.server.NBTTagList; -@@ -0,0 +0,0 @@ import java.util.Arrays; - import java.util.EnumSet; - import java.util.LinkedHashMap; - import java.util.Set; -+import java.util.TreeMap; - import java.util.logging.Level; - import java.util.logging.Logger; - import net.minecraft.server.EnumChatFormat; -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { - private IChatBaseComponent displayName; - private IChatBaseComponent locName; - private List lore; +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + private List lore; + private Integer customModelData; + private String blockData; - private Map enchantments; + private EnchantmentMap enchantments; // Paper private Multimap attributeModifiers; private int repairCost; private int hideFlag; -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private static final CraftCustomTagTypeRegistry TAG_TYPE_REGISTRY = new CraftCustomTagTypeRegistry(); private NBTTagCompound internalTag; @@ -245,9 +237,9 @@ index ef6437f380..2508cfcfa2 100644 + private final Map unhandledTags = new TreeMap<>(); // Paper private final CraftCustomItemTagContainer publicItemTagContainer = new CraftCustomItemTagContainer(TAG_TYPE_REGISTRY); - CraftMetaItem(CraftMetaItem meta) { -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { - } + private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + this.blockData = meta.blockData; if (meta.enchantments != null) { // Spigot - this.enchantments = new LinkedHashMap(meta.enchantments); @@ -255,7 +247,7 @@ index ef6437f380..2508cfcfa2 100644 } if (meta.hasAttributeModifiers()) { -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } @@ -271,7 +263,7 @@ index ef6437f380..2508cfcfa2 100644 for (int i = 0; i < ench.size(); i++) { String id = ((NBTTagCompound) ench.get(i)).getString(ENCHANTMENTS_ID.NBT); -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } @@ -287,7 +279,7 @@ index ef6437f380..2508cfcfa2 100644 for (Map.Entry entry : ench.entrySet()) { // Doctor older enchants String enchantKey = entry.getKey().toString(); -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } public Map getEnchants() { @@ -303,16 +295,16 @@ index ef6437f380..2508cfcfa2 100644 } if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) { -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { - clone.lore = new ArrayList(this.lore); - } +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + clone.customModelData = this.customModelData; + clone.blockData = this.blockData; if (this.enchantments != null) { - clone.enchantments = new LinkedHashMap(this.enchantments); + clone.enchantments = new EnchantmentMap(this.enchantments); // Paper } if (this.hasAttributeModifiers()) { clone.attributeModifiers = HashMultimap.create(this.attributeModifiers); -@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } diff --git a/Spigot-Server-Patches/Optimize-Chunk-Access.patch b/Spigot-Server-Patches/Optimize-Chunk-Access.patch deleted file mode 100644 index 44616ff2f1..0000000000 --- a/Spigot-Server-Patches/Optimize-Chunk-Access.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Thu, 27 Aug 2015 01:15:02 -0400 -Subject: [PATCH] Optimize Chunk Access - -getting a loaded chunk is one of the most hottest pieces of code in the game. -getChunkAt is called for the same chunk multiple times in a row, often from getType(); - -Optimize this look up by using a Last Access cache. - -diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java -index 732c8793e5..8b3738c8f7 100644 ---- a/src/main/java/net/minecraft/server/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/ChunkMap.java -@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - - public Chunk put(long i, Chunk chunk) { - chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper -+ lastChunkByPos = chunk; // Paper - Chunk chunk1 = (Chunk) super.put(i, chunk); - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i); - -@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - for (int k = chunkcoordintpair.z - 1; k <= chunkcoordintpair.z + 1; ++k) { - if (j != chunkcoordintpair.x || k != chunkcoordintpair.z) { - long l = ChunkCoordIntPair.a(j, k); -- Chunk chunk2 = (Chunk) this.get(l); -+ Chunk chunk2 = (Chunk) super.get(l); // Paper - use super to avoid polluting last access cache - - if (chunk2 != null) { - chunk.H(); -@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - continue; - } - -- Chunk neighbor = this.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z)); -+ Chunk neighbor = super.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z)); // Paper - use super to avoid polluting last access cache - if (neighbor != null) { - neighbor.setNeighborLoaded(-x, -z); - chunk.setNeighborLoaded(x, z); -@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - for (int j = chunkcoordintpair.x - 1; j <= chunkcoordintpair.x + 1; ++j) { - for (int k = chunkcoordintpair.z - 1; k <= chunkcoordintpair.z + 1; ++k) { - if (j != chunkcoordintpair.x || k != chunkcoordintpair.z) { -- Chunk chunk1 = (Chunk) this.get(ChunkCoordIntPair.a(j, k)); -+ Chunk chunk1 = (Chunk) super.get(ChunkCoordIntPair.a(j, k)); // Paper - use super to avoid polluting last access cache - - if (chunk1 != null) { - chunk1.I(); -@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - } - } - -+ // Paper start -+ if (lastChunkByPos != null && i == lastChunkByPos.chunkKey) { -+ lastChunkByPos = null; -+ } - return chunk; - } -+ private Chunk lastChunkByPos = null; -+ -+ @Override -+ public Chunk get(long l) { -+ if (lastChunkByPos != null && l == lastChunkByPos.chunkKey) { -+ return lastChunkByPos; -+ } -+ return lastChunkByPos = super.get(l); -+ } -+ // Paper end - - public Chunk remove(Object object) { - return this.remove((Long) object); -diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 1ed7c7e2c9..c54df45837 100644 ---- a/src/main/java/net/minecraft/server/ChunkProviderServer.java -+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - Chunk chunk; - - synchronized (this.chunkLoader) { -- if (this.lastChunk != null && this.lastChunk.getPos().x == i && this.lastChunk.getPos().z == j) { -+ // Paper start - remove vanilla lastChunk, we do it more accurately -+ /* if (this.lastChunk != null && this.lastChunk.locX == i && this.lastChunk.locZ == j) { - return this.lastChunk; -- } -+ }*/ // Paper end - - long k = ChunkCoordIntPair.a(i, j); - - chunk = (Chunk) this.chunks.get(k); - if (chunk != null) { -- this.lastChunk = chunk; -+ //this.lastChunk = chunk; // Paper remove vanilla lastChunk - return chunk; - } - -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - } - - this.chunks.put(k, chunk); -- this.lastChunk = chunk; -+ //this.lastChunk = chunk; // Paper - } - - this.asyncTaskHandler.postToMainThread(chunk::addEntities); -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - this.saveChunk(chunk, true); // Spigot - } - this.chunks.remove(chunk.chunkKey); -- this.lastChunk = null; -+ // this.lastChunk = null; // Paper - } - return true; - } -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - } - - public boolean isLoaded(int i, int j) { -- return this.chunks.containsKey(ChunkCoordIntPair.a(i, j)); -+ return this.chunks.get(ChunkCoordIntPair.asLong(i, j)) != null; // Paper - use get for last access - } - } --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Optimized-Light-Level-Comparisons.patch b/Spigot-Server-Patches/Optimized-Light-Level-Comparisons.patch deleted file mode 100644 index 21c7f46fb0..0000000000 --- a/Spigot-Server-Patches/Optimized-Light-Level-Comparisons.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Fri, 18 Mar 2016 21:22:56 -0400 -Subject: [PATCH] Optimized Light Level Comparisons - -Use an optimized method to test if a block position meets a desired light level. - -This method benefits from returning as soon as the desired light level matches. - -diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java -index fe0dde1461..9d53f1118c 100644 ---- a/src/main/java/net/minecraft/server/BlockCrops.java -+++ b/src/main/java/net/minecraft/server/BlockCrops.java -@@ -0,0 +0,0 @@ public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { - super.a(iblockdata, world, blockposition, random); -- if (world.getLightLevel(blockposition.up(), 0) >= 9) { -+ if (world.isLightLevel(blockposition.up(), 9)) { // Paper - int i = this.k(iblockdata); - - if (i < this.e()) { -diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java -index 81ea9bcb4f..291cc9a398 100644 ---- a/src/main/java/net/minecraft/server/BlockSapling.java -+++ b/src/main/java/net/minecraft/server/BlockSapling.java -@@ -0,0 +0,0 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { - super.a(iblockdata, world, blockposition, random); -- if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(Math.max(2, (int) (((100.0F / world.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot -+ if (world.isLightLevel(blockposition.up(), 9) && random.nextInt(Math.max(2, (int) (((100.0F / world.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) { // Spigot // Paper - // CraftBukkit start - world.captureTreeGeneration = true; - // CraftBukkit end -diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java -index 53f091835c..f8dda1b7a1 100644 ---- a/src/main/java/net/minecraft/server/BlockStem.java -+++ b/src/main/java/net/minecraft/server/BlockStem.java -@@ -0,0 +0,0 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { - super.a(iblockdata, world, blockposition, random); -- if (world.getLightLevel(blockposition.up(), 0) >= 9) { -+ if (world.isLightLevel(blockposition.up(), 9)) { // Paper - float f = BlockCrops.a((Block) this, (IBlockAccess) world, blockposition); - - if (random.nextInt((int) ((100.0F / (this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier)) * (25.0F / f)) + 1) == 0) { // Spigot -diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java -index 5ea5170436..dc61263a3f 100644 ---- a/src/main/java/net/minecraft/server/EntityMonster.java -+++ b/src/main/java/net/minecraft/server/EntityMonster.java -@@ -0,0 +0,0 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { - if (this.world.getBrightness(EnumSkyBlock.SKY, blockposition) > this.random.nextInt(32)) { - return false; - } else { -- int i = this.world.Y() ? this.world.d(blockposition, 10) : this.world.getLightLevel(blockposition); -- -- return i <= this.random.nextInt(8); -+ // Paper start - optimized light check, returns faster -+ boolean passes; -+ if (this.world.Y()) { -+ final int orig = world.getSkylightSubtracted(); -+ world.setSkylightSubtracted(10); -+ passes = !this.world.isLightLevel(blockposition, this.random.nextInt(8)); -+ world.setSkylightSubtracted(orig); -+ } else { -+ passes = !this.world.isLightLevel(blockposition, this.random.nextInt(8)); -+ } -+ return passes; -+ // Paper end - } - } - -diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java -index 002be7f7be..7a943a6c27 100644 ---- a/src/main/java/net/minecraft/server/EntityZombie.java -+++ b/src/main/java/net/minecraft/server/EntityZombie.java -@@ -0,0 +0,0 @@ public class EntityZombie extends EntityMonster { - int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); - int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); - -- if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { -+ if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && !this.world.isLightLevel(new BlockPosition(i1, j1, k1), 10)) { // Paper - entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a_(entityzombie, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Pass-world-to-Village-creation.patch b/Spigot-Server-Patches/Pass-world-to-Village-creation.patch deleted file mode 100644 index 9c036f5194..0000000000 --- a/Spigot-Server-Patches/Pass-world-to-Village-creation.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Sat, 19 Mar 2016 15:16:54 -0400 -Subject: [PATCH] Pass world to Village creation - -fixes NPE bug #95 - -diff --git a/src/main/java/net/minecraft/server/PersistentVillage.java b/src/main/java/net/minecraft/server/PersistentVillage.java -index 98c6bbc183..7a9fb97530 100644 ---- a/src/main/java/net/minecraft/server/PersistentVillage.java -+++ b/src/main/java/net/minecraft/server/PersistentVillage.java -@@ -0,0 +0,0 @@ public class PersistentVillage extends PersistentBase { - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i); -- Village village = new Village(); -+ Village village = new Village(world); // Paper - - village.a(nbttagcompound1); - this.villages.add(village); -diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java -index 68ad7bc213..b794572915 100644 ---- a/src/main/java/net/minecraft/server/Village.java -+++ b/src/main/java/net/minecraft/server/Village.java -@@ -0,0 +0,0 @@ public class Village { - private final List k; - private int l; - -- public Village() { -+ private Village() { // Paper - Nothing should call this - world needs to be set. - this.c = BlockPosition.ZERO; - this.d = BlockPosition.ZERO; - this.j = Maps.newHashMap(); --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch index 227844b2ac..35775bc91c 100644 --- a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch +++ b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Player Tab List and Title APIs diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java -index 62fba42c37..48fecffdfe 100644 +index aa8601920b..6e867e2347 100644 --- a/src/main/java/net/minecraft/server/IChatBaseComponent.java +++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java @@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable { @@ -36,6 +36,7 @@ index 7b18c16402..15d62cf066 100644 + } + // Paper end + @Override public void b(PacketDataSerializer packetdataserializer) throws IOException { packetdataserializer.a((Enum) this.a); if (this.a == PacketPlayOutTitle.EnumTitleAction.TITLE || this.a == PacketPlayOutTitle.EnumTitleAction.SUBTITLE || this.a == PacketPlayOutTitle.EnumTitleAction.ACTIONBAR) { @@ -51,7 +52,7 @@ index 7b18c16402..15d62cf066 100644 if (this.a == PacketPlayOutTitle.EnumTitleAction.TIMES) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5496fae409..b8400876e5 100644 +index 6b93cc3a57..d56fbdf80b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ diff --git a/Spigot-Server-Patches/Remove-Metadata-on-reload.patch b/Spigot-Server-Patches/Remove-Metadata-on-reload.patch index 36841a48c9..e21b60d796 100644 --- a/Spigot-Server-Patches/Remove-Metadata-on-reload.patch +++ b/Spigot-Server-Patches/Remove-Metadata-on-reload.patch @@ -7,7 +7,7 @@ Metadata is not meant to persist reload as things break badly with non primitive This will remove metadata on reload so it does not crash everything if a plugin uses it. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c291bceedd..5e821b84d6 100644 +index 591d3702b5..cf9594ea2b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { diff --git a/Spigot-Server-Patches/Undead-horse-leashing.patch b/Spigot-Server-Patches/Undead-horse-leashing.patch index 03acdc0496..b36253bbd4 100644 --- a/Spigot-Server-Patches/Undead-horse-leashing.patch +++ b/Spigot-Server-Patches/Undead-horse-leashing.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Undead horse leashing default false to match vanilla, but option to allow undead horse types to be leashed. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 06417c8250..66243835a5 100644 +index 30f0dcfd51..89556dc94a 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -20,16 +20,16 @@ index 06417c8250..66243835a5 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityHorseAbstract.java b/src/main/java/net/minecraft/server/EntityHorseAbstract.java -index fc89cc89a4..953277631a 100644 +index e9f34c9307..8ce2fca806 100644 --- a/src/main/java/net/minecraft/server/EntityHorseAbstract.java +++ b/src/main/java/net/minecraft/server/EntityHorseAbstract.java @@ -0,0 +0,0 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInven - } + @Override public boolean a(EntityHuman entityhuman) { - return super.a(entityhuman) && this.getMonsterType() != EnumMonsterType.UNDEAD; + return world.paperConfig.allowLeashingUndeadHorse ? super.a(entityhuman) : super.a(entityhuman) && this.getMonsterType() != EnumMonsterType.UNDEAD; // Paper } - protected void u(float f) { + @Override -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Use-a-Shared-Random-for-Entities.patch b/Spigot-Server-Patches/Use-a-Shared-Random-for-Entities.patch index 3e7f55bab8..7d03357fd7 100644 --- a/Spigot-Server-Patches/Use-a-Shared-Random-for-Entities.patch +++ b/Spigot-Server-Patches/Use-a-Shared-Random-for-Entities.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Use a Shared Random for Entities Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created. diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index c7f83d4343..cbbb243d1c 100644 +index 9ad8893943..5744760acc 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -31,9 +31,9 @@ index c7f83d4343..cbbb243d1c 100644 return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; } @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - this.length = 1.8F; - this.aA = 1.0F; - this.aB = 1.0F; + this.B = Vec3D.a; + this.av = 1.0F; + this.aw = 1.0F; - this.random = new Random(); + this.random = SHARED_RANDOM; // Paper this.fireTicks = -this.getMaxFireTicks(); diff --git a/Spigot-Server-Patches/Waving-banner-workaround.patch b/Spigot-Server-Patches/Waving-banner-workaround.patch index e5bea7890b..29a8e4e51f 100644 --- a/Spigot-Server-Patches/Waving-banner-workaround.patch +++ b/Spigot-Server-Patches/Waving-banner-workaround.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Waving banner workaround This patch is a workaround for MC-63720 diff --git a/src/main/java/net/minecraft/server/PacketPlayOutUpdateTime.java b/src/main/java/net/minecraft/server/PacketPlayOutUpdateTime.java -index c5c3f40ce0..6413f76e78 100644 +index 88c3d7efaf..15af5927f3 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutUpdateTime.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutUpdateTime.java @@ -0,0 +0,0 @@ import java.io.IOException; @@ -32,5 +32,5 @@ index c5c3f40ce0..6413f76e78 100644 + // Paper end } - public void a(PacketDataSerializer packetdataserializer) throws IOException { + @Override -- \ No newline at end of file diff --git a/Spigot-Server-Patches/handle-NaN-health-absorb-values-and-repair-bad-data.patch b/Spigot-Server-Patches/handle-NaN-health-absorb-values-and-repair-bad-data.patch index fd42e7db7d..4e929e68be 100644 --- a/Spigot-Server-Patches/handle-NaN-health-absorb-values-and-repair-bad-data.patch +++ b/Spigot-Server-Patches/handle-NaN-health-absorb-values-and-repair-bad-data.patch @@ -5,12 +5,12 @@ Subject: [PATCH] handle NaN health/absorb values and repair bad data diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index a12cc1e92f..2454083b2d 100644 +index 44570edcae..5ae7014887 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - } + @Override public void a(NBTTagCompound nbttagcompound) { - this.setAbsorptionHearts(nbttagcompound.getFloat("AbsorptionAmount")); + // Paper start - jvm keeps optimizing the setter @@ -44,7 +44,7 @@ index a12cc1e92f..2454083b2d 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5b9f2dd4a6..d0f8ad0b69 100644 +index 326200fd58..e866480f04 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {