diff --git a/build.gradle.kts b/build.gradle.kts index 697d7fce6a..d64559b45a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.core") version "1.5.8" + id("io.papermc.paperweight.core") version "1.5.9" } allprojects { diff --git a/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch b/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch index e7013cf7c5..26a1d28bf7 100644 --- a/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch +++ b/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch @@ -126,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return console.console; + return this.console.console; } + // Paper start diff --git a/patches/server/API-for-updating-recipes-on-clients.patch b/patches/server/API-for-updating-recipes-on-clients.patch index 32193add43..a3f466e3bb 100644 --- a/patches/server/API-for-updating-recipes-on-clients.patch +++ b/patches/server/API-for-updating-recipes-on-clients.patch @@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - ReloadCommand.reload(console); + ReloadCommand.reload(this.console); } + // Paper start diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index 3f480806aa..280275ba55 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // copy tile entity data: - this.snapshot = this.createSnapshot(tileEntity); -- this.load(snapshot); +- this.load(this.snapshot); + if (this.snapshot != null) { + this.load(this.snapshot); + } diff --git a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch index f9962bc501..5cd03bed44 100644 --- a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch +++ b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public BlockState[] getTileEntities(boolean useSnapshot) { + // Paper end if (!this.isLoaded()) { - this.getWorld().getChunkAt(x, z); // Transient load for this tick + this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick } @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { BlockState[] entities = new BlockState[chunk.blockEntities.size()]; diff --git a/patches/server/Add-ArmorStand-Item-Meta.patch b/patches/server/Add-ArmorStand-Item-Meta.patch index 804069aa17..e83134d329 100644 --- a/patches/server/Add-ArmorStand-Item-Meta.patch +++ b/patches/server/Add-ArmorStand-Item-Meta.patch @@ -56,8 +56,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftMetaArmorStand extends CraftMetaItem { - if (tag.contains(ENTITY_TAG.NBT)) { - this.entityTag = tag.getCompound(ENTITY_TAG.NBT).copy(); + if (tag.contains(CraftMetaArmorStand.ENTITY_TAG.NBT)) { + this.entityTag = tag.getCompound(CraftMetaArmorStand.ENTITY_TAG.NBT).copy(); + // Paper start + if (entityTag.contains(INVISIBLE.NBT)) { + invisible = entityTag.getBoolean(INVISIBLE.NBT); @@ -124,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end if (this.entityTag != null) { - tag.put(ENTITY_TAG.NBT, entityTag); + tag.put(CraftMetaArmorStand.ENTITY_TAG.NBT, this.entityTag); } @@ -0,0 +0,0 @@ public class CraftMetaArmorStand extends CraftMetaItem { } diff --git a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch index 3ab1e65665..2c6ef0eebd 100644 --- a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch +++ b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot start + org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Arrays.fill( recentTps, 20 ); + Arrays.fill( this.recentTps, 20 ); long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop lastTick = start - TICK_TIME; // Paper diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -60,8 +60,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 SpigotConfig.restartScript = SpigotConfig.getString( "settings.restart-script", SpigotConfig.restartScript ); SpigotConfig.restartMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.restart", "Server is restarting" ) ); SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) ); -- WatchdogThread.doStart( timeoutTime, restartOnCrash ); -+ // WatchdogThread.doStart( timeoutTime, restartOnCrash ); // Paper - moved to after paper config initialization +- WatchdogThread.doStart( SpigotConfig.timeoutTime, SpigotConfig.restartOnCrash ); ++ // WatchdogThread.doStart( SpigotConfig.timeoutTime, SpigotConfig.restartOnCrash ); // Paper - moved to after paper config initialization } public static boolean bungee; @@ -157,4 +157,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + sleep( 1000 ); // Paper - Reduce check time to every second instead of every ten seconds, more consistent and allows for short timeout } catch ( InterruptedException ex ) { - interrupt(); + this.interrupt(); diff --git a/patches/server/Add-Heightmap-API.patch b/patches/server/Add-Heightmap-API.patch index 0a793f1932..6f3a2b902d 100644 --- a/patches/server/Add-Heightmap-API.patch +++ b/patches/server/Add-Heightmap-API.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - return CraftBlock.at(world, new BlockPos(x, y, z)); + return CraftBlock.at(this.world, new BlockPos(x, y, z)); } + // Paper start - Implement heightmap api diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 4ceb084ed6..232296e1e5 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.disconnect("Invalid payload REGISTER!"); + this.disconnect("Invalid payload REGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause } - } else if (identifier.equals(CUSTOM_UNREGISTER)) { + } else if (identifier.equals(ServerCommonPacketListenerImpl.CUSTOM_UNREGISTER)) { try { @@ -0,0 +0,0 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } @@ -392,8 +392,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot Start if ( entity == this.player && !this.player.isSpectator() ) { -- disconnect( "Cannot interact with self!" ); -+ disconnect( "Cannot interact with self!" , org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION ); // Paper - kick event cause +- this.disconnect( "Cannot interact with self!" ); ++ this.disconnect( "Cannot interact with self!" , org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION ); // Paper - kick event cause return; } // Spigot End diff --git a/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch index a7e21e3944..4b5ec53d1f 100644 --- a/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch +++ b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second this.minimumAPI = this.configuration.getString("settings.minimum-api"); this.printSaveWarning = false; - console.autosavePeriod = this.configuration.getInt("ticks-per.autosave"); + this.console.autosavePeriod = this.configuration.getInt("ticks-per.autosave"); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/patches/server/Add-TNTPrimeEvent.patch b/patches/server/Add-TNTPrimeEvent.patch index cf2e230e71..dce5d82507 100644 --- a/patches/server/Add-TNTPrimeEvent.patch +++ b/patches/server/Add-TNTPrimeEvent.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent()) + continue; + // Paper end - nmsBlock.wasExploded(this.level(), blockposition, explosionSource); + nmsBlock.wasExploded(this.level(), blockposition, this.explosionSource); this.level().removeBlock(blockposition, false); diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java diff --git a/patches/server/Add-Unix-domain-socket-support.patch b/patches/server/Add-Unix-domain-socket-support.patch index 8425142266..4fd13c5c0b 100644 --- a/patches/server/Add-Unix-domain-socket-support.patch +++ b/patches/server/Add-Unix-domain-socket-support.patch @@ -133,11 +133,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper + // Paper start - Unix domain socket support -+ java.net.SocketAddress socketAddress = connection.getRemoteAddress(); - connection.hostname = split[0]; -- connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); -+ connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0); ++ java.net.SocketAddress socketAddress = this.connection.getRemoteAddress(); + this.connection.hostname = split[0]; +- this.connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); ++ this.connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0); + // Paper end - connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); + this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); } else { diff --git a/patches/server/Add-Velocity-IP-Forwarding-Support.patch b/patches/server/Add-Velocity-IP-Forwarding-Support.patch index 2d4c0f34c2..290268ffc0 100644 --- a/patches/server/Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/Add-Velocity-IP-Forwarding-Support.patch @@ -99,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); // CraftBukkit end + // Paper start diff --git a/patches/server/Add-a-consumer-parameter-to-ProjectileSource-launchP.patch b/patches/server/Add-a-consumer-parameter-to-ProjectileSource-launchP.patch index 97b8bc5f9d..026d8b9b2b 100644 --- a/patches/server/Add-a-consumer-parameter-to-ProjectileSource-launchP.patch +++ b/patches/server/Add-a-consumer-parameter-to-ProjectileSource-launchP.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - launchProjectile consumer Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation"); - net.minecraft.world.level.Level world = ((CraftWorld) getWorld()).getHandle(); + net.minecraft.world.level.Level world = ((CraftWorld) this.getWorld()).getHandle(); @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (velocity != null) { ((T) launch.getBukkitEntity()).setVelocity(velocity); diff --git a/patches/server/Add-bypass-host-check.patch b/patches/server/Add-bypass-host-check.patch index d081cabe32..bd1989dfb8 100644 --- a/patches/server/Add-bypass-host-check.patch +++ b/patches/server/Add-bypass-host-check.patch @@ -25,6 +25,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! - if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { + if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper - connection.hostname = split[0]; - connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); - connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); + this.connection.hostname = split[0]; + this.connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); + this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); diff --git a/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch index 628b61d498..415e4fee42 100644 --- a/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch +++ b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch @@ -102,8 +102,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setStorm(boolean hasStorm) { -- world.levelData.setRaining(hasStorm); -+ world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper +- this.world.levelData.setRaining(hasStorm); ++ this.world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper this.setWeatherDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } @@ -111,8 +111,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setThundering(boolean thundering) { -- world.serverLevelData.setThundering(thundering); -+ world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper +- this.world.serverLevelData.setThundering(thundering); ++ this.world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper this.setThunderDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } diff --git a/patches/server/Add-fire-tick-delay-option.patch b/patches/server/Add-fire-tick-delay-option.patch index 5e77c3ee50..dace9ca2a9 100644 --- a/patches/server/Add-fire-tick-delay-option.patch +++ b/patches/server/Add-fire-tick-delay-option.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world)); // Paper if (world.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { if (!state.canSurvive(world, pos)) { - fireExtinguished(world, pos); // CraftBukkit - invalid place location + this.fireExtinguished(world, pos); // CraftBukkit - invalid place location @@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock { public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext); diff --git a/patches/server/Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/patches/server/Add-handshake-event-to-allow-plugins-to-handle-clien.patch index a8762143bc..6914840304 100644 --- a/patches/server/Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/patches/server/Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -53,5 +53,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { - connection.hostname = split[0]; - connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); + this.connection.hostname = split[0]; + this.connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); diff --git a/patches/server/Add-ignore-discounts-API.patch b/patches/server/Add-ignore-discounts-API.patch index 5ea55cd7fa..de96e5537e 100644 --- a/patches/server/Add-ignore-discounts-API.patch +++ b/patches/server/Add-ignore-discounts-API.patch @@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ); this.setSpecialPrice(specialPrice); @@ -0,0 +0,0 @@ public class CraftMerchantRecipe extends MerchantRecipe { - handle.priceMultiplier = priceMultiplier; + this.handle.priceMultiplier = priceMultiplier; } + // Paper start @@ -141,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + public net.minecraft.world.item.trading.MerchantOffer toMinecraft() { - List ingredients = getIngredients(); + List ingredients = this.getIngredients(); Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients"); @@ -0,0 +0,0 @@ public class CraftMerchantRecipe extends MerchantRecipe { if (recipe instanceof CraftMerchantRecipe) { diff --git a/patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch b/patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch index 107ea6f5b2..38dd03945d 100644 --- a/patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch +++ b/patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch @@ -57,4 +57,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public boolean generateTree(Location loc, TreeType type) { - return generateTree(loc, CraftWorld.rand, type); + return this.generateTree(loc, CraftWorld.rand, type); diff --git a/patches/server/Add-missing-SpigotConfig-logCommands-check.patch b/patches/server/Add-missing-SpigotConfig-logCommands-check.patch index 43cdff1d36..6bdacb884d 100644 --- a/patches/server/Add-missing-SpigotConfig-logCommands-check.patch +++ b/patches/server/Add-missing-SpigotConfig-logCommands-check.patch @@ -16,5 +16,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command); + } // Paper - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(getCraftPlayer(), command, new LazyPlayerSet(server)); + PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server)); this.cserver.getPluginManager().callEvent(event); diff --git a/patches/server/Add-missing-block-data-mins-and-maxes.patch b/patches/server/Add-missing-block-data-mins-and-maxes.patch index e0891c359a..f728166dbd 100644 --- a/patches/server/Add-missing-block-data-mins-and-maxes.patch +++ b/patches/server/Add-missing-block-data-mins-and-maxes.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java @@ -0,0 +0,0 @@ public final class CraftCherryLeaves extends org.bukkit.craftbukkit.block.data.C public void setWaterlogged(boolean waterlogged) { - set(CraftCherryLeaves.WATERLOGGED, waterlogged); + this.set(CraftCherryLeaves.WATERLOGGED, waterlogged); } + + // Paper start @@ -96,7 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java @@ -0,0 +0,0 @@ public final class CraftLeaves extends org.bukkit.craftbukkit.block.data.CraftBl public void setWaterlogged(boolean waterlogged) { - set(CraftLeaves.WATERLOGGED, waterlogged); + this.set(CraftLeaves.WATERLOGGED, waterlogged); } + + // Paper start @@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java @@ -0,0 +0,0 @@ public final class CraftMangroveLeaves extends org.bukkit.craftbukkit.block.data public void setWaterlogged(boolean waterlogged) { - set(CraftMangroveLeaves.WATERLOGGED, waterlogged); + this.set(CraftMangroveLeaves.WATERLOGGED, waterlogged); } + + // Paper start diff --git a/patches/server/Add-setPlayerProfile-API-for-Skulls.patch b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch index e14772a6a3..d0a454d80b 100644 --- a/patches/server/Add-setPlayerProfile-API-for-Skulls.patch +++ b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch @@ -97,8 +97,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Builder serialize(Builder builder) { super.serialize(builder); if (this.profile != null) { -- return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile)); -+ return builder.put(SKULL_OWNER.BUKKIT, new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile)); // Paper +- return builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile)); ++ return builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile)); // Paper } NamespacedKey namespacedKeyNB = this.getNoteBlockSound(); if (namespacedKeyNB != null) { diff --git a/patches/server/Add-sun-related-API.patch b/patches/server/Add-sun-related-API.patch index 37c83bf5c7..7af3182a95 100644 --- a/patches/server/Add-sun-related-API.patch +++ b/patches/server/Add-sun-related-API.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public long getGameTime() { - return world.levelData.getGameTime(); + return this.world.levelData.getGameTime(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java diff --git a/patches/server/Add-velocity-warnings.patch b/patches/server/Add-velocity-warnings.patch index 814b5c62d6..db3130fa20 100644 --- a/patches/server/Add-velocity-warnings.patch +++ b/patches/server/Add-velocity-warnings.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end this.entity.setDeltaMovement(CraftVector.toNMS(velocity)); - entity.hurtMarked = true; + this.entity.hurtMarked = true; } + // Paper start diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 11a201ce9d..cc75a3abc2 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2500,7 +2500,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + } else if (false) { // Paper Player player = this.getCraftPlayer(); - AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(server)); + AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server)); String originalFormat = event.getFormat(), originalMessage = event.getMessage(); @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } @@ -2555,8 +2555,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftIconCache icon = server.server.getServerIcon(); ServerListPingEvent() { -- super(connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); -+ super(connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), server.server.motd(), server.getPlayerList().getMaxPlayers()); // Paper - Adventure +- super(ServerStatusPacketListenerImpl.this.connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); ++ super(ServerStatusPacketListenerImpl.this.connection.hostname, ((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), server.server.motd(), server.getPlayerList().getMaxPlayers()); // Paper - Adventure } @Override @@ -2979,7 +2979,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); } @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return Thread.currentThread().equals(console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) + return Thread.currentThread().equals(this.console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) } + // Paper start - Adventure @@ -3337,9 +3337,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - // Lazy initialization: - Component[] messages = this.signText.getMessages(false); - this.lines = new String[messages.length]; -- System.arraycopy(CraftSign.revertComponents(messages), 0, lines, 0, lines.length); -- this.originalLines = new String[lines.length]; -- System.arraycopy(lines, 0, originalLines, 0, originalLines.length); +- System.arraycopy(CraftSign.revertComponents(messages), 0, this.lines, 0, this.lines.length); +- this.originalLines = new String[this.lines.length]; +- System.arraycopy(this.lines, 0, this.originalLines, 0, this.originalLines.length); - } - return this.lines; + // Paper start @@ -3372,7 +3372,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public SignText applyLegacyStringToSignSide() { if (this.lines != null) { -- for (int i = 0; i < lines.length; i++) { +- for (int i = 0; i < this.lines.length; i++) { - String line = (this.lines[i] == null) ? "" : this.lines[i]; - if (line.equals(this.originalLines[i])) { + // Paper start @@ -3656,7 +3656,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setDisplayName(final String name) { + this.getHandle().adventure$displayName = name != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(name) : net.kyori.adventure.text.Component.text(this.getName()); // Paper - this.getHandle().displayName = name == null ? getName() : name; + this.getHandle().displayName = name == null ? this.getName() : name; } + // Paper start @@ -3684,7 +3684,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end @Override public String getPlayerListName() { - return this.getHandle().listName == null ? getName() : CraftChatMessage.fromComponent(this.getHandle().listName); + return this.getHandle().listName == null ? this.getName() : CraftChatMessage.fromComponent(this.getHandle().listName); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } @@ -3696,14 +3696,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public String getPlayerListHeader() { -- return (this.playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); -+ return (this.playerListHeader == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListHeader); +- return (this.playerListHeader == null) ? null : CraftChatMessage.fromComponent(this.playerListHeader); ++ return (this.playerListHeader == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.playerListHeader); } @Override public String getPlayerListFooter() { -- return (this.playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter); -+ return (this.playerListFooter == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListFooter); // Paper - Adventure +- return (this.playerListFooter == null) ? null : CraftChatMessage.fromComponent(this.playerListFooter); ++ return (this.playerListFooter == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.playerListFooter); // Paper - Adventure } @Override @@ -4178,7 +4178,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public String getTitle() { - return title; + return this.title; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -4583,7 +4583,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public String getDisplayName() { - return CraftChatMessage.fromJSONComponent(displayName); + return CraftChatMessage.fromJSONComponent(this.displayName); @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { return this.lore != null && !this.lore.isEmpty(); } @@ -4740,7 +4740,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftMapRenderer extends MapRenderer { } - MapDecoration decoration = worldMap.decorations.get(key); + MapDecoration decoration = this.worldMap.decorations.get(key); - cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, CraftChatMessage.fromComponent(decoration.name())); + cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, decoration.name() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(decoration.name())); // Paper } @@ -4978,14 +4978,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - HashSet makeReference() { + protected HashSet makeReference() { // Paper - protected - Preconditions.checkState(reference == null, "Reference already created!"); - List players = this.server.getPlayerList().players; + Preconditions.checkState(this.reference == null, "Reference already created!"); +- List players = this.server.getPlayerList().players; + // Paper start + return makePlayerSet(this.server); + } + public static HashSet makePlayerSet(final MinecraftServer server) { -+ // Paper end + List players = server.getPlayerList().players; ++ // Paper end HashSet reference = new HashSet(players.size()); for (ServerPlayer player : players) { reference.add(player.getBukkitEntity()); diff --git a/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch b/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch index da66e3dd55..4318fc1bdd 100644 --- a/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch +++ b/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean isSlimeChunk() { // 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk -- return WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; +- return WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), this.worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; + return this.worldServer.paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; // Paper } diff --git a/patches/server/Allow-changing-bed-s-occupied-property.patch b/patches/server/Allow-changing-bed-s-occupied-property.patch index a855243dbf..30d0af2232 100644 --- a/patches/server/Allow-changing-bed-s-occupied-property.patch +++ b/patches/server/Allow-changing-bed-s-occupied-property.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java @@ -0,0 +0,0 @@ public abstract class CraftBed extends CraftBlockData implements Bed { public boolean isOccupied() { - return get(CraftBed.OCCUPIED); + return this.get(CraftBed.OCCUPIED); } + + // Paper start @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java @@ -0,0 +0,0 @@ public final class CraftBed extends org.bukkit.craftbukkit.block.data.CraftBlock public java.util.Set getFaces() { - return getValues(CraftBed.FACING, org.bukkit.block.BlockFace.class); + return this.getValues(CraftBed.FACING, org.bukkit.block.BlockFace.class); } + + // Paper start diff --git a/patches/server/Allow-for-toggling-of-spawn-chunks.patch b/patches/server/Allow-for-toggling-of-spawn-chunks.patch index f9959c7fcc..0585456d4b 100644 --- a/patches/server/Allow-for-toggling-of-spawn-chunks.patch +++ b/patches/server/Allow-for-toggling-of-spawn-chunks.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { }); // CraftBukkit end - timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings + this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings + this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); + this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); } diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index de179d4fbb..65bd1d8729 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1173,8 +1173,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.generator = gen; @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); + this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray } diff --git a/patches/server/Cache-user-authenticator-threads.patch b/patches/server/Cache-user-authenticator-threads.patch index cebf07fab6..3155b62c43 100644 --- a/patches/server/Cache-user-authenticator-threads.patch +++ b/patches/server/Cache-user-authenticator-threads.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void run() { try { @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + ServerLoginPacketListenerImpl.this.requestedUsername, ex); + ServerLoginPacketListenerImpl.this.server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + ServerLoginPacketListenerImpl.this.requestedUsername, ex); } } - }.start(); diff --git a/patches/server/Change-EnderEye-target-without-changing-other-things.patch b/patches/server/Change-EnderEye-target-without-changing-other-things.patch index f34a97e3fa..7f32a5cfa7 100644 --- a/patches/server/Change-EnderEye-target-without-changing-other-things.patch +++ b/patches/server/Change-EnderEye-target-without-changing-other-things.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void setTargetLocation(Location location, boolean update) { + // Paper end - Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds"); + Preconditions.checkArgument(this.getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds"); - this.getHandle().signalTo(CraftLocation.toBlockPosition(location)); + this.getHandle().signalTo(CraftLocation.toBlockPosition(location), update); // Paper } diff --git a/patches/server/Collision-optimisations.patch b/patches/server/Collision-optimisations.patch index dbb9cba805..e9be3a5300 100644 --- a/patches/server/Collision-optimisations.patch +++ b/patches/server/Collision-optimisations.patch @@ -2633,8 +2633,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); + this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray + // Paper start - optimise collisions + this.minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); diff --git a/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch b/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch index f288f46579..4742ce1f2a 100644 --- a/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -198,13 +198,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setKeepSpawnInMemory(boolean keepLoaded) { -- world.keepSpawnInMemory = keepLoaded; + // Paper start - Configurable spawn radius -+ if (keepLoaded == world.keepSpawnInMemory) { ++ if (keepLoaded == this.world.keepSpawnInMemory) { + // do nothing, nothing has changed + return; + } -+ this.world.keepSpawnInMemory = keepLoaded; + this.world.keepSpawnInMemory = keepLoaded; // Grab the worlds spawn chunk BlockPos chunkcoordinates = this.world.getSharedSpawnPos(); if (keepLoaded) { diff --git a/patches/server/Configurable-inter-world-teleportation-safety.patch b/patches/server/Configurable-inter-world-teleportation-safety.patch index 56f926c29b..388370b1ab 100644 --- a/patches/server/Configurable-inter-world-teleportation-safety.patch +++ b/patches/server/Configurable-inter-world-teleportation-safety.patch @@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entity.connection.teleport(to); } else { // The respawn reason should never be used if the passed location is non null. -- server.getHandle().respawn(entity, toWorld, true, to, true, null); -+ server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper +- this.server.getHandle().respawn(entity, toWorld, true, to, true, null); ++ this.server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper } return true; } diff --git a/patches/server/Convert-legacy-attributes-in-Item-Meta.patch b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch index 05d5c5daeb..450ae58c26 100644 --- a/patches/server/Convert-legacy-attributes-in-Item-Meta.patch +++ b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch @@ -37,8 +37,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier); -- String attributeName = entry.getString(ATTRIBUTES_IDENTIFIER.NBT); -+ String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper +- String attributeName = entry.getString(CraftMetaItem.ATTRIBUTES_IDENTIFIER.NBT); ++ String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(CraftMetaItem.ATTRIBUTES_IDENTIFIER.NBT)); // Paper if (attributeName == null || attributeName.isEmpty()) { continue; } diff --git a/patches/server/Disable-spigot-tick-limiters.patch b/patches/server/Disable-spigot-tick-limiters.patch index 3f12790ffb..bd1a33b06d 100644 --- a/patches/server/Disable-spigot-tick-limiters.patch +++ b/patches/server/Disable-spigot-tick-limiters.patch @@ -17,5 +17,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.tileTickPosition++, tilesThisCycle++) { + for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; - TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); + TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); // Spigot start diff --git a/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch b/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch index a39ca1fa55..3f28e7a50c 100644 --- a/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch +++ b/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch @@ -12,9 +12,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } this.commandsConfiguration = YamlConfiguration.loadConfiguration(this.getCommandsConfigFile()); this.commandsConfiguration.options().copyDefaults(true); -- this.commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); +- this.commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); + // Paper start - don't enforce icanhasbukkit default if alias block exists -+ final YamlConfiguration commandsDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8)); ++ final YamlConfiguration commandsDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8)); + if (this.commandsConfiguration.contains("aliases")) commandsDefaults.set("aliases", null); + this.commandsConfiguration.setDefaults(commandsDefaults); + // Paper stop - dont enforce icanhasbukkit default if alias block exists diff --git a/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch b/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch index 38f3f983bf..d1011abe68 100644 --- a/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch +++ b/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } itemstack.addTagElement("pages", nbttaglist); -- CraftEventFactory.handleEditBookEvent(player, slot, handItem, itemstack); // CraftBukkit -+ this.player.getInventory().setItem(slot, CraftEventFactory.handleEditBookEvent(player, slot, handItem, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent) +- CraftEventFactory.handleEditBookEvent(this.player, slot, handItem, itemstack); // CraftBukkit ++ this.player.getInventory().setItem(slot, CraftEventFactory.handleEditBookEvent(this.player, slot, handItem, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent) } @Override diff --git a/patches/server/Don-t-tick-markers.patch b/patches/server/Don-t-tick-markers.patch index 192694b840..2ac631d5c4 100644 --- a/patches/server/Don-t-tick-markers.patch +++ b/patches/server/Don-t-tick-markers.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ActivationRange // Paper start - java.util.List entities = world.getEntities((Entity)null, maxBB, null); + java.util.List entities = world.getEntities((Entity)null, ActivationRange.maxBB, null); + boolean tickMarkers = world.paperConfig().entities.markers.tick; // Paper - configurable marker ticking for (int i = 0; i < entities.size(); i++) { Entity entity = entities.get(i); diff --git a/patches/server/Entity-Activation-Range-2.0.patch b/patches/server/Entity-Activation-Range-2.0.patch index d24b803a52..b08bc1377b 100644 --- a/patches/server/Entity-Activation-Range-2.0.patch +++ b/patches/server/Entity-Activation-Range-2.0.patch @@ -565,7 +565,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end // Paper start - java.util.List entities = world.getEntities((Entity)null, maxBB, null); + java.util.List entities = world.getEntities((Entity)null, ActivationRange.maxBB, null); @@ -0,0 +0,0 @@ public class ActivationRange * @param entity * @return diff --git a/patches/server/Expand-world-key-API.patch b/patches/server/Expand-world-key-API.patch index eb642a04b1..b91f67933d 100644 --- a/patches/server/Expand-world-key-API.patch +++ b/patches/server/Expand-world-key-API.patch @@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + worldKey = ResourceKey.create(Registries.DIMENSION, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper } - ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11), + ServerLevel internal = (ServerLevel) new ServerLevel(this.console, this.console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11), @@ -0,0 +0,0 @@ public final class CraftServer implements Server { return null; } diff --git a/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch index e98fcb4db8..82375ed55d 100644 --- a/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch +++ b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch @@ -358,4 +358,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public net.minecraft.world.entity.ExperienceOrb getHandle() { - return (net.minecraft.world.entity.ExperienceOrb) entity; + return (net.minecraft.world.entity.ExperienceOrb) this.entity; diff --git a/patches/server/Expose-isFuel-and-canSmelt-methods-to-FurnaceInvento.patch b/patches/server/Expose-isFuel-and-canSmelt-methods-to-FurnaceInvento.patch index 5f75625e7f..b2845a01ec 100644 --- a/patches/server/Expose-isFuel-and-canSmelt-methods-to-FurnaceInvento.patch +++ b/patches/server/Expose-isFuel-and-canSmelt-methods-to-FurnaceInvento.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryFurnace.java @@ -0,0 +0,0 @@ public class CraftInventoryFurnace extends CraftInventory implements FurnaceInve - setItem(0, stack); + this.setItem(0, stack); } + // Paper start @@ -28,4 +28,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public Furnace getHolder() { - return (Furnace) inventory.getOwner(); + return (Furnace) this.inventory.getOwner(); diff --git a/patches/server/Extend-block-drop-capture-to-capture-all-items-added.patch b/patches/server/Extend-block-drop-capture-to-capture-all-items-added.patch index a1f1777525..5814fae61c 100644 --- a/patches/server/Extend-block-drop-capture-to-capture-all-items-added.patch +++ b/patches/server/Extend-block-drop-capture-to-capture-all-items-added.patch @@ -30,14 +30,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // return true; // CraftBukkit } // CraftBukkit start -+ java.util.List itemsToDrop = level.captureDrops; // Paper - store current list -+ level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff ++ java.util.List itemsToDrop = this.level.captureDrops; // Paper - store current list ++ this.level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff if (event.isDropItems()) { -- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops); +- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, this.level.captureDrops); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref } -- level.captureDrops = null; -+ //world.captureDrops = null; // Paper - move up +- this.level.captureDrops = null; ++ //this.level.captureDrops = null; // Paper - move up // Drop event experience if (flag && event != null) { diff --git a/patches/server/Fix-BanList-API.patch b/patches/server/Fix-BanList-API.patch index 97c6e934fa..49acfb1302 100644 --- a/patches/server/Fix-BanList-API.patch +++ b/patches/server/Fix-BanList-API.patch @@ -234,9 +234,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public BanEntry ban(String reason, Date expires, String source, boolean kickPlayer) { -- BanEntry banEntry = ((ProfileBanList) server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source); +- BanEntry banEntry = ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source); + public BanEntry ban(String reason, Date expires, String source, boolean kickPlayer) { // Paper - fix ban list API -+ BanEntry banEntry = ((ProfileBanList) server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source); // Paper - fix ban list API ++ BanEntry banEntry = ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source); // Paper - fix ban list API if (kickPlayer) { this.kickPlayer(reason); } diff --git a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch index 099f95874b..8707d03373 100644 --- a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch +++ b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end LevelLightEngine lightengine = this.worldServer.getLightEngine(); - DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(x, chunk.getSectionYFromSectionIndex(i), z)); // SPIGOT-7498: Convert section index + DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(this.x, chunk.getSectionYFromSectionIndex(i), this.z)); // SPIGOT-7498: Convert section index @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { } diff --git a/patches/server/Fix-MC-117075-TE-Unload-Lag-Spike.patch b/patches/server/Fix-MC-117075-TE-Unload-Lag-Spike.patch index b62b476ad4..a64a204b55 100644 --- a/patches/server/Fix-MC-117075-TE-Unload-Lag-Spike.patch +++ b/patches/server/Fix-MC-117075-TE-Unload-Lag-Spike.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + toRemove.add(null); for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; - TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); + TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (tickingblockentity == null) { this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash"); @@ -38,5 +38,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + this.blockEntityTickers.removeAll(toRemove); - timings.tileEntityTick.stopTiming(); // Spigot + this.timings.tileEntityTick.stopTiming(); // Spigot this.tickingBlockEntities = false; diff --git a/patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch b/patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch index b053859c5f..1a3c35ddcc 100644 --- a/patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch +++ b/patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public SculkCatalystBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.SCULK_CATALYST, pos, state); this.catalystListener = new SculkCatalystBlockEntity.CatalystListener(state, new BlockPositionSource(pos)); -- catalystListener.level = level; // CraftBukkit +- this.catalystListener.level = this.level; // CraftBukkit } + // Paper start diff --git a/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch index 29b912251b..749bf8e845 100644 --- a/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch +++ b/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch @@ -106,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot + org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); for (ServerLevel world : this.console.getAllLevels()) { - world.serverLevelData.setDifficulty(config.difficulty); diff --git a/patches/server/Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch b/patches/server/Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch index b00a21dc5c..38101fdbe8 100644 --- a/patches/server/Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch +++ b/patches/server/Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch @@ -29,9 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean setSpawnLocation(int x, int y, int z, float angle) { try { - Location previousLocation = this.getSpawnLocation(); -- world.levelData.setSpawn(new BlockPos(x, y, z), angle); +- this.world.levelData.setSpawn(new BlockPos(x, y, z), angle); + // Location previousLocation = this.getSpawnLocation(); // Paper - moved to nms.ServerLevel -+ world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos ++ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos + // Paper start - move to nms.ServerLevel // Notify anyone who's listening. diff --git a/patches/server/Fix-and-optimise-world-force-upgrading.patch b/patches/server/Fix-and-optimise-world-force-upgrading.patch index d5fb1171c2..cff3045893 100644 --- a/patches/server/Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/Fix-and-optimise-world-force-upgrading.patch @@ -367,8 +367,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worlddata.checkName(name); worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().shouldReportAsModified()); -- if (console.options.has("forceUpgrade")) { -- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> true, iregistry); +- if (this.console.options.has("forceUpgrade")) { +- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.console.options.has("eraseCache"), () -> true, iregistry); - } + // Paper - move down @@ -379,9 +379,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - fix and optimise world upgrading -+ if (console.options.has("forceUpgrade")) { ++ if (this.console.options.has("forceUpgrade")) { + net.minecraft.server.Main.convertWorldButItWorks( -+ actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), console.options.has("eraseCache") ++ actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), this.console.options.has("eraseCache") + ); + } + // Paper end - fix and optimise world upgrading diff --git a/patches/server/Fix-beehives-generating-from-using-bonemeal.patch b/patches/server/Fix-beehives-generating-from-using-bonemeal.patch index 5944ada8af..05bdada235 100644 --- a/patches/server/Fix-beehives-generating-from-using-bonemeal.patch +++ b/patches/server/Fix-beehives-generating-from-using-bonemeal.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void checkTreeBlockHack() { + // Paper end // SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles - if (this.treeBlock && getType() == Material.BEE_NEST) { + if (this.treeBlock && this.getType() == Material.BEE_NEST) { WorldGenLevel generatoraccessseed = this.world.getHandle(); @@ -0,0 +0,0 @@ public final class CapturedBlockState extends CraftBlockState { // End copied block diff --git a/patches/server/Fix-falling-block-spawn-methods.patch b/patches/server/Fix-falling-block-spawn-methods.patch index f301545951..d4dc8ab609 100644 --- a/patches/server/Fix-falling-block-spawn-methods.patch +++ b/patches/server/Fix-falling-block-spawn-methods.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Preconditions.checkArgument(material != null, "Material cannot be null"); Preconditions.checkArgument(material.isBlock(), "Material.%s must be a block", material); -- FallingBlockEntity entity = FallingBlockEntity.fall(world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); +- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); + // Paper start - restore API behavior for spawning falling blocks + FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); // Paper + entity.time = 1; @@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Preconditions.checkArgument(location != null, "Location cannot be null"); Preconditions.checkArgument(data != null, "BlockData cannot be null"); -- FallingBlockEntity entity = FallingBlockEntity.fall(world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM); +- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM); + // Paper start - restore API behavior for spawning falling blocks + FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState()); + entity.time = 1; diff --git a/patches/server/Fix-interact-event-not-being-called-sometimes.patch b/patches/server/Fix-interact-event-not-being-called-sometimes.patch index 0382d3bd21..30fdb02080 100644 --- a/patches/server/Fix-interact-event-not-being-called-sometimes.patch +++ b/patches/server/Fix-interact-event-not-being-called-sometimes.patch @@ -24,13 +24,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - double d3 = player.gameMode.getGameModeForPlayer() == GameType.CREATIVE ? 5.0D : 4.5D; + double d3 = this.player.gameMode.getGameModeForPlayer() == GameType.CREATIVE ? 5.0D : 4.5D; // SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time // SPIGOT-7429: Make sure to call PlayerInteractEvent for spectators and non-pickable entities - org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> { + org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.0, entity -> { // Paper - change raySize from 0.1 to 0.0 Entity handle = ((CraftEntity) entity).getHandle(); - return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(player); + return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player); }); if (result == null) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); diff --git a/patches/server/Fix-numerous-item-duplication-issues-and-teleport-is.patch b/patches/server/Fix-numerous-item-duplication-issues-and-teleport-is.patch index 6a46c7dab7..f49864e08d 100644 --- a/patches/server/Fix-numerous-item-duplication-issues-and-teleport-is.patch +++ b/patches/server/Fix-numerous-item-duplication-issues-and-teleport-is.patch @@ -120,8 +120,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { -- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops -+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe +- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops ++ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe this.handItems.set(i, ItemStack.EMPTY); } } @@ -129,8 +129,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { -- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops -+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe +- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops ++ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe this.armorItems.set(i, ItemStack.EMPTY); } } diff --git a/patches/server/Fix-sniffer-removeExploredLocation.patch b/patches/server/Fix-sniffer-removeExploredLocation.patch index 1940a43859..d7d9f6dc89 100644 --- a/patches/server/Fix-sniffer-removeExploredLocation.patch +++ b/patches/server/Fix-sniffer-removeExploredLocation.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void removeExploredLocation(Location location) { Preconditions.checkArgument(location != null, "location cannot be null"); -- if (location.getWorld() != getWorld()) { +- if (location.getWorld() != this.getWorld()) { - return; - } diff --git a/patches/server/Fix-upstreams-block-state-factories.patch b/patches/server/Fix-upstreams-block-state-factories.patch index 7a83c97a6d..cb0248cf3d 100644 --- a/patches/server/Fix-upstreams-block-state-factories.patch +++ b/patches/server/Fix-upstreams-block-state-factories.patch @@ -370,7 +370,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } private static BlockStateFactory getFactory(Material material) { - return CraftBlockStates.FACTORIES.getOrDefault(material, DEFAULT_FACTORY); + return CraftBlockStates.FACTORIES.getOrDefault(material, CraftBlockStates.DEFAULT_FACTORY); } + // Paper start diff --git a/patches/server/Flag-to-disable-the-channel-limit.patch b/patches/server/Flag-to-disable-the-channel-limit.patch index 28a4e04765..e8cbe56c1b 100644 --- a/patches/server/Flag-to-disable-the-channel-limit.patch +++ b/patches/server/Flag-to-disable-the-channel-limit.patch @@ -28,4 +28,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Preconditions.checkState(DISABLE_CHANNEL_LIMIT || this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel); // Paper - flag to disable channel limit channel = StandardMessenger.validateAndCorrectChannel(channel); if (this.channels.add(channel)) { - server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); + this.server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); diff --git a/patches/server/Further-improve-server-tick-loop.patch b/patches/server/Further-improve-server-tick-loop.patch index debf0da413..d5f8bc0988 100644 --- a/patches/server/Further-improve-server-tick-loop.patch +++ b/patches/server/Further-improve-server-tick-loop.patch @@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getEnchants() { -- return this.hasEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.of(); +- return this.hasEnchants() ? ImmutableMap.copyOf(this.enchantments) : ImmutableMap.of(); + return this.hasEnchants() ? ImmutableSortedMap.copyOfSorted(this.enchantments) : ImmutableMap.of(); // Paper } diff --git a/patches/server/Hide-unnecessary-itemmeta-from-clients.patch b/patches/server/Hide-unnecessary-itemmeta-from-clients.patch index 29d6654cb0..44a7c0ae30 100644 --- a/patches/server/Hide-unnecessary-itemmeta-from-clients.patch +++ b/patches/server/Hide-unnecessary-itemmeta-from-clients.patch @@ -23,13 +23,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Refresh the current entity metadata - entity.getEntityData().refresh(player); + entity.getEntityData().refresh(ServerGamePacketListenerImpl.this.player); // SPIGOT-7136 - Allays - if (entity instanceof Allay) { -- send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); +- ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); + if (entity instanceof Allay allay) { // Paper -+ send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, allay.stripMeta(allay.getItemBySlot(slot), true))).collect(Collectors.toList()))); // Paper - remove unnecessary item meta - player.containerMenu.sendAllDataToRemote(); ++ ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, allay.stripMeta(allay.getItemBySlot(slot), true))).collect(Collectors.toList()))); // Paper - remove unnecessary item meta + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); } } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/patches/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch index a44c585347..e79482f356 100644 --- a/patches/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - return new MethodVisitor( api, super.visitMethod( access, name, desc, signature, exceptions ) ) + return new MethodVisitor( this.api, super.visitMethod( access, name, desc, signature, exceptions ) ) { + // Paper start - Plugin rewrites + @Override diff --git a/patches/server/Ignore-inline-definitions-of-trim-material-pattern.patch b/patches/server/Ignore-inline-definitions-of-trim-material-pattern.patch index 9a467df3aa..151a7edc84 100644 --- a/patches/server/Ignore-inline-definitions-of-trim-material-pattern.patch +++ b/patches/server/Ignore-inline-definitions-of-trim-material-pattern.patch @@ -9,11 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java @@ -0,0 +0,0 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { - if (tag.contains(TRIM.NBT)) { - CompoundTag trimCompound = tag.getCompound(TRIM.NBT); + if (tag.contains(CraftMetaArmor.TRIM.NBT)) { + CompoundTag trimCompound = tag.getCompound(CraftMetaArmor.TRIM.NBT); -- if (trimCompound.contains(TRIM_MATERIAL.NBT) && trimCompound.contains(TRIM_PATTERN.NBT)) { -+ if (trimCompound.contains(TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern - TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT))); - TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT))); +- if (trimCompound.contains(CraftMetaArmor.TRIM_MATERIAL.NBT) && trimCompound.contains(CraftMetaArmor.TRIM_PATTERN.NBT)) { ++ if (trimCompound.contains(CraftMetaArmor.TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(CraftMetaArmor.TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern + TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_MATERIAL.NBT))); + TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_PATTERN.NBT))); diff --git a/patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch b/patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch index 49c921f61c..5cf3f135fc 100644 --- a/patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch +++ b/patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch @@ -59,4 +59,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public AbstractMinecart getHandle() { - return (AbstractMinecart) entity; + return (AbstractMinecart) this.entity; diff --git a/patches/server/Implement-OfflinePlayer-isConnected.patch b/patches/server/Implement-OfflinePlayer-isConnected.patch index 8f715dd011..3718c5f016 100644 --- a/patches/server/Implement-OfflinePlayer-isConnected.patch +++ b/patches/server/Implement-OfflinePlayer-isConnected.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return server.getPlayer(getUniqueId()) != null; + return this.server.getPlayer(this.getUniqueId()) != null; } + // Paper start diff --git a/patches/server/Implement-Player-Client-Options-API.patch b/patches/server/Implement-Player-Client-Options-API.patch index f088babc0c..4992c23751 100644 --- a/patches/server/Implement-Player-Client-Options-API.patch +++ b/patches/server/Implement-Player-Client-Options-API.patch @@ -121,8 +121,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void updateOptions(ClientInformation clientOptions) { + new com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent(getBukkitEntity(), getClientOptionMap(clientOptions.language(), clientOptions.viewDistance(), com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(clientOptions.chatVisibility().name()), clientOptions.chatColors(), new com.destroystokyo.paper.PaperSkinParts(clientOptions.modelCustomisation()), clientOptions.mainHand() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT, clientOptions.allowsListing(), clientOptions.textFilteringEnabled())).callEvent(); // Paper - settings event // CraftBukkit start - if (getMainArm() != clientOptions.mainHand()) { - PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT); + if (this.getMainArm() != clientOptions.mainHand()) { + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), this.getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT); @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.language, clientOptions.language())); // Paper } diff --git a/patches/server/Implement-PlayerLocaleChangeEvent.patch b/patches/server/Implement-PlayerLocaleChangeEvent.patch index 306b55119e..a967559137 100644 --- a/patches/server/Implement-PlayerLocaleChangeEvent.patch +++ b/patches/server/Implement-PlayerLocaleChangeEvent.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.chunkTrackingView = ChunkTrackingView.EMPTY; this.respawnDimension = Level.OVERWORLD; @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { - PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT); + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), this.getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT); this.server.server.getPluginManager().callEvent(event); } - if (!this.language.equals(clientOptions.language())) { diff --git a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index 1d6652dd7a..11b09aafce 100644 --- a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(internal)); @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (this.hasDamage()) { - itemTag.putInt(DAMAGE.NBT, damage); + itemTag.putInt(CraftMetaItem.DAMAGE.NBT, this.damage); } + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + if (hasPlaceableKeys()) { @@ -221,7 +221,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } catch (CloneNotSupportedException e) { throw new Error(e); @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - builder.put(DAMAGE.BUKKIT, damage); + builder.put(CraftMetaItem.DAMAGE.BUKKIT, this.damage); } + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values diff --git a/patches/server/Improve-Block-breakNaturally-API.patch b/patches/server/Improve-Block-breakNaturally-API.patch index 78421f2cd3..7e7f26c0b8 100644 --- a/patches/server/Improve-Block-breakNaturally-API.patch +++ b/patches/server/Improve-Block-breakNaturally-API.patch @@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftBlock implements Block { // Modelled off EntityHuman#hasBlock if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) { - net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), position, this.world.getBlockEntity(position), null, nmsItem); + net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem); + // Paper start - improve Block#breanNaturally + if (triggerEffect) { + if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) { @@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // SPIGOT-6778: Directly call setBlock instead of setTypeAndData, so that the tile entiy is not removed and custom remove logic is run. -- return this.world.setBlock(position, Blocks.AIR.defaultBlockState(), 3) && result; +- return this.world.setBlock(this.position, Blocks.AIR.defaultBlockState(), 3) && result; + // Paper start - improve breakNaturally + boolean destroyed = this.world.removeBlock(this.position, false); + if (destroyed) { diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 80c1bce753..0cac131542 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -354,7 +354,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { } - drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops + this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.brokenByAnything(damageSource); + return this.brokenByAnything(damageSource); // Paper } @@ -377,7 +377,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void kill() { -- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event +- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, this.drops); // CraftBukkit - call event + // Paper start + kill(true); + } @@ -385,7 +385,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void kill(boolean callEvent) { + if (callEvent) { + // Paper end -+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event // Paper - make cancellable ++ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, this.drops); // CraftBukkit - call event // Paper - make cancellable + if (event.isCancelled()) return; // Paper - make cancellable + } // Paper this.remove(Entity.RemovalReason.KILLED); diff --git a/patches/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch index f49f7ea673..a4fc2ebcc0 100644 --- a/patches/server/Improved-Watchdog-Support.patch +++ b/patches/server/Improved-Watchdog-Support.patch @@ -167,7 +167,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + org.spigotmc.WatchdogThread.tick(); // Paper org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Arrays.fill( recentTps, 20 ); + Arrays.fill( this.recentTps, 20 ); long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(list.size()); for (int index = 0; index < list.size(); index++) { - String line = limit( list.getString(index), 8192 ); // Spigot diff --git a/patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch b/patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch index 298b956041..1ea3f7595f 100644 --- a/patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch +++ b/patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -0,0 +0,0 @@ public class CraftFireball extends AbstractProjectile implements Fireball { - update(); // SPIGOT-6579 + this.update(); // SPIGOT-6579 } + // Paper start - set direction without normalizing @@ -27,4 +27,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public AbstractHurtingProjectile getHandle() { - return (AbstractHurtingProjectile) entity; + return (AbstractHurtingProjectile) this.entity; diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index 87e2124f14..b3dbfa18f8 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -633,7 +633,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public EnderMan getHandle() { - return (EnderMan) entity; + return (EnderMan) this.entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -793,7 +793,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -0,0 +0,0 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements public void setEnabled(boolean enabled) { - ((MinecartHopper) getHandle()).setEnabled(enabled); + ((MinecartHopper) this.getHandle()).setEnabled(enabled); } + // Paper start + @Override diff --git a/patches/server/Mob-Pathfinding-API.patch b/patches/server/Mob-Pathfinding-API.patch index 4b7a40cdb9..a60d3d85cc 100644 --- a/patches/server/Mob-Pathfinding-API.patch +++ b/patches/server/Mob-Pathfinding-API.patch @@ -188,7 +188,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void setTarget(LivingEntity target) { Preconditions.checkState(!this.getHandle().generation, "Cannot set target during world generation"); @@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { - return (net.minecraft.world.entity.Mob) entity; + return (net.minecraft.world.entity.Mob) this.entity; } + // Paper start diff --git a/patches/server/More-Lidded-Block-API.patch b/patches/server/More-Lidded-Block-API.patch index cc88e951c5..93b5f12ea4 100644 --- a/patches/server/More-Lidded-Block-API.patch +++ b/patches/server/More-Lidded-Block-API.patch @@ -57,13 +57,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -0,0 +0,0 @@ public class CraftShulkerBox extends CraftLootable implem - if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.Level) { - net.minecraft.world.level.Level world = getTileEntity().getLevel(); - world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0); -- world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); -+ world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound) + if (this.getTileEntity().opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) { + net.minecraft.world.level.Level world = this.getTileEntity().getLevel(); + world.blockEvent(this.getPosition(), this.getTileEntity().getBlockState().getBlock(), 1, 0); +- world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); ++ world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound) } - getTileEntity().opened = false; + this.getTileEntity().opened = false; } @@ -0,0 +0,0 @@ public class CraftShulkerBox extends CraftLootable implem public CraftShulkerBox copy() { diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index 318a835285..9be584afaa 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -469,7 +469,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end @Override public net.minecraft.world.entity.projectile.ThrownPotion getHandle() { - return (net.minecraft.world.entity.projectile.ThrownPotion) entity; + return (net.minecraft.world.entity.projectile.ThrownPotion) this.entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index ea919db518..8921c93074 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -211,4 +211,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), relativeArguments); // Paper - Teleport API } else { // The respawn reason should never be used if the passed location is non null. - server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper + this.server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper diff --git a/patches/server/Multiple-Entries-with-Scoreboards.patch b/patches/server/Multiple-Entries-with-Scoreboards.patch index a22d70e092..3b45224e16 100644 --- a/patches/server/Multiple-Entries-with-Scoreboards.patch +++ b/patches/server/Multiple-Entries-with-Scoreboards.patch @@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -0,0 +0,0 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { - scoreboard.board.addPlayerToTeam(entry, team); + scoreboard.board.addPlayerToTeam(entry, this.team); } + // Paper start diff --git a/patches/server/Name-craft-scheduler-threads-according-to-the-plugin.patch b/patches/server/Name-craft-scheduler-threads-according-to-the-plugin.patch index 436bf7f50f..276cebb045 100644 --- a/patches/server/Name-craft-scheduler-threads-according-to-the-plugin.patch +++ b/patches/server/Name-craft-scheduler-threads-according-to-the-plugin.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final String nameBefore = thread.getName(); + thread.setName(nameBefore + " - " + this.getOwner().getName()); + try { synchronized (this.workers) { // Paper end - name threads according to running plugin - if (getPeriod() == CraftTask.CANCEL) { + if (this.getPeriod() == CraftTask.CANCEL) { // Never continue running after cancelled. // Checking this with the lock is important! @@ -0,0 +0,0 @@ class CraftAsyncTask extends CraftTask { diff --git a/patches/server/Optimise-getType-calls.patch b/patches/server/Optimise-getType-calls.patch index d99d13ba42..da67e1165f 100644 --- a/patches/server/Optimise-getType-calls.patch +++ b/patches/server/Optimise-getType-calls.patch @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Material getType() { -- return CraftMagicNumbers.getMaterial(this.world.getBlockState(position).getBlock()); +- return CraftMagicNumbers.getMaterial(this.world.getBlockState(this.position).getBlock()); + return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls } diff --git a/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch index 3c037886f8..6989e14c70 100644 --- a/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch +++ b/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch @@ -112,8 +112,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addToCraftingManager() { ItemStack result = this.getResult(); -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt()))); // Paper +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt()))); // Paper } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java @@ -141,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void addToCraftingManager() { -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), this.willCopyNbt()))); // Paper +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true)))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyNbt()))); // Paper } } diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index 3211b0582c..967b11f0c9 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -7013,7 +7013,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void loadPlugins() { - this.pluginManager.registerInterface(JavaPluginLoader.class); - -- File pluginFolder = (File) console.options.valueOf("plugins"); +- File pluginFolder = (File) this.console.options.valueOf("plugins"); - - if (pluginFolder.exists()) { - Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder); diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 733056ff4f..8fcc932731 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -4836,7 +4836,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - org.spigotmc.SpigotConfig.init((java.io.File) options.valueOf("spigot-settings")); + org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); // Spigot end + // Paper start @@ -4906,7 +4906,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class CraftServer implements Server { } - org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot + org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot + this.console.paperConfigurations.reloadConfigs(this.console); for (ServerLevel world : this.console.getAllLevels()) { world.serverLevelData.setDifficulty(config.difficulty); diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index dd9ca2ec14..09f3f82586 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return server.getPlayer(getUniqueId()) != null; + return this.server.getPlayer(this.getUniqueId()) != null; } - @Override @@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } - -- server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity)); +- this.server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity)); } void resetAndHideEntity(org.bukkit.entity.Entity entity) { @@ -124,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId()); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); + this.server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); } + // Paper start + @Override diff --git a/patches/server/PlayerNaturallySpawnCreaturesEvent.patch b/patches/server/PlayerNaturallySpawnCreaturesEvent.patch index c85410ff9f..8469934e40 100644 --- a/patches/server/PlayerNaturallySpawnCreaturesEvent.patch +++ b/patches/server/PlayerNaturallySpawnCreaturesEvent.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; + chunkRange = (chunkRange > this.level.spigotConfig.viewDistance) ? (byte) this.level.spigotConfig.viewDistance : chunkRange; chunkRange = (chunkRange > 8) ? 8 : chunkRange; - double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; diff --git a/patches/server/Properly-resend-entities.patch b/patches/server/Properly-resend-entities.patch index 3c9e05dd92..414992a3be 100644 --- a/patches/server/Properly-resend-entities.patch +++ b/patches/server/Properly-resend-entities.patch @@ -89,9 +89,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { -- send(new ClientboundAddEntityPacket(entity)); +- ServerGamePacketListenerImpl.this.send(new ClientboundAddEntityPacket(entity)); + entity.getEntityData().resendPossiblyDesyncedEntity(player); // Paper - The entire mob gets deleted, so resend it. - player.containerMenu.sendAllDataToRemote(); + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/patches/server/Put-world-into-worldlist-before-initing-the-world.patch b/patches/server/Put-world-into-worldlist-before-initing-the-world.patch index cf12637cc8..5febe06357 100644 --- a/patches/server/Put-world-into-worldlist-before-initing-the-world.patch +++ b/patches/server/Put-world-into-worldlist-before-initing-the-world.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); + this.addLevel(world); // Paper - move up - this.initWorld(world, worlddata, worldData, worldoptions); + this.initWorld(world, worlddata, this.worldData, worldoptions); - this.addLevel(world); + // Paper - move up diff --git a/patches/server/Remap-fixes.patch b/patches/server/Remap-fixes.patch index 61df6859b6..3233483441 100644 --- a/patches/server/Remap-fixes.patch +++ b/patches/server/Remap-fixes.patch @@ -88,36 +88,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private LootContextParamSet paramSet; private Optional randomSequence; -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java -@@ -0,0 +0,0 @@ public abstract class CraftParticle implements Keyed { - private static final BiFunction, CraftParticle> VOID_FUNCTION = (name, particle) -> new CraftParticle<>(name, particle, Void.class) { - @Override - public ParticleOptions createParticleParam(Void data) { -- return (SimpleParticleType) CraftParticle.this.getHandle(); -+ return (SimpleParticleType) this.getHandle(); // Paper - fix? - } - }; - -@@ -0,0 +0,0 @@ public abstract class CraftParticle implements Keyed { - BiFunction, CraftParticle> itemStackFunction = (name, particle) -> new CraftParticle<>(name, particle, ItemStack.class) { - @Override - public ParticleOptions createParticleParam(ItemStack data) { -- return new ItemParticleOption((net.minecraft.core.particles.ParticleType) CraftParticle.this.getHandle(), CraftItemStack.asNMSCopy(data)); -+ return new ItemParticleOption((net.minecraft.core.particles.ParticleType) this.getHandle(), CraftItemStack.asNMSCopy(data)); // Paper - fix? - } - }; - - BiFunction, CraftParticle> blockDataFunction = (name, particle) -> new CraftParticle<>(name, particle, BlockData.class) { - @Override - public ParticleOptions createParticleParam(BlockData data) { -- return new BlockParticleOption((net.minecraft.core.particles.ParticleType) CraftParticle.this.getHandle(), ((CraftBlockData) data).getState()); -+ return new BlockParticleOption((net.minecraft.core.particles.ParticleType) this.getHandle(), ((CraftBlockData) data).getState()); // Paper - fix? - } - }; - diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/DyeColorsTest.java diff --git a/patches/server/Restore-custom-InventoryHolder-support.patch b/patches/server/Restore-custom-InventoryHolder-support.patch index 4a6594578c..921ffceb16 100644 --- a/patches/server/Restore-custom-InventoryHolder-support.patch +++ b/patches/server/Restore-custom-InventoryHolder-support.patch @@ -183,12 +183,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end @@ -0,0 +0,0 @@ public class CraftContainer extends AbstractContainerMenu { - this.lastSlots = delegate.lastSlots; - this.slots = delegate.slots; - this.remoteSlots = delegate.remoteSlots; + this.lastSlots = this.delegate.lastSlots; + this.slots = this.delegate.slots; + this.remoteSlots = this.delegate.remoteSlots; + // Paper start - copy data slots for InventoryView#set/getProperty -+ this.dataSlots = delegate.dataSlots; -+ this.remoteDataSlots = delegate.remoteDataSlots; ++ this.dataSlots = this.delegate.dataSlots; ++ this.remoteDataSlots = this.delegate.remoteDataSlots; + // Paper end } diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 5428b0cb6d..d2822da84b 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -16767,7 +16767,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { if (!this.initServer()) { @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entityManager = this.getCraftWorld().getHandle().entityManager; -- long pair = ChunkPos.asLong(x, z); +- long pair = ChunkPos.asLong(this.x, this.z); - - if (entityManager.areEntitiesLoaded(pair)) { - return entityManager.getEntities(new ChunkPos(this.x, this.z)).stream() @@ -22647,7 +22647,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - return entityManager.getEntities(new ChunkPos(this.x, this.z)).stream() - .map(net.minecraft.world.entity.Entity::getBukkitEntity) - .filter(Objects::nonNull).toArray(Entity[]::new); -+ return getCraftWorld().getHandle().getChunkEntities(this.x, this.z); // Paper - rewrite chunk system ++ return this.getCraftWorld().getHandle().getChunkEntities(this.x, this.z); // Paper - rewrite chunk system } @Override @@ -22677,7 +22677,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean isPrimaryThread() { -- return Thread.currentThread().equals(console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) +- return Thread.currentThread().equals(this.console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) + return io.papermc.paper.util.TickThread.isTickThread(); // Paper - rewrite chunk system } @@ -22749,13 +22749,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot start @Override public int getViewDistance() { -- return world.spigotConfig.viewDistance; +- return this.world.spigotConfig.viewDistance; + return this.getHandle().playerChunkLoader.getAPIViewDistance(); // Paper - replace player chunk loader } @Override public int getSimulationDistance() { -- return world.spigotConfig.simulationDistance; +- return this.world.spigotConfig.simulationDistance; + return this.getHandle().playerChunkLoader.getAPITickDistance(); // Paper - replace player chunk loader } // Spigot end @@ -22947,9 +22947,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ActivationType.ANIMAL.boundingBox = player.getBoundingBox().inflate( animalActivationRange, 256, animalActivationRange ); ActivationType.MONSTER.boundingBox = player.getBoundingBox().inflate( monsterActivationRange, 256, monsterActivationRange ); -- world.getEntities().get(maxBB, ActivationRange::activateEntity); +- world.getEntities().get(ActivationRange.maxBB, ActivationRange::activateEntity); + // Paper start -+ java.util.List entities = world.getEntities((Entity)null, maxBB, null); ++ java.util.List entities = world.getEntities((Entity)null, ActivationRange.maxBB, null); + for (int i = 0; i < entities.size(); i++) { + Entity entity = entities.get(i); + ActivationRange.activateEntity(entity); diff --git a/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch b/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch index bf75bba818..6267920ffd 100644 --- a/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch +++ b/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch @@ -27,4 +27,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (System.getProperty("jdk.nio.maxCachedBufferSize") == null) System.setProperty("jdk.nio.maxCachedBufferSize", "262144"); // Paper - cap per-thread NIO cache size OptionParser parser = new OptionParser() { { - acceptsAll(Main.asList("?", "help"), "Show the help"); + this.acceptsAll(Main.asList("?", "help"), "Show the help"); diff --git a/patches/server/Support-components-in-ItemMeta.patch b/patches/server/Support-components-in-ItemMeta.patch index 04a360c20c..5a6b506cd4 100644 --- a/patches/server/Support-components-in-ItemMeta.patch +++ b/patches/server/Support-components-in-ItemMeta.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return CraftChatMessage.fromJSONComponent(displayName); + return CraftChatMessage.fromJSONComponent(this.displayName); } + // Paper start diff --git a/patches/server/Suppress-Item-Meta-Validation-Checks.patch b/patches/server/Suppress-Item-Meta-Validation-Checks.patch index 708e1948ad..601c285c40 100644 --- a/patches/server/Suppress-Item-Meta-Validation-Checks.patch +++ b/patches/server/Suppress-Item-Meta-Validation-Checks.patch @@ -10,11 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java @@ -0,0 +0,0 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { - CompoundTag trimCompound = tag.getCompound(TRIM.NBT); + CompoundTag trimCompound = tag.getCompound(CraftMetaArmor.TRIM.NBT); - if (trimCompound.contains(TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern -- TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT))); -- TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT))); + if (trimCompound.contains(CraftMetaArmor.TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(CraftMetaArmor.TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern +- TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_MATERIAL.NBT))); +- TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(CraftMetaArmor.TRIM_PATTERN.NBT))); + // Paper start + TrimMaterial trimMaterial = getRegistry(Registry.TRIM_MATERIAL, trimCompound.getString(TRIM_MATERIAL.NBT)); + TrimPattern trimPattern = getRegistry(Registry.TRIM_PATTERN, trimCompound.getString(TRIM_PATTERN.NBT)); @@ -75,12 +75,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super(tag); + try { // Paper - Ignore invalid game profiles - if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); - } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { - this.setProfile(new GameProfile(Util.NIL_UUID, tag.getString(SKULL_OWNER.NBT))); + if (tag.contains(CraftMetaSkull.SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + this.setProfile(NbtUtils.readGameProfile(tag.getCompound(CraftMetaSkull.SKULL_OWNER.NBT))); + } else if (tag.contains(CraftMetaSkull.SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(CraftMetaSkull.SKULL_OWNER.NBT).isEmpty()) { + this.setProfile(new GameProfile(Util.NIL_UUID, tag.getString(CraftMetaSkull.SKULL_OWNER.NBT))); } + } catch (Exception ignored) {} // Paper - if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - CompoundTag nbtTagCompound = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy(); + if (tag.contains(CraftMetaSkull.BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + CompoundTag nbtTagCompound = tag.getCompound(CraftMetaSkull.BLOCK_ENTITY_TAG.NBT).copy(); diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch index fc8939b4c3..e9e9ba4c67 100644 --- a/patches/server/Timings-v2.patch +++ b/patches/server/Timings-v2.patch @@ -970,9 +970,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (event.isCancelled()) { return; } -- ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper); -- server.dispatchServerCommand(event.getSender(), serverCommand); -+ + // Paper start + command.set(event.getCommand()); + if (event.getCommand().toLowerCase().startsWith("timings") && event.getCommand().toLowerCase().matches("timings (report|paste|get|merged|seperate)")) { @@ -987,8 +984,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable)); + } else { + // Paper end -+ ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper); -+ server.dispatchServerCommand(event.getSender(), serverCommand); + ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper); + this.server.dispatchServerCommand(event.getSender(), serverCommand); + } // Paper }); + // Paper start @@ -1074,7 +1071,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } gameprofilerfiller.incrementCounter("getChunkCacheMiss"); -- level.timings.syncChunkLoadTimer.startTiming(); // Spigot +- this.level.timings.syncChunkLoadTimer.startTiming(); // Spigot CompletableFuture> completablefuture = this.getChunkFutureMainThread(x, z, leastStatus, create); ServerChunkCache.MainThreadExecutor chunkproviderserver_b = this.mainThreadProcessor; @@ -1082,7 +1079,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!completablefuture.isDone()) { // Paper + this.level.timings.syncChunkLoad.startTiming(); // Paper chunkproviderserver_b.managedBlock(completablefuture::isDone); -- level.timings.syncChunkLoadTimer.stopTiming(); // Spigot +- this.level.timings.syncChunkLoadTimer.stopTiming(); // Spigot + this.level.timings.syncChunkLoad.stopTiming(); // Paper + } // Paper ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { @@ -1109,7 +1106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.level.timings.doChunkUnload.startTiming(); // Spigot @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { - boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit + boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit gameprofilerfiller.push("naturalSpawnCount"); + this.level.timings.countNaturalMobs.startTiming(); // Paper - timings @@ -1183,8 +1180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.updateSkyBrightness(); this.tickTime(); gameprofilerfiller.popPush("tickPending"); -- timings.doTickPending.startTiming(); // Spigot -+ timings.scheduledBlocks.startTiming(); // Paper +- this.timings.doTickPending.startTiming(); // Spigot ++ this.timings.scheduledBlocks.startTiming(); // Paper if (!this.isDebug()) { j = this.getGameTime(); gameprofilerfiller.push("blockTicks"); @@ -1192,8 +1189,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.fluidTicks.tick(j, 65536, this::tickFluid); gameprofilerfiller.pop(); } -- timings.doTickPending.stopTiming(); // Spigot -+ timings.scheduledBlocks.stopTiming(); // Paper +- this.timings.doTickPending.stopTiming(); // Spigot ++ this.timings.scheduledBlocks.stopTiming(); // Paper gameprofilerfiller.popPush("raid"); + this.timings.raids.startTiming(); // Paper - timings @@ -1204,7 +1201,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.getChunkSource().tick(shouldKeepTicking, true); + this.timings.chunkProviderTick.stopTiming(); // Paper - timings gameprofilerfiller.popPush("blockEvents"); - timings.doSounds.startTiming(); // Spigot + this.timings.doSounds.startTiming(); // Spigot this.runBlockEvents(); @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { } @@ -1258,7 +1255,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { if (!savingDisabled) { - org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit + try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); @@ -1530,17 +1527,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }); // CraftBukkit end - this.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.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); ++ this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings + this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); } @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - timings.tileEntityTick.stopTiming(); // Spigot + this.timings.tileEntityTick.stopTiming(); // Spigot this.tickingBlockEntities = false; + co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper gameprofilerfiller.pop(); - spigotConfig.currentPrimedTnt = 0; // Spigot + this.spigotConfig.currentPrimedTnt = 0; // Spigot } public void guardEntityTick(Consumer tickConsumer, T entity) { @@ -2115,7 +2112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final int animalActivationRange = world.spigotConfig.animalActivationRange; @@ -0,0 +0,0 @@ public class ActivationRange - world.getEntities().get(maxBB, ActivationRange::activateEntity); + world.getEntities().get(ActivationRange.maxBB, ActivationRange::activateEntity); } - SpigotTimings.entityActivationCheckTimer.stopTiming(); + MinecraftTimings.entityActivationCheckTimer.stopTiming(); diff --git a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index 334a256ce0..21aad62470 100644 --- a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -321,7 +321,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Use TerminalConsoleAppender + new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start(); + /* - jline.console.ConsoleReader bufferedreader = reader; + jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader; // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -407,7 +407,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - JLine update + /* public ConsoleReader getReader() { - return console.reader; + return this.console.reader; } + */ + // Paper end @@ -533,12 +533,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override protected List evaluate() { - List offers = ConsoleCommandCompleter.this.server.getCommandMap().tabComplete(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer); -+ List offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - fix remap ++ List offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - Remove "this." - TabCompleteEvent tabEvent = new TabCompleteEvent(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); - ConsoleCommandCompleter.this.server.getPluginManager().callEvent(tabEvent); -+ TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); // Paper - fix remap -+ server.getPluginManager().callEvent(tabEvent); // Paper - fix remap ++ TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); // Paper - Remove "this." ++ server.getPluginManager().callEvent(tabEvent); // Paper - Remove "this." return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); } @@ -590,7 +590,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.server.close(); } finally { try { -- server.reader.getTerminal().restore(); +- this.server.reader.getTerminal().restore(); + net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender } catch (Exception e) { } diff --git a/patches/server/Use-a-Queue-for-Queueing-Commands.patch b/patches/server/Use-a-Queue-for-Queueing-Commands.patch index c40fb2d526..77d93c198c 100644 --- a/patches/server/Use-a-Queue-for-Queueing-Commands.patch +++ b/patches/server/Use-a-Queue-for-Queueing-Commands.patch @@ -36,4 +36,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end // CraftBukkit start - ServerCommand for preprocessing - ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg); + ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.msg); diff --git a/patches/server/Vanished-players-don-t-have-rights.patch b/patches/server/Vanished-players-don-t-have-rights.patch index 4a09dd6ce4..df927e6ce6 100644 --- a/patches/server/Vanished-players-don-t-have-rights.patch +++ b/patches/server/Vanished-players-don-t-have-rights.patch @@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); } + // Paper start diff --git a/patches/server/Wait-for-Async-Tasks-during-shutdown.patch b/patches/server/Wait-for-Async-Tasks-during-shutdown.patch index 28353e474e..bb40d7de24 100644 --- a/patches/server/Wait-for-Async-Tasks-during-shutdown.patch +++ b/patches/server/Wait-for-Async-Tasks-during-shutdown.patch @@ -56,4 +56,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public void reloadData() { - ReloadCommand.reload(console); + ReloadCommand.reload(this.console); diff --git a/patches/server/WorldCreator-keepSpawnLoaded.patch b/patches/server/WorldCreator-keepSpawnLoaded.patch index 8a9919016c..861da1d748 100644 --- a/patches/server/WorldCreator-keepSpawnLoaded.patch +++ b/patches/server/WorldCreator-keepSpawnLoaded.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11), + ServerLevel internal = (ServerLevel) new ServerLevel(this.console, this.console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11), worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, this.console.overworld().getRandomSequences(), creator.environment(), generator, biomeProvider); - internal.keepSpawnInMemory = creator.keepSpawnInMemory(); + // internal.keepSpawnInMemory = creator.keepSpawnInMemory(); // Paper - replace