From a64c1a03c9bb616c7d55b54b427a450604fe9ac3 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 24 Apr 2019 02:00:24 +0100 Subject: [PATCH] More work towards 1.14 pre5 --- .../0002-Paper-config-files.patch | 16 +- Spigot-Server-Patches/0004-MC-Utils.patch | 6 +- ...-MinecraftKey-Information-to-Objects.patch | 44 +- ...to-current-Chunk-for-Entity-and-Bloc.patch | 95 +- ...ts-for-each-Entity-Block-Entity-Type.patch | 14 +- Spigot-Server-Patches/0009-Timings-v2.patch | 905 ++++++++---------- ...ctus-and-reed-natural-growth-heights.patch | 10 +- ...figurable-baby-zombie-movement-speed.patch | 26 +- ...012-Configurable-fishing-time-ranges.patch | 16 +- .../0013-Allow-nerfed-mobs-to-jump.patch | 30 +- ...-despawn-distances-for-living-entiti.patch | 23 +- ...5-Allow-for-toggling-of-spawn-chunks.patch | 10 +- ...ck-and-tnt-entities-at-the-specified.patch | 52 +- ...ient-crashes-server-lists-and-Mojang.patch | 40 +- .../0018-Player-affects-spawning-API.patch | 66 +- ...ve-invalid-mob-spawner-tile-entities.patch | 10 +- .../0020-Optimize-TileEntity-Ticking.patch | 127 ++- scripts/importmcdev.sh | 1 - work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 21 files changed, 647 insertions(+), 850 deletions(-) diff --git a/Spigot-Server-Patches/0002-Paper-config-files.patch b/Spigot-Server-Patches/0002-Paper-config-files.patch index edcc15c03..eedae5688 100644 --- a/Spigot-Server-Patches/0002-Paper-config-files.patch +++ b/Spigot-Server-Patches/0002-Paper-config-files.patch @@ -1,4 +1,4 @@ -From a3b9b3e93ec4c99f6bdd845a923c4ee057801b78 Mon Sep 17 00:00:00 2001 +From c94a16a6e4f1498e7bc54b2043915211a590b586 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 29 Feb 2016 21:02:09 -0600 Subject: [PATCH] Paper config files @@ -596,10 +596,10 @@ index f31f407fa1..28fa346b7f 100644 this.world = new CraftWorld((WorldServer) this, gen, env); this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 142b4a3a17..60a5ba6c73 100644 +index 83ab4245da..93246f464b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -727,6 +727,7 @@ public final class CraftServer implements Server { +@@ -751,6 +751,7 @@ public final class CraftServer implements Server { } org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot @@ -607,7 +607,7 @@ index 142b4a3a17..60a5ba6c73 100644 for (WorldServer world : console.getWorlds()) { world.worldData.setDifficulty(config.difficulty); world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); -@@ -742,6 +743,7 @@ public final class CraftServer implements Server { +@@ -766,6 +767,7 @@ public final class CraftServer implements Server { world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns(); } world.spigotConfig.init(); // Spigot @@ -615,7 +615,7 @@ index 142b4a3a17..60a5ba6c73 100644 } pluginManager.clearPlugins(); -@@ -749,6 +751,7 @@ public final class CraftServer implements Server { +@@ -773,6 +775,7 @@ public final class CraftServer implements Server { resetRecipes(); reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot @@ -623,7 +623,7 @@ index 142b4a3a17..60a5ba6c73 100644 overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); ignoreVanillaPermissions = commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -1925,4 +1928,26 @@ public final class CraftServer implements Server { +@@ -1949,4 +1952,26 @@ public final class CraftServer implements Server { { return spigot; } @@ -651,10 +651,10 @@ index 142b4a3a17..60a5ba6c73 100644 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index c9668afc65..3e7024780b 100644 +index b61c06e32a..e34abd0c1f 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -128,6 +128,14 @@ public class Main { +@@ -127,6 +127,14 @@ public class Main { .defaultsTo(new File("spigot.yml")) .describedAs("Yml file"); // Spigot End diff --git a/Spigot-Server-Patches/0004-MC-Utils.patch b/Spigot-Server-Patches/0004-MC-Utils.patch index dcb2efdbb..8cb5d2666 100644 --- a/Spigot-Server-Patches/0004-MC-Utils.patch +++ b/Spigot-Server-Patches/0004-MC-Utils.patch @@ -1,4 +1,4 @@ -From 8da836e8eedeba7af28f6260fa2084de50ec23ee Mon Sep 17 00:00:00 2001 +From 134acc6c6f13c7533bbf99adc73fc208aec957e9 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:55:47 -0400 Subject: [PATCH] MC Utils @@ -837,10 +837,10 @@ index ea90a01830..59e7d907ef 100644 if (throwable != null) { completablefuture.completeExceptionally(throwable); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index c4aa0152c8..6e44e58c58 100644 +index 73dd802205..9ed7f8ede4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -91,6 +91,7 @@ public final class CraftItemStack extends ItemStack { +@@ -85,6 +85,7 @@ public final class CraftItemStack extends ItemStack { } net.minecraft.server.ItemStack handle; diff --git a/Spigot-Server-Patches/0006-Add-MinecraftKey-Information-to-Objects.patch b/Spigot-Server-Patches/0006-Add-MinecraftKey-Information-to-Objects.patch index 7eac81ad3..99cc95d2e 100644 --- a/Spigot-Server-Patches/0006-Add-MinecraftKey-Information-to-Objects.patch +++ b/Spigot-Server-Patches/0006-Add-MinecraftKey-Information-to-Objects.patch @@ -1,4 +1,4 @@ -From f01b6961ade709b2e4076e4c8bc65ca191af034d Mon Sep 17 00:00:00 2001 +From 46fe3ad03c1a6e865b265c93a1d00dc98c5e7be4 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 01:40:13 -0400 Subject: [PATCH] Add MinecraftKey Information to Objects @@ -19,10 +19,10 @@ index 2e79b0b5ff..f38179e983 100644 MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index cd998fcfb5..d9c9748cec 100644 +index cec990f357..d636965800 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -44,7 +44,7 @@ import org.bukkit.event.entity.EntityPortalEvent; +@@ -47,7 +47,7 @@ import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.plugin.PluginManager; // CraftBukkit end @@ -31,16 +31,7 @@ index cd998fcfb5..d9c9748cec 100644 // CraftBukkit start private static final int CURRENT_LEVEL = 2; -@@ -72,7 +72,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener { - private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - private static double c = 1.0D; - private static int entityCount; -- private final EntityTypes g; -+ private final EntityTypes g; public EntityTypes getEntityType() { return g; } // Paper - OBFHELPER - private int id; - public boolean j; - public final List passengers; -@@ -1775,12 +1775,29 @@ public abstract class Entity implements INamableTileEntity, ICommandListener { +@@ -1664,12 +1664,31 @@ public abstract class Entity implements INamableTileEntity, ICommandListener { return true; } @@ -64,27 +55,26 @@ index cd998fcfb5..d9c9748cec 100644 + } @Nullable public final String getSaveID() { -- EntityTypes entitytypes = this.P(); -- MinecraftKey minecraftkey = EntityTypes.getName(entitytypes); -- + EntityTypes entitytypes = this.getEntityType(); + MinecraftKey minecraftkey = EntityTypes.getName(entitytypes); + - return entitytypes.a() && minecraftkey != null ? minecraftkey.toString() : null; -+ EntityTypes type = this.getEntityType(); -+ return type != null && type.isPersistable() ? getMinecraftKeyString() : null; ++ return entitytypes != null && entitytypes.isPersistable() ? getMinecraftKeyString() : null; + // Paper end } protected abstract void a(NBTTagCompound nbttagcompound); diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index a07ee150c2..d74bfa1201 100644 +index 0f2604a3d5..fae259ac70 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java -@@ -240,6 +240,7 @@ public class EntityTypes { +@@ -238,6 +238,7 @@ public class EntityTypes { } } + public boolean isPersistable() { return a(); } // Paper - OBFHELPER public boolean a() { - return this.aU; + return this.bb; } diff --git a/src/main/java/net/minecraft/server/KeyedObject.java b/src/main/java/net/minecraft/server/KeyedObject.java new file mode 100644 @@ -102,7 +92,7 @@ index 0000000000..743142d030 + } +} diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 62b6e6eb38..7390061bf0 100644 +index df46dbcacc..319be67501 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -7,11 +7,11 @@ import org.apache.logging.log4j.Logger; @@ -114,13 +104,13 @@ index 62b6e6eb38..7390061bf0 100644 public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot private static final Logger a = LogManager.getLogger(); -- private final TileEntityTypes e; -+ private final TileEntityTypes e; public TileEntityTypes getTileEntityType() { return e; } // Paper - OBFHELPER +- private final TileEntityTypes b; ++ private final TileEntityTypes b; public TileEntityTypes getTileEntityType() { return b; } // Paper - OBFHELPER + @Nullable protected World world; protected BlockPosition position; - protected boolean d; -@@ -23,6 +23,26 @@ public abstract class TileEntity { - this.e = tileentitytypes; +@@ -24,6 +24,26 @@ public abstract class TileEntity { + this.b = tileentitytypes; } + // Paper start diff --git a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch index ec3d5bac9..2db09b319 100644 --- a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch +++ b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch @@ -1,4 +1,4 @@ -From b62193df23ee54b4b15077fd0ac4939003ac99aa Mon Sep 17 00:00:00 2001 +From 117ce0bb3764d81b944e8a9455f9da22c01d732c Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 02:10:36 -0400 Subject: [PATCH] Store reference to current Chunk for Entity and Block @@ -8,22 +8,25 @@ This enables us a fast reference to the entities current chunk instead of having to look it up by hashmap lookups. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 417c015e56..95a51ab745 100644 +index 0f031e862b..7fa141f52c 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -36,7 +36,7 @@ public class Chunk implements IChunkAccess { - private final BiomeBase[] f; - private final boolean[] g; - private final Map h; -- private boolean i; -+ private boolean i;public boolean isLoaded() { return i; } // Paper - OBFHELPER + private final ChunkSection[] sections; + private final BiomeBase[] d; + private final Map e; +- public boolean loaded; ++ public boolean loaded; public boolean isLoaded() { return loaded; } // Paper - OBFHELPER public final World world; public final Map heightMap; - public final int locX; -@@ -66,7 +66,30 @@ public class Chunk implements IChunkAccess { - // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking - private int neighbors = 0x1 << 12; - public long chunkKey; + private final ChunkConverter i; +@@ -58,11 +58,39 @@ public class Chunk implements IChunkAccess { + private final ChunkCoordIntPair loc; + private volatile boolean x; + ++ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking ++ private int neighbors = 0x1 << 12; ++ public long chunkKey; + // Paper start + private class TileEntityHashMap extends java.util.HashMap { + @Override @@ -37,7 +40,7 @@ index 417c015e56..95a51ab745 100644 + } + return replaced; + } - ++ + @Override + public TileEntity remove(Object key) { + TileEntity removed = super.remove(key); @@ -48,27 +51,25 @@ index 417c015e56..95a51ab745 100644 + } + } + // Paper end - public boolean areNeighborsLoaded(final int radius) { - switch (radius) { - case 2: -@@ -97,7 +120,7 @@ public class Chunk implements IChunkAccess { - this.g = new boolean[256]; - this.h = Maps.newHashMap(); ++ + public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer consumer) { + this.sections = new ChunkSection[16]; + this.e = Maps.newHashMap(); this.heightMap = Maps.newEnumMap(HeightMap.Type.class); - this.tileEntities = Maps.newHashMap(); + this.tileEntities = new TileEntityHashMap(); // Paper - this.p = Maps.newHashMap(); - this.q = Maps.newHashMap(); - this.r = new ShortList[16]; -@@ -653,6 +676,7 @@ public class Chunk implements IChunkAccess { + this.l = Maps.newHashMap(); + this.m = Maps.newHashMap(); + this.n = new ShortList[16]; +@@ -357,6 +385,7 @@ public class Chunk implements IChunkAccess { } entity.inChunk = true; + entity.setCurrentChunk(this); // Paper - entity.chunkX = this.locX; + entity.chunkX = this.loc.x; entity.chunkY = k; - entity.chunkZ = this.locZ; -@@ -663,6 +687,7 @@ public class Chunk implements IChunkAccess { + entity.chunkZ = this.loc.z; +@@ -368,6 +397,7 @@ public class Chunk implements IChunkAccess { ((HeightMap) this.heightMap.get(heightmap_type)).a(along); } @@ -76,7 +77,7 @@ index 417c015e56..95a51ab745 100644 public void b(Entity entity) { this.a(entity, entity.chunkY); } -@@ -675,8 +700,12 @@ public class Chunk implements IChunkAccess { +@@ -380,8 +410,12 @@ public class Chunk implements IChunkAccess { if (i >= this.entitySlices.length) { i = this.entitySlices.length - 1; } @@ -90,21 +91,21 @@ index 417c015e56..95a51ab745 100644 + // Paper end } - public boolean c(BlockPosition blockposition) { + @Override diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index d9c9748cec..bdb4ca7643 100644 +index d636965800..e2b37ed1a0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -132,7 +132,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - private static final DataWatcherObject aF = DataWatcher.a(Entity.class, DataWatcherRegistry.i); - private static final DataWatcherObject aG = DataWatcher.a(Entity.class, DataWatcherRegistry.i); - private static final DataWatcherObject aH = DataWatcher.a(Entity.class, DataWatcherRegistry.i); +@@ -131,7 +131,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + private static final DataWatcherObject aB = DataWatcher.a(Entity.class, DataWatcherRegistry.i); + private static final DataWatcherObject aC = DataWatcher.a(Entity.class, DataWatcherRegistry.i); + protected static final DataWatcherObject X = DataWatcher.a(Entity.class, DataWatcherRegistry.s); - public boolean inChunk; + public boolean inChunk; public boolean isAddedToChunk() { return inChunk; } // Paper - OBFHELPER public int chunkX; public int getChunkX() { return chunkX; } // Paper - OBFHELPER public int chunkY; public int getChunkY() { return chunkY; } // Paper - OBFHELPER public int chunkZ; public int getChunkZ() { return chunkZ; } // Paper - OBFHELPER -@@ -1776,6 +1776,39 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -1665,6 +1665,39 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } // Paper start @@ -145,10 +146,10 @@ index d9c9748cec..bdb4ca7643 100644 private String entityKeyString; diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 7390061bf0..c69209497b 100644 +index 319be67501..12f359a6ba 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java -@@ -41,6 +41,15 @@ public abstract class TileEntity implements KeyedObject { // Paper +@@ -42,6 +42,15 @@ public abstract class TileEntity implements KeyedObject { // Paper getMinecraftKey(); // Try to load if it doesn't exists. return tileEntityKeyString; } @@ -165,18 +166,26 @@ index 7390061bf0..c69209497b 100644 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 9cdd0331f4..7edbbb106b 100644 +index ee34d42160..c1ad2626a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -9,6 +9,7 @@ import java.util.UUID; - - import net.minecraft.server.*; - -+import org.bukkit.Chunk; +@@ -6,6 +6,7 @@ import com.google.common.collect.Lists; + import java.util.List; + import java.util.Set; + import java.util.UUID; ++<<<<<<< HEAD + import net.minecraft.server.AxisAlignedBB; + import net.minecraft.server.BlockPosition; + import net.minecraft.server.DamageSource; +@@ -137,6 +138,7 @@ import net.minecraft.server.EntityZombieVillager; + import net.minecraft.server.EnumChatFormat; + import net.minecraft.server.IChatBaseComponent; + import net.minecraft.server.NBTTagCompound; ++import org.bukkit.Chunk; // Paper import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Server; -@@ -44,6 +45,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -173,6 +175,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { this.entity = entity; } diff --git a/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch b/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch index 643c6d073..8ea613836 100644 --- a/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch +++ b/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch @@ -1,4 +1,4 @@ -From 9e8dc233b5846b4e81ae4964ddb0a48a75b64c23 Mon Sep 17 00:00:00 2001 +From 2976aeb8835db3b9c38ccc891e1b011dca486d42 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 02:13:59 -0400 Subject: [PATCH] Store counts for each Entity/Block Entity Type @@ -6,10 +6,10 @@ Subject: [PATCH] Store counts for each Entity/Block Entity Type Opens door for future patches to optimize performance diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 95a51ab745..554fbeb071 100644 +index 7fa141f52c..2b29fe837b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -67,15 +67,19 @@ public class Chunk implements IChunkAccess { +@@ -62,15 +62,19 @@ public class Chunk implements IChunkAccess { private int neighbors = 0x1 << 12; public long chunkKey; // Paper start @@ -29,7 +29,7 @@ index 95a51ab745..554fbeb071 100644 } return replaced; } -@@ -85,6 +89,7 @@ public class Chunk implements IChunkAccess { +@@ -80,6 +84,7 @@ public class Chunk implements IChunkAccess { TileEntity removed = super.remove(key); if (removed != null) { removed.setCurrentChunk(null); @@ -37,15 +37,15 @@ index 95a51ab745..554fbeb071 100644 } return removed; } -@@ -675,6 +680,7 @@ public class Chunk implements IChunkAccess { +@@ -384,6 +389,7 @@ public class Chunk implements IChunkAccess { k = this.entitySlices.length - 1; } + if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper entity.inChunk = true; entity.setCurrentChunk(this); // Paper - entity.chunkX = this.locX; -@@ -705,6 +711,7 @@ public class Chunk implements IChunkAccess { + entity.chunkX = this.loc.x; +@@ -415,6 +421,7 @@ public class Chunk implements IChunkAccess { if (!this.entitySlices[i].remove(entity)) { return; } diff --git a/Spigot-Server-Patches/0009-Timings-v2.patch b/Spigot-Server-Patches/0009-Timings-v2.patch index 5b69c2e7b..0d7030914 100644 --- a/Spigot-Server-Patches/0009-Timings-v2.patch +++ b/Spigot-Server-Patches/0009-Timings-v2.patch @@ -1,4 +1,4 @@ -From 4a1323b0eed07d0157b70eb57455075f172446c7 Mon Sep 17 00:00:00 2001 +From acaccffc57a71f1aa4ecc97947903de8ad5b238b Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 3 Mar 2016 04:00:11 -0600 Subject: [PATCH] Timings v2 @@ -6,10 +6,10 @@ Subject: [PATCH] Timings v2 diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java new file mode 100644 -index 0000000000..7a2a27cdb4 +index 0000000000..3f9fb6f906 --- /dev/null +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java -@@ -0,0 +1,132 @@ +@@ -0,0 +1,133 @@ +package co.aikar.timings; + +import com.google.common.collect.MapMaker; @@ -21,6 +21,7 @@ index 0000000000..7a2a27cdb4 + +import java.util.Map; + ++// TODO: Re-implement missing timers +public final class MinecraftTimings { + + public static final Timing playerListTimer = Timings.ofSafe("Player List"); @@ -144,10 +145,10 @@ index 0000000000..7a2a27cdb4 +} diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java new file mode 100644 -index 0000000000..145cb274b0 +index 0000000000..d5d3b2a20c --- /dev/null +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -@@ -0,0 +1,104 @@ +@@ -0,0 +1,105 @@ +package co.aikar.timings; + +import net.minecraft.server.World; @@ -156,6 +157,7 @@ index 0000000000..145cb274b0 +/** + * Set of timers per world, to track world specific timings. + */ ++// TODO: Re-implement missing timers +public class WorldTimingsHandler { + public final Timing mobSpawn; + public final Timing doChunkUnload; @@ -297,11 +299,11 @@ index 5518ec1e54..7691409f6c 100644 + } } diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java -index e89ba3e412..1dc13fcc30 100644 +index c6d536226b..15dac7b94e 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java -@@ -22,6 +22,15 @@ public class Block implements IMaterial { - protected final boolean i; +@@ -24,6 +24,15 @@ public class Block implements IMaterial { + protected final boolean q; protected final SoundEffectType stepSound; protected final Material material; + // Paper start @@ -313,92 +315,98 @@ index e89ba3e412..1dc13fcc30 100644 + return timing; + } + // Paper end - protected final MaterialMapColor l; + protected final MaterialMapColor t; private final float frictionFactor; protected final BlockStateList blockStateList; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 554fbeb071..2b1198ca8f 100644 +index 2b29fe837b..89bce93c61 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -853,6 +853,7 @@ public class Chunk implements IChunkAccess { +@@ -89,6 +89,29 @@ public class Chunk implements IChunkAccess { + return removed; + } + } ++ public boolean areNeighborsLoaded(final int radius) { ++ switch (radius) { ++ case 2: ++ return this.neighbors == Integer.MAX_VALUE >> 6; ++ case 1: ++ final int mask = ++ // x z offset x z offset x z offset ++ (0x1 << (1 * 5 + 1 + 12)) | (0x1 << (0 * 5 + 1 + 12)) | (0x1 << (-1 * 5 + 1 + 12)) | ++ (0x1 << (1 * 5 + 0 + 12)) | (0x1 << (0 * 5 + 0 + 12)) | (0x1 << (-1 * 5 + 0 + 12)) | ++ (0x1 << (1 * 5 + -1 + 12)) | (0x1 << (0 * 5 + -1 + 12)) | (0x1 << (-1 * 5 + -1 + 12)); ++ return (this.neighbors & mask) == mask; ++ default: ++ throw new UnsupportedOperationException(String.valueOf(radius)); ++ } ++ } ++ ++ public void setNeighborLoaded(final int x, final int z) { ++ this.neighbors |= 0x1 << (x * 5 + 12 + z); ++ } ++ ++ public void setNeighborUnloaded(final int x, final int z) { ++ this.neighbors &= ~(0x1 << (x * 5 + 12 + z)); ++ } + // Paper end + + public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer consumer) { +@@ -546,6 +569,7 @@ public class Chunk implements IChunkAccess { server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); if (this.needsDecoration) { + this.world.timings.syncChunkLoadPopulateTimer.startTiming(); // Paper - BlockSand.instaFall = true; java.util.Random random = new java.util.Random(); random.setSeed(world.getSeed()); -@@ -873,6 +874,7 @@ public class Chunk implements IChunkAccess { + long xRand = random.nextLong() / 2L * 2L + 1L; +@@ -564,6 +588,7 @@ public class Chunk implements IChunkAccess { + } } - BlockSand.instaFall = false; server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); + this.world.timings.syncChunkLoadPopulateTimer.stopTiming(); // Paper } } - // CraftBukkit end -diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java -index df2711a5f8..732c8793e5 100644 ---- a/src/main/java/net/minecraft/server/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/ChunkMap.java -@@ -14,6 +14,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap { } - - public Chunk put(long i, Chunk chunk) { -+ chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper - Chunk chunk1 = (Chunk) super.put(i, chunk); - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i); - -@@ -46,6 +47,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap { - } - } - } -+ chunk.world.timings.syncChunkLoadPostTimer.stopTiming(); // Paper - // CraftBukkit end - - return chunk1; diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index a8cdcb7da8..eb83e20d50 100644 +index 416f8e080c..5ee9824ba2 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -88,7 +88,7 @@ public class ChunkProviderServer implements IChunkProvider { - } - - if (flag) { -- try { -+ try (co.aikar.timings.Timing timing = world.timings.syncChunkLoadTimer.startTiming()) { // Paper - chunk = this.chunkLoader.a(this.world, i, j, (chunk1) -> { - chunk1.setLastSaved(this.world.getTime()); - this.chunks.put(ChunkCoordIntPair.a(i, j), chunk1); -@@ -103,8 +103,7 @@ public class ChunkProviderServer implements IChunkProvider { - this.asyncTaskHandler.postToMainThread(chunk::addEntities); - return chunk; - } else if (flag1) { -- try { -- world.timings.syncChunkLoadTimer.startTiming(); // Spigot -+ try (co.aikar.timings.Timing timing = world.timings.chunkGeneration.startTiming()) { // Paper - this.batchScheduler.b(); - this.batchScheduler.a(new ChunkCoordIntPair(i, j)); - CompletableFuture completablefuture = this.batchScheduler.c(); -@@ -113,7 +112,7 @@ public class ChunkProviderServer implements IChunkProvider { - } catch (RuntimeException runtimeexception) { - throw this.a(i, j, (Throwable) runtimeexception); - } -- finally { world.timings.syncChunkLoadTimer.stopTiming(); } // Spigot -+ // finally { world.timings.syncChunkLoadTimer.stopTiming(); } // Spigot // Paper - } else { - return null; - } -@@ -206,7 +205,7 @@ public class ChunkProviderServer implements IChunkProvider { +@@ -186,7 +186,9 @@ public class ChunkProviderServer extends IChunkProvider { } - public void saveChunk(IChunkAccess ichunkaccess, boolean unloaded) { // Spigot -- try { + public void save(boolean flag) { + try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { // Paper - Timings - ichunkaccess.setLastSaved(this.world.getTime()); - this.chunkLoader.saveChunk(this.world, ichunkaccess, unloaded); // Spigot - } catch (IOException ioexception) { + this.playerChunkMap.save(flag); ++ } // Paper - Timings + } + + @Override +@@ -296,10 +298,9 @@ public class ChunkProviderServer extends IChunkProvider { + this.world.timings.mobSpawn.stopTiming(); // Spigot + this.world.getMethodProfiler().exit(); + } +- +- this.world.timings.doTickTiles.startTiming(); // Spigot ++ this.world.timings.chunkTicks.startTiming(); // Spigot // Paper + this.world.a(chunk, l); +- this.world.timings.doTickTiles.stopTiming(); // Spigot ++ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper + } + } + } +@@ -310,9 +311,7 @@ public class ChunkProviderServer extends IChunkProvider { + } + } + +- this.world.timings.tracker.startTiming(); // Spigot + this.playerChunkMap.g(); +- this.world.timings.tracker.stopTiming(); // Spigot + } + + @Override diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 8e5ce6c181..35976a26f3 100644 +index c91347c644..8ac0e67e35 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -1,5 +1,6 @@ @@ -406,10 +414,10 @@ index 8e5ce6c181..35976a26f3 100644 +import co.aikar.timings.Timings; import com.google.common.collect.Maps; - import com.mojang.datafixers.DataFixTypes; - import com.mojang.datafixers.DataFixer; -@@ -672,7 +673,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - public void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) { + import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + import it.unimi.dsi.fastutil.longs.LongSet; +@@ -412,7 +413,7 @@ public class ChunkRegionLoader { + private static void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) { NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10); World world = chunk.getWorld(); - world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot @@ -417,8 +425,8 @@ index 8e5ce6c181..35976a26f3 100644 for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i); -@@ -681,8 +682,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - chunk.f(true); +@@ -424,8 +425,6 @@ public class ChunkRegionLoader { + chunk.d(true); } - world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot @@ -426,7 +434,7 @@ index 8e5ce6c181..35976a26f3 100644 NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10); for (int j = 0; j < nbttaglist1.size(); ++j) { -@@ -699,8 +698,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { +@@ -442,8 +441,6 @@ public class ChunkRegionLoader { } } } @@ -435,7 +443,7 @@ index 8e5ce6c181..35976a26f3 100644 if (nbttagcompound.hasKeyOfType("TileTicks", 9) && world.getBlockTickList() instanceof TickListServer) { ((TickListServer) world.getBlockTickList()).a(nbttagcompound.getList("TileTicks", 10)); -@@ -709,7 +706,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { +@@ -452,7 +449,7 @@ public class ChunkRegionLoader { if (nbttagcompound.hasKeyOfType("LiquidTicks", 9) && world.getFluidTickList() instanceof TickListServer) { ((TickListServer) world.getFluidTickList()).a(nbttagcompound.getList("LiquidTicks", 10)); } @@ -445,10 +453,10 @@ index 8e5ce6c181..35976a26f3 100644 } diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java -index 65574eb2e5..bc87cfc4b6 100644 +index 46e7737ca3..a3ef943066 100644 --- a/src/main/java/net/minecraft/server/CustomFunction.java +++ b/src/main/java/net/minecraft/server/CustomFunction.java -@@ -12,12 +12,22 @@ public class CustomFunction { +@@ -13,12 +13,22 @@ public class CustomFunction { private final CustomFunction.c[] a; private final MinecraftKey b; @@ -472,10 +480,10 @@ index 65574eb2e5..bc87cfc4b6 100644 return this.b; } diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java -index f28f4f3cd3..6b417be1dd 100644 +index ed4b189d7e..2d2a4c9825 100644 --- a/src/main/java/net/minecraft/server/CustomFunctionData.java +++ b/src/main/java/net/minecraft/server/CustomFunctionData.java -@@ -100,7 +100,7 @@ public class CustomFunctionData implements ITickable, IResourcePackListener { +@@ -100,7 +100,7 @@ public class CustomFunctionData implements IResourcePackListener { return 0; } else { @@ -485,10 +493,10 @@ index f28f4f3cd3..6b417be1dd 100644 int j = 0; CustomFunction.c[] acustomfunction_c = customfunction.b(); diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index ad9c00bc80..4e9ef43b45 100644 +index b60956218d..19e2df3098 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java -@@ -29,7 +29,7 @@ import org.apache.logging.log4j.Level; +@@ -31,7 +31,7 @@ import org.apache.logging.log4j.Level; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.LoggerOutputStream; @@ -497,7 +505,7 @@ index ad9c00bc80..4e9ef43b45 100644 import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.server.RemoteServerCommandEvent; -@@ -454,7 +454,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer +@@ -428,7 +428,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public void handleCommandQueue() { @@ -506,7 +514,7 @@ index ad9c00bc80..4e9ef43b45 100644 while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); -@@ -469,7 +469,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer +@@ -443,7 +443,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer // CraftBukkit end } @@ -514,8 +522,8 @@ index ad9c00bc80..4e9ef43b45 100644 + MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot } - public boolean Q() { -@@ -718,7 +718,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer + @Override +@@ -681,7 +681,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer return remoteControlCommandListener.getMessages(); } }; @@ -538,10 +546,10 @@ index ad9c00bc80..4e9ef43b45 100644 return waitable.get(); } catch (java.util.concurrent.ExecutionException e) { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index bdb4ca7643..131946154e 100644 +index e2b37ed1a0..2d07bfa879 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -27,7 +27,8 @@ import org.bukkit.command.CommandSender; +@@ -30,7 +30,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Hanging; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Vehicle; @@ -551,7 +559,7 @@ index bdb4ca7643..131946154e 100644 import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; -@@ -158,7 +159,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -159,7 +160,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke public boolean valid; public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only public boolean forceExplosionKnockback; // SPIGOT-949 @@ -560,27 +568,27 @@ index bdb4ca7643..131946154e 100644 // Spigot start public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); public final boolean defaultActivationState; -@@ -551,7 +552,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -475,7 +476,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } - public void move(EnumMoveType enummovetype, double d0, double d1, double d2) { + public void move(EnumMoveType enummovetype, Vec3D vec3d) { - org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot if (this.noclip) { - this.a(this.getBoundingBox().d(d0, d1, d2)); + this.a(this.getBoundingBox().b(vec3d)); this.recalcPosition(); -@@ -901,7 +901,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -640,7 +640,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke - this.world.methodProfiler.exit(); + this.world.getMethodProfiler().exit(); } - org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot } - protected float ab() { + protected Vec3D a(Vec3D vec3d, EnumMoveType enummovetype) { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 011c7af218..b092b0fa23 100644 +index d31c1c989c..d89dbf1745 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -32,7 +32,7 @@ import org.bukkit.event.entity.EntityTeleportEvent; +@@ -35,7 +35,7 @@ import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; // CraftBukkit end @@ -589,15 +597,15 @@ index 011c7af218..b092b0fa23 100644 public abstract class EntityLiving extends Entity { -@@ -2024,7 +2024,6 @@ public abstract class EntityLiving extends Entity { - } +@@ -2208,7 +2208,6 @@ public abstract class EntityLiving extends Entity { + @Override public void tick() { - SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot super.tick(); - this.cV(); + this.dk(); this.o(); -@@ -2095,9 +2094,7 @@ public abstract class EntityLiving extends Entity { +@@ -2283,9 +2282,7 @@ public abstract class EntityLiving extends Entity { } } @@ -607,94 +615,64 @@ index 011c7af218..b092b0fa23 100644 double d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f = (float) (d0 * d0 + d1 * d1); -@@ -2173,8 +2170,6 @@ public abstract class EntityLiving extends Entity { - } else { - this.bv = 0; +@@ -2365,8 +2362,6 @@ public abstract class EntityLiving extends Entity { + if (this.isSleeping()) { + this.pitch = 0.0F; } - - SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot } protected float e(float f, float f1) { -@@ -2244,7 +2239,6 @@ public abstract class EntityLiving extends Entity { - } +@@ -2440,7 +2435,6 @@ public abstract class EntityLiving extends Entity { - this.world.methodProfiler.enter("ai"); + this.setMot(d4, d5, d6); + this.world.getMethodProfiler().enter("ai"); - SpigotTimings.timerEntityAI.startTiming(); // Spigot if (this.isFrozen()) { - this.bg = false; - this.bh = 0.0F; -@@ -2255,7 +2249,6 @@ public abstract class EntityLiving extends Entity { + this.jumping = false; + this.bb = 0.0F; +@@ -2451,7 +2445,6 @@ public abstract class EntityLiving extends Entity { this.doTick(); - this.world.methodProfiler.exit(); + this.world.getMethodProfiler().exit(); } - SpigotTimings.timerEntityAI.stopTiming(); // Spigot - this.world.methodProfiler.exit(); - this.world.methodProfiler.enter("jump"); -@@ -2280,9 +2273,7 @@ public abstract class EntityLiving extends Entity { + this.world.getMethodProfiler().exit(); + this.world.getMethodProfiler().enter("jump"); +@@ -2476,9 +2469,7 @@ public abstract class EntityLiving extends Entity { this.n(); AxisAlignedBB axisalignedbb = this.getBoundingBox(); - SpigotTimings.timerEntityAIMove.startTiming(); // Spigot - this.a(this.bh, this.bi, this.bj); + this.e(new Vec3D((double) this.bb, (double) this.bc, (double) this.bd)); - SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot - this.world.methodProfiler.exit(); - this.world.methodProfiler.enter("push"); - if (this.bw > 0) { -@@ -2290,9 +2281,7 @@ public abstract class EntityLiving extends Entity { + this.world.getMethodProfiler().exit(); + this.world.getMethodProfiler().enter("push"); + if (this.bq > 0) { +@@ -2486,9 +2477,7 @@ public abstract class EntityLiving extends Entity { this.a(axisalignedbb, this.getBoundingBox()); } - SpigotTimings.timerEntityAICollision.startTiming(); // Spigot - this.cN(); + this.collideNearby(); - SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot - this.world.methodProfiler.exit(); - } - -diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java -index cd462f7dfc..45ab33d1ae 100644 ---- a/src/main/java/net/minecraft/server/EntityTracker.java -+++ b/src/main/java/net/minecraft/server/EntityTracker.java -@@ -168,7 +168,7 @@ public class EntityTracker { - public void updatePlayers() { - List list = Lists.newArrayList(); - Iterator iterator = this.c.iterator(); -- -+ world.timings.tracker1.startTiming(); // Paper - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - -@@ -181,7 +181,9 @@ public class EntityTracker { - } - } - } -+ world.timings.tracker1.stopTiming(); // Paper - -+ world.timings.tracker2.startTiming(); // Paper - for (int i = 0; i < list.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) list.get(i); - Iterator iterator1 = this.c.iterator(); -@@ -194,6 +196,7 @@ public class EntityTracker { - } - } - } -+ world.timings.tracker2.stopTiming(); // Paper - + this.world.getMethodProfiler().exit(); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 72de40434f..7e89d7158b 100644 +index e35d4808bf..7b102e155d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1,5 +1,6 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; +import co.aikar.timings.Timings; - import com.google.common.base.Stopwatch; ++import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -@@ -62,8 +63,8 @@ import org.bukkit.craftbukkit.CraftServer; + import com.google.gson.JsonElement; +@@ -54,8 +56,8 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.Main; import org.bukkit.event.server.ServerLoadEvent; // CraftBukkit end @@ -702,9 +680,9 @@ index 72de40434f..7e89d7158b 100644 import org.spigotmc.SlackActivityAccountant; // Spigot +import co.aikar.timings.MinecraftTimings; // Paper - public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable { -@@ -616,6 +617,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati +@@ -659,6 +661,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit - SpigotTimings.worldSaveTimer.startTiming(); // Spigot + MinecraftServer.LOGGER.debug("Autosave started"); this.methodProfiler.enter("save"); this.playerList.savePlayers(); - // Spigot Start -@@ -859,7 +860,6 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati - // this.saveChunks(true); - // Spigot End + this.saveChunks(true, false, false); this.methodProfiler.exit(); + MinecraftServer.LOGGER.debug("Autosave finished"); - SpigotTimings.worldSaveTimer.stopTiming(); // Spigot } this.methodProfiler.enter("snooper"); -@@ -880,14 +880,14 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati +@@ -980,29 +981,28 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 8000L) { -+ try (Timing ignored = world.timings.doChunkMapUpdate.startTiming()) { // Paper - this.k = i; - - for (j = 0; j < this.i.size(); ++j) { -@@ -91,9 +93,11 @@ public class PlayerChunkMap { - playerchunk.d(); - playerchunk.c(); - } -+ } // Paper timing - } - - if (!this.f.isEmpty()) { -+ try (Timing ignored = world.timings.doChunkMapToUpdate.startTiming()) { // Paper - Iterator iterator = this.f.iterator(); - - while (iterator.hasNext()) { -@@ -102,23 +106,29 @@ public class PlayerChunkMap { - } - - this.f.clear(); -+ } // Paper timing - } - - if (this.l && i % 4L == 0L) { - this.l = false; -+ try (Timing ignored = world.timings.doChunkMapSortMissing.startTiming()) { // Paper - Collections.sort(this.h, (playerchunk1, playerchunk2) -> { - return ComparisonChain.start().compare(playerchunk1.g(), playerchunk2.g()).result(); - }); -+ } // Paper timing - } - - if (this.m && i % 4L == 2L) { - this.m = false; -+ try (Timing ignored = world.timings.doChunkMapSortSendToPlayers.startTiming()) { // Paper - Collections.sort(this.g, (playerchunk1, playerchunk2) -> { - return ComparisonChain.start().compare(playerchunk1.g(), playerchunk2.g()).result(); - }); -+ } // Paper timing - } - - if (!this.h.isEmpty()) { -+ try (Timing ignored = world.timings.doChunkMapPlayersNeedingChunks.startTiming()) { // Paper - // Spigot start - org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant; - activityAccountant.startActivity(0.5); -@@ -150,10 +160,12 @@ public class PlayerChunkMap { - } - - activityAccountant.endActivity(); // Spigot -+ } // Paper timing - } - - if (!this.g.isEmpty()) { - j = 81; -+ try (Timing ignored = world.timings.doChunkMapPendingSendToPlayers.startTiming()) { // Paper - Iterator iterator2 = this.g.iterator(); - - while (iterator2.hasNext()) { -@@ -167,14 +179,17 @@ public class PlayerChunkMap { - } + import com.google.common.collect.Sets; + import com.mojang.datafixers.DataFixer; +@@ -248,6 +250,23 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + playerchunk = new PlayerChunk(new ChunkCoordIntPair(i), j, this.lightEngine, this.q, this); } + ++ // TODO: VERIFY THIS ++ ChunkCoordIntPair currentChunkPair = new ChunkCoordIntPair(i); ++ for (int x = -2; x < 3; x++) { ++ for (int z = -2; z < 3; z++) { ++ if (x == 0 && z == 0) { ++ continue; ++ } ++ ++ ++ Chunk neighbor = getUpdatingChunk(ChunkCoordIntPair.pair(currentChunkPair.x + x, currentChunkPair.z + z)) ++ if (neighbor != null) { ++ neighbor.setNeighborLoaded(-x, -z); ++ playerchunk.getChunk().setNeighborLoaded(x, z); ++ } ++ } ++ } ++ + this.updatingChunks.put(i, playerchunk); + this.updatingChunksModified = true; } -+ } // Paper timing - } +@@ -350,6 +369,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + this.a(i, playerchunk, event); // CraftBukkit + } else { + if (this.g.remove(i, playerchunk) && ichunkaccess != null) { ++ ++ // TODO: VERIFY THIS ++ // Paper - Update neighbor counts ++ for (int x = -2; x < 3; x++) { ++ for (int z = -2; z < 3; z++) { ++ if (x == 0 && z == 0) { ++ continue; ++ } ++ ++ ++ Chunk neighbor = ((Chunk) ichunkaccess).world.getChunkProvider().getChunkAt(event.getChunk().getX(), event.getChunk().getZ(), false); ++ if (neighbor != null) { ++ neighbor.setNeighborUnloaded(-x, -z); ++ ((Chunk) ichunkaccess).setNeighborUnloaded(x, z); ++ } ++ } ++ } ++ // Paper + // CraftBukkit start + if (event == null) { + this.saveChunk(ichunkaccess); +@@ -418,7 +455,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + }); - if (this.managedPlayers.isEmpty()) { -+ try (Timing ignored = world.timings.doChunkMapUnloadChunks.startTiming()) { // Paper - WorldProvider worldprovider = this.world.worldProvider; + return completablefuture.thenComposeAsync((either) -> { +- return (CompletableFuture) either.map((list) -> { ++ return either.map((list) -> { // Paper - Shut up. + try { + CompletableFuture> completablefuture1 = chunkstatus.a(this.world, this.chunkGenerator, this.definedStructureManager, this.lightEngine, (ichunkaccess) -> { + return this.b(playerchunk); +@@ -898,6 +935,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - if (!worldprovider.canRespawn()) { - this.world.getChunkProvider().b(); + PlayerChunkMap.EntityTracker playerchunkmap_entitytracker; + ObjectIterator objectiterator; ++ world.timings.tracker1.startTiming(); // Paper + + for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) { + playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next(); +@@ -915,9 +953,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + playerchunkmap_entitytracker.e = sectionposition1; } -+ } // Paper timing } ++ world.timings.tracker1.stopTiming(); // Paper - } + objectiterator = this.trackedEntities.values().iterator(); + ++ world.timings.tracker2.startTiming(); // Paper + while (objectiterator.hasNext()) { + playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next(); + playerchunkmap_entitytracker.track(list); diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 06f90ceca5..b9e6a3275c 100644 +index 23e37b5008..287bba3f6c 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java -@@ -58,6 +58,7 @@ import org.bukkit.inventory.CraftingInventory; +@@ -60,6 +60,7 @@ import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.util.NumberConversions; +import co.aikar.timings.MinecraftTimings; // Paper // CraftBukkit end - public class PlayerConnection implements PacketListenerPlayIn, ITickable { -@@ -135,7 +136,6 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + public class PlayerConnection implements PacketListenerPlayIn { +@@ -137,7 +138,6 @@ public class PlayerConnection implements PacketListenerPlayIn { // CraftBukkit end public void tick() { @@ -948,7 +899,7 @@ index 06f90ceca5..b9e6a3275c 100644 this.syncPosition(); this.player.playerTick(); this.player.setLocation(this.l, this.m, this.n, this.player.yaw, this.player.pitch); -@@ -208,7 +208,6 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -210,7 +210,6 @@ public class PlayerConnection implements PacketListenerPlayIn { this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0])); } @@ -956,7 +907,7 @@ index 06f90ceca5..b9e6a3275c 100644 } -@@ -1602,7 +1601,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -1648,7 +1647,7 @@ public class PlayerConnection implements PacketListenerPlayIn { // CraftBukkit end private void handleCommand(String s) { @@ -965,7 +916,7 @@ index 06f90ceca5..b9e6a3275c 100644 // CraftBukkit start - whole method if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot this.LOGGER.info(this.player.getName() + " issued server command: " + s); -@@ -1613,7 +1612,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -1659,7 +1658,7 @@ public class PlayerConnection implements PacketListenerPlayIn { this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -974,7 +925,7 @@ index 06f90ceca5..b9e6a3275c 100644 return; } -@@ -1626,7 +1625,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -1672,7 +1671,7 @@ public class PlayerConnection implements PacketListenerPlayIn { java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); return; } finally { @@ -984,10 +935,10 @@ index 06f90ceca5..b9e6a3275c 100644 // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java -index a73947d261..596aa27feb 100644 +index c8d2c81c58..aefc3eb19c 100644 --- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java +++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java -@@ -1,12 +1,19 @@ +@@ -1,5 +1,8 @@ package net.minecraft.server; +import co.aikar.timings.MinecraftTimings; // Paper @@ -995,11 +946,13 @@ index a73947d261..596aa27feb 100644 + public class PlayerConnectionUtils { - public static void ensureMainThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { + public static void ensureMainThread(Packet packet, T t0, WorldServer worldserver) throws CancelledPacketHandleException { +@@ -8,9 +11,12 @@ public class PlayerConnectionUtils { + + public static void ensureMainThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { if (!iasynctaskhandler.isMainThread()) { + Timing timing = MinecraftTimings.getPacketTiming(packet); // Paper -+ - iasynctaskhandler.postToMainThread(() -> { + iasynctaskhandler.execute(() -> { if (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect) return; // CraftBukkit + try (Timing ignored = timing.startTiming()) { // Paper packet.a(t0); @@ -1008,7 +961,7 @@ index a73947d261..596aa27feb 100644 throw CancelledPacketHandleException.INSTANCE; } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 54e44cba35..3a83819d56 100644 +index 993306e8e7..e6c03908cb 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -1,5 +1,6 @@ @@ -1018,7 +971,7 @@ index 54e44cba35..3a83819d56 100644 import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -1173,10 +1174,11 @@ public abstract class PlayerList { +@@ -888,10 +889,11 @@ public abstract class PlayerList { } public void savePlayers() { @@ -1032,10 +985,10 @@ index 54e44cba35..3a83819d56 100644 public WhiteList getWhitelist() { diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java -index 0da57948a3..6571fc5952 100644 +index 537e610797..b48e5b51a0 100644 --- a/src/main/java/net/minecraft/server/TickListServer.java +++ b/src/main/java/net/minecraft/server/TickListServer.java -@@ -24,13 +24,19 @@ public class TickListServer implements TickList { +@@ -25,13 +25,19 @@ public class TickListServer implements TickList { private final List> g = Lists.newArrayList(); private final Consumer> h; @@ -1056,37 +1009,36 @@ index 0da57948a3..6571fc5952 100644 public void a() { int i = this.nextTickList.size(); -@@ -49,7 +55,7 @@ public class TickListServer implements TickList { - } +@@ -51,6 +57,7 @@ public class TickListServer implements TickList { + + this.f.getMethodProfiler().enter("cleaning"); - this.f.methodProfiler.enter("cleaning"); -- + timingCleanup.startTiming(); // Paper NextTickListEntry nextticklistentry; // CraftBukkit - decompile error for (int j = 0; j < i; ++j) { -@@ -62,9 +68,11 @@ public class TickListServer implements TickList { +@@ -63,9 +70,11 @@ public class TickListServer implements TickList { // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList this.g.add(nextticklistentry); } + timingCleanup.stopTiming(); // Paper - this.f.methodProfiler.exit(); - this.f.methodProfiler.enter("ticking"); + this.f.getMethodProfiler().exit(); + this.f.getMethodProfiler().enter("ticking"); + timingTicking.startTiming(); // Paper Iterator iterator = this.g.iterator(); while (iterator.hasNext()) { -@@ -89,6 +97,7 @@ public class TickListServer implements TickList { +@@ -88,6 +97,7 @@ public class TickListServer implements TickList { - this.f.methodProfiler.exit(); + this.f.getMethodProfiler().exit(); this.g.clear(); + timingTicking.stopTiming(); // Paper } } diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index c69209497b..68ac014aab 100644 +index 12f359a6ba..b5e0ba3909 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -4,12 +4,13 @@ import javax.annotation.Nullable; @@ -1103,20 +1055,21 @@ index c69209497b..68ac014aab 100644 - public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot + public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper private static final Logger a = LogManager.getLogger(); - private final TileEntityTypes e; public TileEntityTypes getTileEntityType() { return e; } // Paper - OBFHELPER - protected World world; + private final TileEntityTypes b; public TileEntityTypes getTileEntityType() { return b; } // Paper - OBFHELPER + @Nullable diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 9d5b3958bf..ad792af2bc 100644 +index 28fa346b7f..eabcab0244 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -1,5 +1,6 @@ - package net.minecraft.server; +@@ -1,5 +1,7 @@ + package net.minecraft.server; ++import co.aikar.timings.Timing; +import co.aikar.timings.Timings; - import com.google.common.base.MoreObjects; import com.google.common.collect.Lists; - import it.unimi.dsi.fastutil.longs.LongSet; -@@ -24,7 +25,6 @@ import java.util.ArrayList; + import java.io.IOException; + import java.util.Collection; +@@ -20,7 +22,6 @@ import java.util.ArrayList; import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.block.BlockState; @@ -1124,202 +1077,132 @@ index 9d5b3958bf..ad792af2bc 100644 import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlockState; -@@ -132,7 +132,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc +@@ -88,7 +89,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper - public final SpigotTimings.WorldTimingsHandler timings; // Spigot + public final co.aikar.timings.WorldTimingsHandler timings; // Paper - private boolean guardEntityList; // Spigot public static BlockPosition lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; -@@ -200,7 +200,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + private org.spigotmc.TickLimiter tileLimiter; +@@ -150,7 +151,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + public void c(WorldBorder worldborder, double d0) {} }); - this.getServer().addWorld(this.world); // CraftBukkit end - timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings + timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings - this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); + this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); } -@@ -1081,6 +1081,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - } - - this.methodProfiler.exitEnter("remove"); -+ timings.entityRemoval.startTiming(); // Paper - this.entityList.removeAll(this.g); - - int j; -@@ -1101,6 +1102,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - - this.g.clear(); - this.p_(); -+ timings.entityRemoval.stopTiming(); // Paper - this.methodProfiler.exitEnter("regular"); - - CrashReport crashreport1; -@@ -1110,6 +1112,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - timings.entityTick.startTiming(); // Spigot - guardEntityList = true; // Spigot - // CraftBukkit start - Use field for loop variable -+ co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Paper - int entitiesThisCycle = 0; - if (tickPosition < 0) tickPosition = 0; - for (entityLimiter.initTick(); -@@ -1131,10 +1134,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - this.methodProfiler.enter("tick"); - if (!entity.dead && !(entity instanceof EntityPlayer)) { - try { -- SpigotTimings.tickEntityTimer.startTiming(); // Spigot -+ entity.tickTimer.startTiming(); // Paper - this.g(entity); -- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot -+ entity.tickTimer.stopTiming(); // Paper - } catch (Throwable throwable1) { -+ entity.tickTimer.stopTiming(); - crashreport1 = CrashReport.a(throwable1, "Ticking entity"); - crashreportsystemdetails1 = crashreport1.a("Entity being ticked"); - entity.appendEntityCrashDetails(crashreportsystemdetails1); -@@ -1259,6 +1263,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc +@@ -733,14 +734,14 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose } timings.tileEntityPending.stopTiming(); // Spigot + co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper - this.methodProfiler.exit(); - this.methodProfiler.exit(); - } -@@ -1317,7 +1322,6 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - } - // CraftBukkit end - -- entity.tickTimer.startTiming(); // Spigot - entity.N = entity.locX; - entity.O = entity.locY; - entity.P = entity.locZ; -@@ -1325,6 +1329,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - entity.lastPitch = entity.pitch; - if (flag && entity.inChunk) { - ++entity.ticksLived; -+ ++co.aikar.timings.TimingHistory.activatedEntityTicks; // Paper - if (entity.isPassenger()) { - entity.aH(); - } else { -@@ -1388,8 +1393,6 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - } - } - } -- entity.tickTimer.stopTiming(); // Spigot -- + gameprofilerfiller.exit(); + spigotConfig.currentPrimedTnt = 0; // Spigot } - public boolean a(@Nullable Entity entity, VoxelShape voxelshape) { + public void a(Consumer consumer, Entity entity) { + try { +- // Spigot start +- SpigotTimings.tickEntityTimer.startTiming(); ++ timings.tickEntities.startTiming(); + entity.tickTimer.startTiming(); + // Spigot end + consumer.accept(entity); +@@ -754,7 +755,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + // Spigot start + finally { + entity.tickTimer.stopTiming(); +- SpigotTimings.tickEntityTimer.startTiming(); ++ timings.tickEntities.stopTiming(); + } + // Spigot end + } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index a7ae16681d..5a7087c758 100644 +index 1ec8272ff3..4fdbb8cd57 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1,5 +1,6 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; ++import co.aikar.timings.TimingHistory; +import co.aikar.timings.Timings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import com.google.common.util.concurrent.ListenableFuture; -@@ -59,10 +60,11 @@ public class WorldServer extends World implements IAsyncTaskHandler { + import com.google.common.collect.Queues; +@@ -37,7 +39,6 @@ import org.bukkit.Bukkit; + + import org.bukkit.WeatherType; + import org.bukkit.block.BlockState; +-import org.bukkit.craftbukkit.SpigotTimings; // Spigot + import org.bukkit.craftbukkit.event.CraftEventFactory; + import org.bukkit.craftbukkit.util.HashTreeSet; + +@@ -99,10 +100,10 @@ public class WorldServer extends World { // CraftBukkit end this.nextTickListBlock = new TickListServer<>(this, (block) -> { return block == null || block.getBlockData().isAir(); -- }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::getOrDefault, this::b); -+ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::getOrDefault, this::b, "Blocks"); // Paper - timings -+ +- }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b); ++ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> { return fluidtype == null || fluidtype == FluidTypes.EMPTY; -- }, IRegistry.FLUID::getKey, IRegistry.FLUID::getOrDefault, this::a); -+ }, IRegistry.FLUID::getKey, IRegistry.FLUID::getOrDefault, this::a, "Fluids"); // Paper - timings +- }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a); ++ }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings + this.I = Sets.newHashSet(); this.siegeManager = new VillageSiege(this); - this.d = new ObjectLinkedOpenHashSet(); - this.server = minecraftserver; -@@ -279,13 +281,13 @@ public class WorldServer extends World implements IAsyncTaskHandler { + this.J = new ObjectLinkedOpenHashSet(); +@@ -442,6 +443,7 @@ public class WorldServer extends World { - timings.doChunkUnload.stopTiming(); // Spigot - this.methodProfiler.exitEnter("tickPending"); -- timings.doTickPending.startTiming(); // Spigot -+ timings.scheduledBlocks.startTiming(); // Paper - this.q(); -- timings.doTickPending.stopTiming(); // Spigot -+ timings.scheduledBlocks.stopTiming(); // Paper - this.methodProfiler.exitEnter("tickBlocks"); -- timings.doTickTiles.startTiming(); // Spigot -+ timings.chunkTicks.startTiming(); // Paper - this.n_(); -- timings.doTickTiles.stopTiming(); // Spigot -+ timings.chunkTicks.stopTiming(); // Paper - this.methodProfiler.exitEnter("chunkMap"); - timings.doChunkMap.startTiming(); // Spigot - this.manager.flush(); -@@ -515,6 +517,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - } + org.spigotmc.ActivationRange.activateEntities(this); // Spigot + timings.entityTick.startTiming(); // Spigot ++ TimingHistory.entityTicks += this.globalEntityList.size(); // Paper + while (objectiterator.hasNext()) { + Entry entry = (Entry) objectiterator.next(); + Entity entity1 = (Entity) entry.getValue(); +@@ -545,6 +547,7 @@ public class WorldServer extends World { + } - this.methodProfiler.exitEnter("tickBlocks"); -+ timings.chunkTicksBlocks.startTiming(); // Paper - if (i > 0) { - ChunkSection[] achunksection = chunk.getSections(); - int i1 = achunksection.length; -@@ -546,6 +549,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - } - } + gameprofilerfiller.exitEnter("tickBlocks"); ++ timings.chunkTicksBlocks.startTiming(); // Paper + if (i > 0) { + ChunkSection[] achunksection = chunk.getSections(); + int l = achunksection.length; +@@ -576,7 +579,7 @@ public class WorldServer extends World { } -+ timings.chunkTicksBlocks.stopTiming(); // Paper } + } +- ++ timings.chunkTicksBlocks.stopTiming(); // Paper + gameprofilerfiller.exit(); + } - this.methodProfiler.exit(); -@@ -851,6 +855,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { +@@ -869,6 +872,7 @@ public class WorldServer extends World { - if (chunkproviderserver.d()) { + if (!flag1) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit -+ timings.worldSave.startTiming(); // Paper ++ try (Timing ignored = timings.worldSave.startTiming()) { //Paper if (iprogressupdate != null) { iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0])); } -@@ -860,7 +865,9 @@ public class WorldServer extends World implements IAsyncTaskHandler { +@@ -878,7 +882,10 @@ public class WorldServer extends World { iprogressupdate.c(new ChatMessage("menu.savingChunks", new Object[0])); } + timings.worldSaveChunks.startTiming(); // Paper - chunkproviderserver.a(flag); + chunkproviderserver.save(flag); + timings.worldSaveChunks.stopTiming(); // Paper - // CraftBukkit - ArrayList -> Collection - java.util.Collection list = chunkproviderserver.a(); - Iterator iterator = list.iterator(); -@@ -872,7 +879,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - chunkproviderserver.unload(chunk); - } - } -- -+ timings.worldSave.stopTiming(); // Paper ++ } // Paper } } -@@ -885,6 +892,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - } - - protected void a() throws ExceptionWorldConflict { -+ timings.worldSaveLevel.startTiming(); // Paper - this.checkSession(); - Iterator iterator = this.server.getWorlds().iterator(); - -@@ -908,6 +916,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - this.worldData.c(this.server.getBossBattleCustomData().c()); - this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t()); - this.h().a(); -+ timings.worldSaveLevel.stopTiming(); // Paper - } - - // CraftBukkit start diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6a44f0d918..fea49800d8 100644 +index 93246f464b..95d0075d57 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1986,12 +1986,31 @@ public final class CraftServer implements Server { +@@ -1922,12 +1922,31 @@ public final class CraftServer implements Server { private final Spigot spigot = new Spigot() { @@ -1353,22 +1236,20 @@ index 6a44f0d918..fea49800d8 100644 org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java deleted file mode 100644 -index 2ab4b11a8d..0000000000 +index 38f211526b..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ /dev/null -@@ -1,173 +0,0 @@ +@@ -1,166 +0,0 @@ -package org.bukkit.craftbukkit; - --import com.google.common.collect.Maps; --import net.minecraft.server.*; --import org.bukkit.plugin.java.JavaPluginLoader; --import org.spigotmc.CustomTimingsHandler; --import org.bukkit.scheduler.BukkitTask; -- -import java.util.HashMap; --import java.util.Map; -- +-import net.minecraft.server.Entity; +-import net.minecraft.server.TileEntity; +-import net.minecraft.server.World; -import org.bukkit.craftbukkit.scheduler.CraftTask; +-import org.bukkit.plugin.java.JavaPluginLoader; +-import org.bukkit.scheduler.BukkitTask; +-import org.spigotmc.CustomTimingsHandler; - -public class SpigotTimings { - @@ -1379,7 +1260,6 @@ index 2ab4b11a8d..0000000000 - public static final CustomTimingsHandler playerConnectionTimer = new CustomTimingsHandler("** PlayerConnection"); - public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables"); - public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler"); -- public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick"); - public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update"); - public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command"); - public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save"); @@ -1482,7 +1362,6 @@ index 2ab4b11a8d..0000000000 - public final CustomTimingsHandler doTickTiles; - public final CustomTimingsHandler doVillages; - public final CustomTimingsHandler doChunkMap; -- public final CustomTimingsHandler doChunkGC; - public final CustomTimingsHandler doSounds; - public final CustomTimingsHandler entityTick; - public final CustomTimingsHandler tileEntityTick; @@ -1492,7 +1371,6 @@ index 2ab4b11a8d..0000000000 - public final CustomTimingsHandler tickEntities; - - public final CustomTimingsHandler syncChunkLoadTimer; -- public final CustomTimingsHandler syncChunkLoadDataTimer; - public final CustomTimingsHandler syncChunkLoadStructuresTimer; - public final CustomTimingsHandler syncChunkLoadEntitiesTimer; - public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer; @@ -1509,14 +1387,12 @@ index 2ab4b11a8d..0000000000 - doVillages = new CustomTimingsHandler("** " + name + "doVillages"); - doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap"); - doSounds = new CustomTimingsHandler("** " + name + "doSounds"); -- doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC"); - doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer"); - entityTick = new CustomTimingsHandler("** " + name + "entityTick"); - tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick"); - tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending"); - - syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad"); -- syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data"); - syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures"); - syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities"); - syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities"); @@ -1530,47 +1406,11 @@ index 2ab4b11a8d..0000000000 - } - } -} -diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java -index 413dd35f06..52a8c48fa4 100644 ---- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java -+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java -@@ -1,6 +1,8 @@ - package org.bukkit.craftbukkit.chunkio; - - import java.io.IOException; -+ -+import co.aikar.timings.Timing; - import net.minecraft.server.Chunk; - import net.minecraft.server.ChunkCoordIntPair; - import net.minecraft.server.ChunkRegionLoader; -@@ -16,7 +18,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider {}); - -@@ -38,11 +40,13 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider> 4, z >> 4 ); ++ if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) ) ++ { ++ isActive = false; ++ } return isActive; } } diff --git a/Spigot-Server-Patches/0010-Configurable-cactus-and-reed-natural-growth-heights.patch b/Spigot-Server-Patches/0010-Configurable-cactus-and-reed-natural-growth-heights.patch index 9a14f99fe..5d6d8f1ff 100644 --- a/Spigot-Server-Patches/0010-Configurable-cactus-and-reed-natural-growth-heights.patch +++ b/Spigot-Server-Patches/0010-Configurable-cactus-and-reed-natural-growth-heights.patch @@ -1,4 +1,4 @@ -From 77786f5eecb8349c36a8926fa9f13a230c4594ec Mon Sep 17 00:00:00 2001 +From 662d7a5246e03de6fe1d4cd0a5d59943e103859a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Mar 2016 13:02:51 -0600 Subject: [PATCH] Configurable cactus and reed natural growth heights @@ -23,10 +23,10 @@ index a738657394..098bd3fba8 100644 + } } diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java -index 625b9a049f..b6806d8db3 100644 +index a26e794124..29f9ff6c18 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java -@@ -29,7 +29,7 @@ public class BlockCactus extends Block { +@@ -30,7 +30,7 @@ public class BlockCactus extends Block { ; } @@ -36,10 +36,10 @@ index 625b9a049f..b6806d8db3 100644 if (j >= (byte) range(3, ((100.0F / world.spigotConfig.cactusModifier) * 15) + 0.5F, 15)) { // Spigot diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java -index fad1a0a83c..c7017c58e7 100644 +index 4d5f485f0f..ff674a9d5b 100644 --- a/src/main/java/net/minecraft/server/BlockReed.java +++ b/src/main/java/net/minecraft/server/BlockReed.java -@@ -25,7 +25,7 @@ public class BlockReed extends Block { +@@ -29,7 +29,7 @@ public class BlockReed extends Block { ; } diff --git a/Spigot-Server-Patches/0011-Configurable-baby-zombie-movement-speed.patch b/Spigot-Server-Patches/0011-Configurable-baby-zombie-movement-speed.patch index 6e5181c69..fabf83a7b 100644 --- a/Spigot-Server-Patches/0011-Configurable-baby-zombie-movement-speed.patch +++ b/Spigot-Server-Patches/0011-Configurable-baby-zombie-movement-speed.patch @@ -1,4 +1,4 @@ -From c5b2c65f35f14d8c0bfee7cf4b6d98ed4eff89b2 Mon Sep 17 00:00:00 2001 +From 5ca07131699fd9580f9c2c4fb0a39186c2f221c7 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Mar 2016 13:09:16 -0600 Subject: [PATCH] Configurable baby zombie movement speed @@ -20,26 +20,26 @@ index 098bd3fba8..55d8e74f82 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java -index e3d52e7cf7..002be7f7be 100644 +index 21df3ef2c3..d9d9938602 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java -@@ -18,7 +18,7 @@ public class EntityZombie extends EntityMonster { +@@ -19,7 +19,7 @@ public class EntityZombie extends EntityMonster { - protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); - private static final UUID a = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); -- private static final AttributeModifier b = new AttributeModifier(EntityZombie.a, "Baby speed boost", 0.5D, 1); -+ private final AttributeModifier babyModifier = new AttributeModifier(EntityZombie.a, "Baby speed boost", world.paperConfig.babyZombieMovementSpeed, 1); // Paper - Remove static - Make baby speed configurable - private static final DataWatcherObject bC = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); - private static final DataWatcherObject bD = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.b); - private static final DataWatcherObject bE = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); -@@ -129,9 +129,9 @@ public class EntityZombie extends EntityMonster { + protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); + private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); +- private static final AttributeModifier c = new AttributeModifier(EntityZombie.b, "Baby speed boost", 0.5D, AttributeModifier.Operation.MULTIPLY_BASE); ++ private final AttributeModifier babyModifier = new AttributeModifier(EntityZombie.b, "Baby speed boost", world.paperConfig.babyZombieMovementSpeed, AttributeModifier.Operation.MULTIPLY_BASE); private final AttributeModifier = c;// Paper - Remove static - Make baby speed configurable + private static final DataWatcherObject bz = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); + private static final DataWatcherObject bA = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.b); + public static final DataWatcherObject DROWN_CONVERTING = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); +@@ -127,9 +127,9 @@ public class EntityZombie extends EntityMonster { if (this.world != null && !this.world.isClientSide) { AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); -- attributeinstance.c(EntityZombie.b); +- attributeinstance.c(EntityZombie.c); + attributeinstance.c(this.babyModifier); // Paper if (flag) { -- attributeinstance.b(EntityZombie.b); +- attributeinstance.b(EntityZombie.c); + attributeinstance.b(this.babyModifier); // Paper } } diff --git a/Spigot-Server-Patches/0012-Configurable-fishing-time-ranges.patch b/Spigot-Server-Patches/0012-Configurable-fishing-time-ranges.patch index bfa2dd531..21c60e961 100644 --- a/Spigot-Server-Patches/0012-Configurable-fishing-time-ranges.patch +++ b/Spigot-Server-Patches/0012-Configurable-fishing-time-ranges.patch @@ -1,4 +1,4 @@ -From 3c9cc110ddcacd96a032d910e15dbcaff3d43473 Mon Sep 17 00:00:00 2001 +From 9fe272a81b0d394b409499ce747d5add6da430ca Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Mar 2016 13:14:11 -0600 Subject: [PATCH] Configurable fishing time ranges @@ -22,17 +22,17 @@ index 55d8e74f82..a55163a458 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java -index 39499f0743..118b974d76 100644 +index 366356a921..b082d0a820 100644 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/src/main/java/net/minecraft/server/EntityFishingHook.java -@@ -386,8 +386,9 @@ public class EntityFishingHook extends Entity { - this.aw = MathHelper.nextInt(this.random, 20, 80); +@@ -329,8 +329,9 @@ public class EntityFishingHook extends Entity { + this.at = MathHelper.nextInt(this.random, 20, 80); } } else { -- this.h = MathHelper.nextInt(this.random, 100, 600); -+ this.h = MathHelper.nextInt(this.random, world.paperConfig.fishingMinTicks, world.paperConfig.fishingMaxTicks); // Paper - this.h -= this.aA * 20 * 5; -+ this.h = Math.max(0, this.h); // Paper - Don't allow negative values +- this.as = MathHelper.nextInt(this.random, 100, 600); ++ this.as = MathHelper.nextInt(this.random, world.paperConfig.fishingMinTicks, world.paperConfig.fishingMaxTicks); // Paper + this.as -= this.ax * 20 * 5; ++ this.as = Math.max(0, this.as); // Paper - Don't allow negative values } } diff --git a/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump.patch b/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump.patch index ca61df02e..ac7df145c 100644 --- a/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump.patch +++ b/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump.patch @@ -1,4 +1,4 @@ -From 52b62639d8961610094976f5c68b9d3caf0bda60 Mon Sep 17 00:00:00 2001 +From 4fe17ed34ff3c43917ab28bcfea9060d23bf3271 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Mar 2016 13:24:16 -0600 Subject: [PATCH] Allow nerfed mobs to jump @@ -19,7 +19,7 @@ index a55163a458..341038fc4d 100644 + } } diff --git a/src/main/java/net/minecraft/server/ControllerJump.java b/src/main/java/net/minecraft/server/ControllerJump.java -index 4ed5192c65..489beed269 100644 +index 2e869004c8..8a6856e0fd 100644 --- a/src/main/java/net/minecraft/server/ControllerJump.java +++ b/src/main/java/net/minecraft/server/ControllerJump.java @@ -13,6 +13,7 @@ public class ControllerJump { @@ -28,21 +28,21 @@ index 4ed5192c65..489beed269 100644 + public void jumpIfSet() { this.b(); } // Paper - OBFHELPER public void b() { - this.b.o(this.a); + this.b.setJumping(this.a); this.a = false; diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index 1a3517aeed..2bfd5fe2d8 100644 +index afa03ce6f2..d49047abc1 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java -@@ -33,6 +33,7 @@ public abstract class EntityInsentient extends EntityLiving { - private final EntityAIBodyControl b; +@@ -31,6 +31,7 @@ public abstract class EntityInsentient extends EntityLiving { + private final EntityAIBodyControl c; protected NavigationAbstract navigation; public PathfinderGoalSelector goalSelector; + @Nullable public PathfinderGoalFloat goalFloat; // Paper public PathfinderGoalSelector targetSelector; private EntityLiving goalTarget; - private final EntitySenses bC; -@@ -647,6 +648,12 @@ public abstract class EntityInsentient extends EntityLiving { + private final EntitySenses bz; +@@ -640,6 +641,12 @@ public abstract class EntityInsentient extends EntityLiving { // Spigot Start if ( this.fromMobSpawner ) { @@ -56,27 +56,25 @@ index 1a3517aeed..2bfd5fe2d8 100644 } // Spigot End diff --git a/src/main/java/net/minecraft/server/PathfinderGoalFloat.java b/src/main/java/net/minecraft/server/PathfinderGoalFloat.java -index 0d95051383..38a0b2db1e 100644 +index 040a64471f..2dfa5a7b40 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalFloat.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalFloat.java -@@ -6,14 +6,17 @@ public class PathfinderGoalFloat extends PathfinderGoal { +@@ -8,6 +8,7 @@ public class PathfinderGoalFloat extends PathfinderGoal { public PathfinderGoalFloat(EntityInsentient entityinsentient) { this.a = entityinsentient; + if (entityinsentient.getWorld().paperConfig.nerfedMobsShouldJump) entityinsentient.goalFloat = this; // Paper - this.a(4); + this.a(EnumSet.of(PathfinderGoal.Type.JUMP)); entityinsentient.getNavigation().d(true); } - -+ public boolean validConditions() { return this.a(); } // Paper - OBFHELPER - public boolean a() { - return this.a.isInWater() && this.a.bY() > 0.4D || this.a.ax(); +@@ -19,6 +20,7 @@ public class PathfinderGoalFloat extends PathfinderGoal { + return this.a.isInWater() && this.a.ce() > d0 || this.a.aC(); } + public void update() { this.e(); } // Paper - OBFHELPER + @Override public void e() { if (this.a.getRandom().nextFloat() < 0.8F) { - this.a.getControllerJump().a(); -- 2.21.0 diff --git a/Spigot-Server-Patches/0014-Add-configurable-despawn-distances-for-living-entiti.patch b/Spigot-Server-Patches/0014-Add-configurable-despawn-distances-for-living-entiti.patch index ddb5d3818..83318d4f6 100644 --- a/Spigot-Server-Patches/0014-Add-configurable-despawn-distances-for-living-entiti.patch +++ b/Spigot-Server-Patches/0014-Add-configurable-despawn-distances-for-living-entiti.patch @@ -1,4 +1,4 @@ -From 8f3d832ee04d29536a8b70ff9c830a9f573a7112 Mon Sep 17 00:00:00 2001 +From 224c6085a743293e4c7c8f99d4d13e93a81a7f30 Mon Sep 17 00:00:00 2001 From: Suddenly Date: Tue, 1 Mar 2016 13:51:54 -0600 Subject: [PATCH] Add configurable despawn distances for living entities @@ -30,26 +30,23 @@ index 341038fc4d..3e1f4be10f 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index 2bfd5fe2d8..80d872e797 100644 +index d49047abc1..265e734af2 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java -@@ -626,13 +626,13 @@ public abstract class EntityInsentient extends EntityLiving { - double d2 = entityhuman.locZ - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; +@@ -616,11 +616,11 @@ public abstract class EntityInsentient extends EntityLiving { + if (entityhuman != null) { + double d0 = entityhuman.h(this); -- if (d3 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check -+ if (d3 > world.paperConfig.hardDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances +- if (d0 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check ++ if (d0 > world.paperConfig.hardDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances this.die(); } -- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check -+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d3 > world.paperConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances +- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check ++ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > world.paperConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances this.die(); -- } else if (d3 < 1024.0D) { -+ } else if (d3 < world.paperConfig.softDespawnDistance) { // Paper - custom despawn distances + } else if (d0 < 1024.0D) { this.ticksFarFromPlayer = 0; - } - } -- 2.21.0 diff --git a/Spigot-Server-Patches/0015-Allow-for-toggling-of-spawn-chunks.patch b/Spigot-Server-Patches/0015-Allow-for-toggling-of-spawn-chunks.patch index b98db1729..93adf4160 100644 --- a/Spigot-Server-Patches/0015-Allow-for-toggling-of-spawn-chunks.patch +++ b/Spigot-Server-Patches/0015-Allow-for-toggling-of-spawn-chunks.patch @@ -1,4 +1,4 @@ -From d8c63a9b9619e7934ca20c09f63909e16f6fa012 Mon Sep 17 00:00:00 2001 +From 0b044b5e02fe8181fd259c98ce1fefd8870f7c30 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 3 Mar 2016 03:53:43 -0600 Subject: [PATCH] Allow for toggling of spawn chunks @@ -20,15 +20,15 @@ index 3e1f4be10f..3f734327c0 100644 + } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index ad792af2bc..f24ee385cd 100644 +index eabcab0244..446f864420 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -201,6 +201,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - this.getServer().addWorld(this.world); +@@ -152,6 +152,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose + }); // CraftBukkit end timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings + this.keepSpawnInMemory = this.paperConfig.keepSpawnInMemory; // Paper - this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); + this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); } -- diff --git a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch index d656694c9..09d92a93a 100644 --- a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch +++ b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch @@ -1,4 +1,4 @@ -From 7b97269d9fb6b8c56c684946f4f85a3fe07d8b6f Mon Sep 17 00:00:00 2001 +From 658e764bcd49c33fd09b0bcf5cc42014f7599b19 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 14:14:15 -0600 Subject: [PATCH] Drop falling block and tnt entities at the specified height @@ -24,10 +24,10 @@ index 3f734327c0..1ed58f4bba 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 131946154e..2198182ec9 100644 +index 2d07bfa879..7191861e81 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1879,6 +1879,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -1770,6 +1770,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke return this.a(itemstack, 0.0F); } @@ -36,45 +36,39 @@ index 131946154e..2198182ec9 100644 public EntityItem a(ItemStack itemstack, float f) { if (itemstack.isEmpty()) { diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java -index 4e4c8cc501..a6eae266de 100644 +index c9c903367f..55591fbe05 100644 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java -@@ -86,6 +86,17 @@ public class EntityFallingBlock extends Entity { - } +@@ -105,11 +105,13 @@ public class EntityFallingBlock extends Entity { - this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); -+ -+ // Paper start - Configurable EntityFallingBlock height nerf -+ if (this.world.paperConfig.fallingBlockHeightNerf != 0 && this.locY > this.world.paperConfig.fallingBlockHeightNerf) { -+ if (this.dropItem && this.world.getGameRules().getBoolean("doEntityDrops")) { -+ this.dropItem(new ItemStack(block), 0.0F); -+ } -+ -+ this.die(); -+ } -+ // Paper end -+ - if (!this.world.isClientSide) { - blockposition = new BlockPosition(this); - boolean flag = this.block.getBlock() instanceof BlockConcretePowder; + if (!this.onGround && !flag1) { + if (!this.world.isClientSide && (this.ticksLived > 100 && (blockposition.getY() < 1 || blockposition.getY() > 256) || this.ticksLived > 600)) { ++ if (this.world.paperConfig.fallingBlockHeightNerf != 0 && this.locY > this.world.paperConfig.fallingBlockHeightNerf) { // Paper - Configurable EntityFallingBlock height nerf + if (this.dropItem && this.world.getGameRules().getBoolean("doEntityDrops")) { + this.a((IMaterial) block); + } + + this.die(); ++ } // Paper + } + } else { + IBlockData iblockdata = this.world.getType(blockposition); diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java -index e3a03782c8..8c19278f37 100644 +index ba86a07344..e3001570f9 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java -@@ -57,6 +57,13 @@ public class EntityTNTPrimed extends Entity { +@@ -57,6 +57,11 @@ public class EntityTNTPrimed extends Entity { } - this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); -+ + this.move(EnumMoveType.SELF, this.getMot()); + // Paper start - Configurable TNT entity height nerf + if (this.world.paperConfig.entityTNTHeightNerf != 0 && this.locY > this.world.paperConfig.entityTNTHeightNerf) { + this.die(); + } + // Paper end -+ - this.motX *= 0.9800000190734863D; - this.motY *= 0.9800000190734863D; - this.motZ *= 0.9800000190734863D; + this.setMot(this.getMot().a(0.98D)); + if (this.onGround) { + this.setMot(this.getMot().d(0.7D, -0.5D, 0.7D)); -- 2.21.0 diff --git a/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch b/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch index 2e4e58c13..ce51e7dec 100644 --- a/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch +++ b/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch @@ -1,4 +1,4 @@ -From 39a20240b9b506f4bba726d5504af0c03588988d Mon Sep 17 00:00:00 2001 +From d054764b7c89587e26af504433d4ce408277a3be Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Mar 2016 14:32:43 -0600 Subject: [PATCH] Show 'Paper' in client crashes, server lists, and Mojang @@ -6,23 +6,23 @@ Subject: [PATCH] Show 'Paper' in client crashes, server lists, and Mojang diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java -index 220ca7bca0..e13e17bdd2 100644 +index d05fee962a..61c02c530b 100644 --- a/src/main/java/net/minecraft/server/EULA.java +++ b/src/main/java/net/minecraft/server/EULA.java -@@ -52,7 +52,7 @@ public class EULA { +@@ -70,7 +70,7 @@ public class EULA { + Properties properties = new Properties(); - fileoutputstream = new FileOutputStream(this.b); - properties.setProperty("eula", "false"); -- properties.store(fileoutputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); -+ properties.store(fileoutputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\nYou also agree that tacos are tasty, and the best food in the world."); // Paper - fix lag); - } catch (Exception exception) { - EULA.a.warn("Failed to save {}", this.b, exception); - } finally { + properties.setProperty("eula", "false"); +- properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); ++ properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\nYou also agree that tacos are tasty, and the best food in the world."); // Paper - fix lag; + } catch (Throwable throwable1) { + throwable = throwable1; + throw throwable1; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7e89d7158b..df85f35f37 100644 +index 7b102e155d..89ad19e59c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1209,7 +1209,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati +@@ -1264,7 +1264,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant Date: Tue, 1 Mar 2016 14:47:52 -0600 Subject: [PATCH] Player affects spawning API diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 050f21efa5..58e037e13b 100644 +index 07401b4d9b..20460ad98a 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java -@@ -68,6 +68,9 @@ public abstract class EntityHuman extends EntityLiving { - private final ItemCooldown ce; +@@ -70,6 +70,9 @@ public abstract class EntityHuman extends EntityLiving { + private final ItemCooldown bY; @Nullable public EntityFishingHook hookedFish; + // Paper start @@ -19,70 +19,36 @@ index 050f21efa5..58e037e13b 100644 // CraftBukkit start public boolean fauxSleeping; diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index 80d872e797..e5322de974 100644 +index 265e734af2..5d830b245d 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java -@@ -620,7 +620,7 @@ public abstract class EntityInsentient extends EntityLiving { - } else { +@@ -613,7 +613,7 @@ public abstract class EntityInsentient extends EntityLiving { + if (!this.isPersistent() && !this.I()) { EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - if (entityhuman != null) { + if (entityhuman != null && entityhuman.affectsSpawning) { // Paper - Affects Spawning API - double d0 = entityhuman.locX - this.locX; - double d1 = entityhuman.locY - this.locY; - double d2 = entityhuman.locZ - this.locZ; + double d0 = entityhuman.h(this); + + if (d0 > world.paperConfig.hardDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java -index 3c566ebd0e..ba40e03fcc 100644 +index dbbc34d91b..d823c6b6d9 100644 --- a/src/main/java/net/minecraft/server/EntitySilverfish.java +++ b/src/main/java/net/minecraft/server/EntitySilverfish.java -@@ -96,7 +96,7 @@ public class EntitySilverfish extends EntityMonster { - if (super.a(generatoraccess, flag)) { - EntityHuman entityhuman = generatoraccess.b(this, 5.0D); +@@ -106,7 +106,7 @@ public class EntitySilverfish extends EntityMonster { + if (super.a(generatoraccess, enummobspawn)) { + EntityHuman entityhuman = this.world.a(EntitySilverfish.b, (EntityLiving) this); - return entityhuman == null; + return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API } else { return false; } -diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index 6ca0e19cb9..4eaa5d93b4 100644 ---- a/src/main/java/net/minecraft/server/SpawnerCreature.java -+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java -@@ -37,7 +37,7 @@ public final class SpawnerCreature { - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - -- if (!entityhuman.isSpectator()) { -+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) { // Paper - int l = MathHelper.floor(entityhuman.locX / 16.0D); - - j = MathHelper.floor(entityhuman.locZ / 16.0D); -diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index f24ee385cd..106ad00dc7 100644 ---- a/src/main/java/net/minecraft/server/World.java -+++ b/src/main/java/net/minecraft/server/World.java -@@ -30,6 +30,7 @@ import org.bukkit.craftbukkit.CraftWorld; - import org.bukkit.craftbukkit.block.CraftBlockState; - import org.bukkit.craftbukkit.block.data.CraftBlockData; - import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.util.LongHashSet; // Paper - import org.bukkit.event.block.BlockPhysicsEvent; - import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; - import org.bukkit.generator.ChunkGenerator; -@@ -2389,7 +2390,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman = (EntityHuman) this.players.get(i); - -- if (IEntitySelector.f.test(entityhuman)) { -+ if (IEntitySelector.f.test(entityhuman) && entityhuman.affectsSpawning) { // Paper - Affects Spawning API - double d4 = entityhuman.d(d0, d1, d2); - - if (d3 < 0.0D || d4 < d3 * d3) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 99f99148d6..15c2e1dee7 100644 +index 25726dd751..ca65d51d81 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -1613,7 +1613,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1639,7 +1639,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public String getLocale() { return getHandle().locale; diff --git a/Spigot-Server-Patches/0019-Remove-invalid-mob-spawner-tile-entities.patch b/Spigot-Server-Patches/0019-Remove-invalid-mob-spawner-tile-entities.patch index a87d92248..cc972c516 100644 --- a/Spigot-Server-Patches/0019-Remove-invalid-mob-spawner-tile-entities.patch +++ b/Spigot-Server-Patches/0019-Remove-invalid-mob-spawner-tile-entities.patch @@ -1,16 +1,16 @@ -From e73aad40de93a92039325077c5df36af6786dd22 Mon Sep 17 00:00:00 2001 +From fe64055921f76ebcdb8891a74b35ef5c8aa9eccd Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 15:08:03 -0600 Subject: [PATCH] Remove invalid mob spawner tile entities diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 2b1198ca8f..e15ed21f67 100644 +index 89bce93c61..3be7f7d297 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -796,6 +796,10 @@ public class Chunk implements IChunkAccess { - tileentity.z(); - this.tileEntities.put(blockposition.h(), tileentity); +@@ -523,6 +523,10 @@ public class Chunk implements IChunkAccess { + } + // CraftBukkit start + // Paper start - Remove invalid mob spawner tile entities + } else if (tileentity instanceof TileEntityMobSpawner && !(getBlockData(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getBlock() instanceof BlockMobSpawner)) { diff --git a/Spigot-Server-Patches/0020-Optimize-TileEntity-Ticking.patch b/Spigot-Server-Patches/0020-Optimize-TileEntity-Ticking.patch index 4cdc29fe9..279e309d2 100644 --- a/Spigot-Server-Patches/0020-Optimize-TileEntity-Ticking.patch +++ b/Spigot-Server-Patches/0020-Optimize-TileEntity-Ticking.patch @@ -1,11 +1,11 @@ -From a9d542b68c57c3744614b77947da9e5db95321c3 Mon Sep 17 00:00:00 2001 +From 902b97c38b3a8621321d4d2e0eaf73efb88b4128 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 8 Mar 2015 22:55:25 -0600 Subject: [PATCH] Optimize TileEntity Ticking diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java -index 2b03896e23..c46b761cc5 100644 +index 271406f8bb..d606e2e4fd 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity; @@ -17,81 +17,72 @@ index 2b03896e23..c46b761cc5 100644 private NonNullList items; protected float a; -@@ -113,9 +113,15 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { +@@ -101,13 +101,19 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { + return nbttagcompound; + } + +- @Override + public void tick() { + int i = this.position.getX(); + int j = this.position.getY(); int k = this.position.getZ(); - ++this.k; -+ // Paper start + ++this.j; + } -+ private void doOpenLogic() { - float f; -- -- if (!this.world.isClientSide && this.f != 0 && (this.k + i + j + k) % 200 == 0) { ++ ++ public void doOpenLogic() { + int i = this.position.getX(); + int j = this.position.getY(); + int k = this.position.getZ(); -+ if (false && !this.world.isClientSide && this.f != 0 && (this.k + i + j + k) % 200 == 0) { // Paper - disable block -+ // Paper end - this.f = 0; - f = 5.0F; - List list = this.world.a(EntityHuman.class, new AxisAlignedBB((double) ((float) i - 5.0F), (double) ((float) j - 5.0F), (double) ((float) k - 5.0F), (double) ((float) (i + 1) + 5.0F), (double) ((float) (j + 1) + 5.0F), (double) ((float) (k + 1) + 5.0F))); -@@ -134,13 +140,17 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { - } - } - -- this.e = this.a; -- f = 0.1F; -- if (this.f > 0 && this.a == 0.0F) { -+ if (this.f == 1 && this.a == 0.0F) { // check == 1 instead of > 0, first open ++ + this.viewingCount = a(this.world, this, this.j, i, j, k, this.viewingCount); + this.b = this.a; + float f = 0.1F; +@@ -115,8 +121,11 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { + if (this.viewingCount > 0 && this.a == 0.0F) { this.a(SoundEffects.BLOCK_CHEST_OPEN); } -+ // Paper start + } -+ private void doCloseLogic() { -+ this.e = this.a; -+ // Paper end -- if (this.f == 0 && this.a > 0.0F || this.f > 0 && this.a < 1.0F) { -+ if (this.f == 0/* && this.a > 0.0F || this.f > 0 && this.a < 1.0F*/) { // Paper disable all but player count check -+ /* // Paper disable animation stuff +- if (this.viewingCount == 0 && this.a > 0.0F || this.viewingCount > 0 && this.a < 1.0F) { ++ public void doCloseLogic() { ++ if (this.viewingCount == 0 /* && this.a > 0.0F || this.viewingCount > 0 && this.a < 1.0F */) { // Paper - disable all but player count check ++ /* // Paper - disable animation stuff float f1 = this.a; - if (this.f > 0) { -@@ -155,9 +165,14 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { - + if (this.viewingCount > 0) { +@@ -132,8 +141,11 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { float f2 = 0.5F; -+ if (this.a < 0.5F && f1 >= 0.5F) { - this.a(SoundEffects.BLOCK_CHEST_CLOSE); - } -+ */ -+ // add some delay -+ MCUtil.scheduleTask(10, () -> { -+ if (this.f == 0) this.a(SoundEffects.BLOCK_CHEST_CLOSE); ++ */ ++ MCUtil.scheduleTask(10, () -> { ++ this.a(SoundEffects.BLOCK_CHEST_CLOSE); + }); -+ // } // Paper end ++ //} // Paper end if (this.a < 0.0F) { this.a = 0.0F; -@@ -203,6 +218,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { +@@ -210,6 +222,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { - ++this.f; + ++this.viewingCount; if (this.world == null) return; // CraftBukkit + doOpenLogic(); // Paper // CraftBukkit start - Call redstone event - if (this.getBlock() == Blocks.TRAPPED_CHEST) { -@@ -224,6 +240,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { - --this.f; + if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { +@@ -232,6 +245,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { + --this.viewingCount; // CraftBukkit start - Call redstone event + doCloseLogic(); // Paper - if (this.getBlock() == Blocks.TRAPPED_CHEST) { - int newPower = Math.max(0, Math.min(15, this.f)); + if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { + int newPower = Math.max(0, Math.min(15, this.viewingCount)); diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java -index ee19595d33..f2df6f3950 100644 +index 6908f50031..ed5cdf177f 100644 --- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java +++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java @@ -1,6 +1,6 @@ @@ -101,57 +92,63 @@ index ee19595d33..f2df6f3950 100644 +public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickable public float a; - public float e; -@@ -17,19 +17,37 @@ public class TileEntityEnderChest extends TileEntity implements ITickable { + public float b; +@@ -11,18 +11,28 @@ public class TileEntityEnderChest extends TileEntity implements ITickable { + super(TileEntityTypes.ENDER_CHEST); + } + +- @Override + public void tick() { + if (++this.g % 20 * 4 == 0) { + this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c); } - this.e = this.a; -+ // Paper start -+ /* + this.b = this.a; ++ /* // Paper int i = this.position.getX(); int j = this.position.getY(); int k = this.position.getZ(); float f = 0.1F; double d0; - -+ */ + // Paper start ++ */ + } ++ + private void doOpenLogic() { + int i = this.position.getX(); + int j = this.position.getY(); + int k = this.position.getZ(); ++ double d0; + // Paper end - if (this.f > 0 && this.a == 0.0F) { - double d1 = (double) i + 0.5D; -- d0 = (double) k + 0.5D; -+ double d0 = (double) k + 0.5D; // Paper + if (this.c > 0 && this.a == 0.0F) { + double d1 = (double) i + 0.5D; +@@ -30,7 +40,15 @@ public class TileEntityEnderChest extends TileEntity implements ITickable { + d0 = (double) k + 0.5D; this.world.a((EntityHuman) null, d1, (double) j + 0.5D, d0, SoundEffects.BLOCK_ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); } -- + // Paper start + } + + private void doCloseLogic() { + int i = this.position.getX(); + int j = this.position.getY(); + int k = this.position.getZ(); -+ this.e = this.a; + double d0; + // Paper end - if (this.f == 0 && this.a > 0.0F || this.f > 0 && this.a < 1.0F) { + if (this.c == 0 && this.a > 0.0F || this.c > 0 && this.a < 1.0F) { float f1 = this.a; -@@ -76,11 +94,13 @@ public class TileEntityEnderChest extends TileEntity implements ITickable { +@@ -79,11 +97,13 @@ public class TileEntityEnderChest extends TileEntity implements ITickable { public void c() { - ++this.f; - this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.f); + ++this.c; + this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c); + doOpenLogic(); // Paper } public void d() { - --this.f; - this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.f); + --this.c; + this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c); + doCloseLogic(); // Paper } diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 227a01eab..9d14850d8 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -95,7 +95,6 @@ done # import FileName - ######################################################## ######################################################## ######################################################## diff --git a/work/Bukkit b/work/Bukkit index 263f706c2..3735f9d0a 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 263f706c2b25d4a2c0970bbb2bf99112947bc15e +Subproject commit 3735f9d0ad8295565d59db84f49446589f580da0 diff --git a/work/CraftBukkit b/work/CraftBukkit index 48c4c5ca8..364b6fbb7 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 48c4c5ca8133cead0e849c546cf7e0865300c94d +Subproject commit 364b6fbb73176d276a110f4ce4217979ad7ee6a4 diff --git a/work/Spigot b/work/Spigot index 3e47a77bb..6dbf995f1 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 3e47a77bbf13823cba635bfc6b643f3816ae5347 +Subproject commit 6dbf995f13ca29e311d686e963973905388a29b3