diff options
author | Noah van der Aa <[email protected]> | 2024-04-24 22:32:38 +0200 |
---|---|---|
committer | Noah van der Aa <[email protected]> | 2024-04-24 22:32:38 +0200 |
commit | 22227ccf2670e21152aa4746d0ac02e319e166f3 (patch) | |
tree | b5d8baf8d9c28fe464a63b19e5f00a9cc97ad439 /patches/unapplied | |
parent | 71ae391eb3adc9a2e03514cd8bbff93d2241590c (diff) | |
download | Paper-22227ccf2670e21152aa4746d0ac02e319e166f3.tar.gz Paper-22227ccf2670e21152aa4746d0ac02e319e166f3.zip |
more more work (757)
Diffstat (limited to 'patches/unapplied')
37 files changed, 0 insertions, 2203 deletions
diff --git a/patches/unapplied/server/0749-Fire-CauldronLevelChange-on-initial-fill.patch b/patches/unapplied/server/0749-Fire-CauldronLevelChange-on-initial-fill.patch deleted file mode 100644 index 0ad967e4e4..0000000000 --- a/patches/unapplied/server/0749-Fire-CauldronLevelChange-on-initial-fill.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Tue, 29 Mar 2022 13:46:23 -0700 -Subject: [PATCH] Fire CauldronLevelChange on initial fill - -Also don't fire level events or game events if stalactite -drip is cancelled - -diff --git a/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java b/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java -index 4c9334dde0734a3550a810845cee53f474e9c96b..50fd3e43b4971cd72efd1f609f0cdc4b0f57bed4 100644 ---- a/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java -+++ b/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java -@@ -80,7 +80,7 @@ public interface CauldronInteraction { - } else { - if (!world.isClientSide) { - // CraftBukkit start -- if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { -+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent - return InteractionResult.SUCCESS; - } - // CraftBukkit end -@@ -128,7 +128,7 @@ public interface CauldronInteraction { - if ((Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtils.getPotion(itemstack) == Potions.WATER) { - if (!world.isClientSide) { - // CraftBukkit start -- if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { -+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent - return InteractionResult.SUCCESS; - } - // CraftBukkit end -@@ -212,7 +212,7 @@ public interface CauldronInteraction { - } else { - if (!world.isClientSide) { - // CraftBukkit start -- if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.CAULDRON.defaultBlockState(), player, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.CAULDRON.defaultBlockState(), player, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL, false)) { // Paper - Call CauldronLevelChangeEvent - return InteractionResult.SUCCESS; - } - // CraftBukkit end -@@ -233,7 +233,7 @@ public interface CauldronInteraction { - static InteractionResult emptyBucket(Level world, BlockPos pos, Player player, InteractionHand hand, ItemStack stack, BlockState state, SoundEvent soundEvent) { - if (!world.isClientSide) { - // CraftBukkit start -- if (!LayeredCauldronBlock.changeLevel(state, world, pos, state, player, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) { -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, state, player, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent - return InteractionResult.SUCCESS; - } - // CraftBukkit end -diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -index 588b3e911d9b22dad2928ea9e32e8a8a3a8e9b96..47b6b83842201620bd6620f5acf11bb14334e35d 100644 ---- a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -@@ -43,10 +43,18 @@ public class CauldronBlock extends AbstractCauldronBlock { - public void handlePrecipitation(BlockState state, Level world, BlockPos pos, Biome.Precipitation precipitation) { - if (CauldronBlock.shouldHandlePrecipitation(world, precipitation)) { - if (precipitation == Biome.Precipitation.RAIN) { -- world.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState()); -+ // Paper start - Call CauldronLevelChangeEvent -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event -+ return; -+ } -+ // Paper end - Call CauldronLevelChangeEvent - world.gameEvent((Entity) null, GameEvent.BLOCK_CHANGE, pos); - } else if (precipitation == Biome.Precipitation.SNOW) { -- world.setBlockAndUpdate(pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState()); -+ // Paper start - Call CauldronLevelChangeEvent -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event -+ return; -+ } -+ // Paper end - Call CauldronLevelChangeEvent - world.gameEvent((Entity) null, GameEvent.BLOCK_CHANGE, pos); - } - -@@ -64,11 +72,19 @@ public class CauldronBlock extends AbstractCauldronBlock { - - if (fluid == Fluids.WATER) { - iblockdata1 = Blocks.WATER_CAULDRON.defaultBlockState(); -- LayeredCauldronBlock.changeLevel(state, world, pos, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit -+ // Paper start - Call CauldronLevelChangeEvent; don't send level event or game event if cancelled -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit -+ return; -+ } -+ // Paper end - Call CauldronLevelChangeEvent - world.levelEvent(1047, pos, 0); - } else if (fluid == Fluids.LAVA) { - iblockdata1 = Blocks.LAVA_CAULDRON.defaultBlockState(); -- LayeredCauldronBlock.changeLevel(state, world, pos, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit -+ // Paper start - Call CauldronLevelChangeEvent; don't send level event or game event if cancelled -+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit -+ return; -+ } -+ // Paper end - Call CauldronLevelChangeEvent - world.levelEvent(1046, pos, 0); - } - -diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -index 18ca086e28f4295cb9303919222d7c8ae0ca5d9a..542bc6be48d5c53eee988156e7aa6ecfccb51069 100644 ---- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -@@ -101,7 +101,13 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { - } - - // CraftBukkit start -- public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { -+ // Paper start - Call CauldronLevelChangeEvent -+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable -+ return changeLevel(iblockdata, world, blockposition, newBlock, entity, reason, true); -+ } -+ -+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable -+ // Paper end - Call CauldronLevelChangeEvent - CraftBlockState newState = CraftBlockStates.getBlockState(world, blockposition); - newState.setData(newBlock); - -@@ -114,7 +120,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { - return false; - } - newState.update(true); -- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); -+ if (sendGameEvent) world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent - return true; - } - // CraftBukkit end diff --git a/patches/unapplied/server/0750-fix-powder-snow-cauldrons-not-turning-to-water.patch b/patches/unapplied/server/0750-fix-powder-snow-cauldrons-not-turning-to-water.patch deleted file mode 100644 index 1d388d0504..0000000000 --- a/patches/unapplied/server/0750-fix-powder-snow-cauldrons-not-turning-to-water.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Thu, 30 Dec 2021 14:02:13 -0800 -Subject: [PATCH] fix powder snow cauldrons not turning to water - -Powder snow cauldrons should turn to water when -extinguishing an entity - -diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -index 542bc6be48d5c53eee988156e7aa6ecfccb51069..42c1e3dfec23d6a7d832bf73d47ecae1212ec2c9 100644 ---- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java -@@ -69,7 +69,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { - if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) { - // CraftBukkit start - if (entity.mayInteract(world, pos)) { -- if (!LayeredCauldronBlock.lowerFillLevel(state, world, pos, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { -+ if (!this.handleEntityOnFireInsideWithEvent(state, world, pos, entity)) { // Paper - fix powdered snow cauldron extinguishing entities - return; - } - } -@@ -79,6 +79,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { - - } - -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - fix powdered snow cauldron extinguishing entities; use #handleEntityOnFireInsideWithEvent - private void handleEntityOnFireInside(BlockState state, Level world, BlockPos pos) { - if (this.precipitationType == Biome.Precipitation.SNOW) { - LayeredCauldronBlock.lowerFillLevel((BlockState) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) state.getValue(LayeredCauldronBlock.LEVEL)), world, pos); -@@ -87,6 +88,15 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { - } - - } -+ // Paper start - fix powdered snow cauldron extinguishing entities -+ protected boolean handleEntityOnFireInsideWithEvent(BlockState state, Level world, BlockPos pos, Entity entity) { -+ if (this.precipitationType == Biome.Precipitation.SNOW) { -+ return LayeredCauldronBlock.lowerFillLevel((BlockState) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) state.getValue(LayeredCauldronBlock.LEVEL)), world, pos, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); -+ } else { -+ return LayeredCauldronBlock.lowerFillLevel(state, world, pos, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); -+ } -+ } -+ // Paper end - fix powdered snow cauldron extinguishing entities - - public static void lowerFillLevel(BlockState state, Level world, BlockPos pos) { - // CraftBukkit start diff --git a/patches/unapplied/server/0751-Add-PlayerStopUsingItemEvent.patch b/patches/unapplied/server/0751-Add-PlayerStopUsingItemEvent.patch deleted file mode 100644 index c78c171d1e..0000000000 --- a/patches/unapplied/server/0751-Add-PlayerStopUsingItemEvent.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: u9g <[email protected]> -Date: Tue, 3 May 2022 20:41:37 -0400 -Subject: [PATCH] Add PlayerStopUsingItemEvent - - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 5de5ca787905d9e0133e5f75280748526c568203..2b7325d3bcea2175ec22a45101f5bbaf29c2231a 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4045,6 +4045,7 @@ public abstract class LivingEntity extends Entity implements Attackable { - - public void releaseUsingItem() { - if (!this.useItem.isEmpty()) { -+ if (this instanceof ServerPlayer) new io.papermc.paper.event.player.PlayerStopUsingItemEvent((Player) getBukkitEntity(), useItem.asBukkitMirror(), getTicksUsingItem()).callEvent(); // Paper - Add PlayerStopUsingItemEvent - this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); - if (this.useItem.useOnRelease()) { - this.updatingUsingItem(); diff --git a/patches/unapplied/server/0752-Don-t-tick-markers.patch b/patches/unapplied/server/0752-Don-t-tick-markers.patch deleted file mode 100644 index f920e6b436..0000000000 --- a/patches/unapplied/server/0752-Don-t-tick-markers.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Noah van der Aa <[email protected]> -Date: Fri, 7 Jan 2022 11:58:26 +0100 -Subject: [PATCH] Don't tick markers - -Fixes https://github.com/PaperMC/Paper/issues/7276 and https://github.com/PaperMC/Paper/issues/8118 -by using a config option that, when set to false, does not add markers to the entity -tick list at all and ignores them in Spigot's activation range checks. The entity tick -list is only used in the tick and tickPassenger methods, so we can safely not add the -markers to it. When the config option is set to true, markers are ticked as normal. - -diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -index ff99336e0b8131ae161cfa5c4fc83c6905e3dbc8..5e5a018433414af76eaa1e781f61612ddc305b07 100644 ---- a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -+++ b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -@@ -109,7 +109,7 @@ public final class EntityCommand implements PaperSubcommand { - ChunkPos chunk = e.chunkPosition(); - info.left++; - info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1); -- if (!chunkProviderServer.isPositionTicking(e)) { -+ if (!chunkProviderServer.isPositionTicking(e) || (e instanceof net.minecraft.world.entity.Marker && !world.paperConfig().entities.markers.tick)) { // Paper - Configurable marker ticking - nonEntityTicking.merge(key, 1, Integer::sum); - } - }); -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 03a9f82ac2af6cb64081c2bb758cb02a7ffd5b89..024f32155feb31365c8233f94b1e15ed85e929fb 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -2235,6 +2235,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - - public void onTickingStart(Entity entity) { -+ if (entity instanceof net.minecraft.world.entity.Marker && !paperConfig().entities.markers.tick) return; // Paper - Configurable marker ticking - ServerLevel.this.entityTickList.add(entity); - } - diff --git a/patches/unapplied/server/0753-Expand-FallingBlock-API.patch b/patches/unapplied/server/0753-Expand-FallingBlock-API.patch deleted file mode 100644 index 3f57a2d718..0000000000 --- a/patches/unapplied/server/0753-Expand-FallingBlock-API.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sun, 5 Dec 2021 14:58:17 -0500 -Subject: [PATCH] Expand FallingBlock API - -- add auto expire setting -- add setter for block data -- add accessors for block state - -== AT == -public net.minecraft.world.entity.item.FallingBlockEntity blockState - -Co-authored-by: Lukas Planz <[email protected]> - -diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index c0477f913867c67809978a4f240303151d81e6ea..a52c2fc38fd97ffa1684270443646d605ec35830 100644 ---- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -67,6 +67,7 @@ public class FallingBlockEntity extends Entity { - @Nullable - public CompoundTag blockData; - protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); -+ public boolean autoExpire = true; // Paper - Expand FallingBlock API - - public FallingBlockEntity(EntityType<? extends FallingBlockEntity> type, Level world) { - super(type, world); -@@ -169,7 +170,7 @@ public class FallingBlockEntity extends Entity { - } - - if (!this.onGround() && !flag1) { -- if (!this.level().isClientSide && (this.time > 100 && (blockposition.getY() <= this.level().getMinBuildHeight() || blockposition.getY() > this.level().getMaxBuildHeight()) || this.time > 600)) { -+ if (!this.level().isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level().getMinBuildHeight() || blockposition.getY() > this.level().getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Expand FallingBlock API - if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - this.spawnAtLocation((ItemLike) block); - } -@@ -315,6 +316,7 @@ public class FallingBlockEntity extends Entity { - } - - nbt.putBoolean("CancelDrop", this.cancelDrop); -+ if (!autoExpire) {nbt.putBoolean("Paper.AutoExpire", false);} // Paper - Expand FallingBlock API - } - - @Override -@@ -342,6 +344,11 @@ public class FallingBlockEntity extends Entity { - this.blockState = Blocks.SAND.defaultBlockState(); - } - -+ // Paper start - Expand FallingBlock API -+ if (nbt.contains("Paper.AutoExpire")) { -+ this.autoExpire = nbt.getBoolean("Paper.AutoExpire"); -+ } -+ // Paper end - Expand FallingBlock API - } - - public void setHurtsEntities(float fallHurtAmount, int fallHurtMax) { -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -index a7a3f74b846112d752fe04162b30805961457b11..1359d25a32b4a5d5e8e68ce737bd19f7b5afaf69 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -@@ -33,6 +33,31 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { - public BlockData getBlockData() { - return CraftBlockData.fromData(this.getHandle().getBlockState()); - } -+ // Paper start - Expand FallingBlock API -+ @Override -+ public void setBlockData(final BlockData blockData) { -+ Preconditions.checkArgument(blockData != null, "blockData"); -+ final net.minecraft.world.level.block.state.BlockState oldState = this.getHandle().blockState, newState = ((CraftBlockData) blockData).getState(); -+ this.getHandle().blockState = newState; -+ this.getHandle().blockData = null; -+ -+ if (oldState != newState) this.update(); -+ } -+ -+ @Override -+ public org.bukkit.block.BlockState getBlockState() { -+ return org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.getHandle().blockState, this.getHandle().blockData); -+ } -+ -+ @Override -+ public void setBlockState(final org.bukkit.block.BlockState blockState) { -+ Preconditions.checkArgument(blockState != null, "blockState"); -+ // Calls #update if needed, the block data compound tag is not synced with the client and hence can be mutated after the sync with clients. -+ // The call also clears any potential old block data. -+ this.setBlockData(blockState.getBlockData()); -+ if (blockState instanceof final org.bukkit.craftbukkit.block.CraftBlockEntityState<?> tileEntity) this.getHandle().blockData = tileEntity.getSnapshotNBT(); -+ } -+ // Paper end - Expand FallingBlock API - - @Override - public boolean getDropItem() { -@@ -101,4 +126,15 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { - this.setHurtEntities(true); - } - } -+ // Paper start - Expand FallingBlock API -+ @Override -+ public boolean doesAutoExpire() { -+ return this.getHandle().autoExpire; -+ } -+ -+ @Override -+ public void shouldAutoExpire(boolean autoExpires) { -+ this.getHandle().autoExpire = autoExpires; -+ } -+ // Paper end - Expand FallingBlock API - } diff --git a/patches/unapplied/server/0754-Add-support-for-Proxy-Protocol.patch b/patches/unapplied/server/0754-Add-support-for-Proxy-Protocol.patch deleted file mode 100644 index 1c60d69833..0000000000 --- a/patches/unapplied/server/0754-Add-support-for-Proxy-Protocol.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: PanSzelescik <[email protected]> -Date: Thu, 7 Apr 2022 16:13:39 +0200 -Subject: [PATCH] Add support for Proxy Protocol - - -diff --git a/build.gradle.kts b/build.gradle.kts -index d16c0311142e44ec1048818221796c09ab7a90d8..f9056ee057a22a11288405cd42cd0ba4c9d120c3 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -30,6 +30,7 @@ dependencies { - log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins - runtimeOnly(log4jPlugins.output) - alsoShade(log4jPlugins.output) -+ implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol - // Paper end - implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") -diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -index 87abd6274f9da9367094bad0c28acfa47e01c50e..4f330a44c77a7ec3237a86fda04921a8c4a1c00f 100644 ---- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -@@ -121,6 +121,29 @@ public class ServerConnectionListener { - Connection object = j > 0 ? new RateKickingConnection(j) : new Connection(PacketFlow.SERVERBOUND); // CraftBukkit - decompile error - - //ServerConnectionListener.this.connections.add(object); // Paper -+ // Paper start - Add support for Proxy Protocol -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.proxyProtocol) { -+ channel.pipeline().addAfter("timeout", "haproxy-decoder", new io.netty.handler.codec.haproxy.HAProxyMessageDecoder()); -+ channel.pipeline().addAfter("haproxy-decoder", "haproxy-handler", new ChannelInboundHandlerAdapter() { -+ @Override -+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { -+ if (msg instanceof io.netty.handler.codec.haproxy.HAProxyMessage message) { -+ if (message.command() == io.netty.handler.codec.haproxy.HAProxyCommand.PROXY) { -+ String realaddress = message.sourceAddress(); -+ int realport = message.sourcePort(); -+ -+ SocketAddress socketaddr = new java.net.InetSocketAddress(realaddress, realport); -+ -+ Connection connection = (Connection) channel.pipeline().get("packet_handler"); -+ connection.address = socketaddr; -+ } -+ } else { -+ super.channelRead(ctx, msg); -+ } -+ } -+ }); -+ } -+ // Paper end - Add support for proxy protocol - pending.add(object); // Paper - prevent blocking on adding a new connection while the server is ticking - ((Connection) object).configurePacketHandler(channelpipeline); - ((Connection) object).setListenerForServerboundHandshake(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object)); diff --git a/patches/unapplied/server/0755-Fix-OfflinePlayer-getBedSpawnLocation.patch b/patches/unapplied/server/0755-Fix-OfflinePlayer-getBedSpawnLocation.patch deleted file mode 100644 index e67e0fc286..0000000000 --- a/patches/unapplied/server/0755-Fix-OfflinePlayer-getBedSpawnLocation.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Mon, 30 May 2022 16:03:36 -0700 -Subject: [PATCH] Fix OfflinePlayer#getBedSpawnLocation - -When calling getBedSpawnLocation on an -instance of CraftOfflinePlayer the world was incorrect -due to the logic for reading the NBT not being up-to-date. - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java -index 0c1b5f625a351905e082b2c2a63bfd737101527e..ef2dfa30686bba3eb510bf95172174cc9972422e 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java -@@ -37,6 +37,7 @@ import org.bukkit.profile.PlayerProfile; - - @SerializableAs("Player") - public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializable { -+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper - private final GameProfile profile; - private final CraftServer server; - private final PlayerDataStorage storage; -@@ -361,11 +362,20 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa - if (data == null) return null; - - if (data.contains("SpawnX") && data.contains("SpawnY") && data.contains("SpawnZ")) { -- String spawnWorld = data.getString("SpawnWorld"); -- if (spawnWorld.equals("")) { -- spawnWorld = this.server.getWorlds().get(0).getName(); -+ // Paper start - fix wrong world -+ final float respawnAngle = data.getFloat("SpawnAngle"); -+ org.bukkit.World spawnWorld = this.server.getWorld(data.getString("SpawnWorld")); // legacy -+ if (data.contains("SpawnDimension")) { -+ com.mojang.serialization.DataResult<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> result = net.minecraft.world.level.Level.RESOURCE_KEY_CODEC.parse(net.minecraft.nbt.NbtOps.INSTANCE, data.get("SpawnDimension")); -+ net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> levelKey = result.resultOrPartial(LOGGER::error).orElse(net.minecraft.world.level.Level.OVERWORLD); -+ net.minecraft.server.level.ServerLevel level = this.server.console.getLevel(levelKey); -+ spawnWorld = level != null ? level.getWorld() : spawnWorld; - } -- return new Location(this.server.getWorld(spawnWorld), data.getInt("SpawnX"), data.getInt("SpawnY"), data.getInt("SpawnZ")); -+ if (spawnWorld == null) { -+ return null; -+ } -+ return new Location(spawnWorld, data.getInt("SpawnX"), data.getInt("SpawnY"), data.getInt("SpawnZ"), respawnAngle, 0); -+ // Paper end - } - return null; - } diff --git a/patches/unapplied/server/0756-Fix-FurnaceInventory-for-smokers-and-blast-furnaces.patch b/patches/unapplied/server/0756-Fix-FurnaceInventory-for-smokers-and-blast-furnaces.patch deleted file mode 100644 index ef7517367b..0000000000 --- a/patches/unapplied/server/0756-Fix-FurnaceInventory-for-smokers-and-blast-furnaces.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Sat, 1 Jan 2022 23:11:26 -0800 -Subject: [PATCH] Fix FurnaceInventory for smokers and blast furnaces - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java -index 8d3f71689087d687e6400e2ea9750a6fb3535bf1..149683821a248fbbd93d0417085f0cb0e86a1398 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java -@@ -65,7 +65,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - return new CraftInventory(tileEntity); - } - -- public static class Furnace extends CraftTileInventoryConverter { -+ public static class Furnace extends AbstractFurnaceInventoryConverter { // Paper - Furnace, BlastFurnace, and Smoker are pretty much identical - - @Override - public Container getTileEntity() { -@@ -73,6 +73,11 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - return furnace; - } - -+ // Paper start - abstract furnace converter to apply to all 3 furnaces -+ } -+ -+ public static abstract class AbstractFurnaceInventoryConverter extends CraftTileInventoryConverter { -+ // Paper end - abstract furnace converter to apply to all 3 furnaces - // Paper start - @Override - public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { -@@ -170,7 +175,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - } - } - -- public static class BlastFurnace extends CraftTileInventoryConverter { -+ public static class BlastFurnace extends AbstractFurnaceInventoryConverter { // Paper - Furnace, BlastFurnace, and Smoker are pretty much identical - - @Override - public Container getTileEntity() { -@@ -186,7 +191,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - } - } - -- public static class Smoker extends CraftTileInventoryConverter { -+ public static class Smoker extends AbstractFurnaceInventoryConverter { // Paper - Furnace, BlastFurnace, and Smoker are pretty much identical - - @Override - public Container getTileEntity() { diff --git a/patches/unapplied/server/0757-properly-read-and-store-sus-effect-duration.patch b/patches/unapplied/server/0757-properly-read-and-store-sus-effect-duration.patch deleted file mode 100644 index 94589408f4..0000000000 --- a/patches/unapplied/server/0757-properly-read-and-store-sus-effect-duration.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Mon, 18 Dec 2023 20:05:50 -0800 -Subject: [PATCH] properly read and store sus effect duration - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java -index e13146b71552ab3f9ae867110650fe3977563dfb..2c3b9f76067088efdc2250cdb5070df86e2dc0f5 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java -@@ -49,7 +49,14 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious - if (type == null) { - continue; - } -- int duration = effect.getInt(CraftMetaSuspiciousStew.DURATION.NBT); -+ // Paper start - default duration is 160 -+ final int duration; -+ if (effect.contains(CraftMetaSuspiciousStew.DURATION.NBT)) { -+ duration = effect.getInt(CraftMetaSuspiciousStew.DURATION.NBT); -+ } else { -+ duration = net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION; -+ } -+ // Paper end start - default duration is 160 - this.customEffects.add(new PotionEffect(type, duration, 0)); - } - } -@@ -80,7 +87,7 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious - for (PotionEffect effect : this.customEffects) { - CompoundTag effectData = new CompoundTag(); - effectData.putString(CraftMetaSuspiciousStew.ID.NBT, effect.getType().getKey().toString()); -- effectData.putInt(CraftMetaSuspiciousStew.DURATION.NBT, effect.getDuration()); -+ if (effect.getDuration() != net.minecraft.world.item.SuspiciousStewItem.DEFAULT_DURATION) effectData.putInt(CraftMetaSuspiciousStew.DURATION.NBT, effect.getDuration()); // Paper - don't save duration if it's the default value - effectList.add(effectData); - } - } diff --git a/patches/unapplied/server/0758-Sanitize-sent-BlockEntity-NBT.patch b/patches/unapplied/server/0758-Sanitize-sent-BlockEntity-NBT.patch deleted file mode 100644 index 72cdd70ba1..0000000000 --- a/patches/unapplied/server/0758-Sanitize-sent-BlockEntity-NBT.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Fri, 3 Dec 2021 16:55:50 -0500 -Subject: [PATCH] Sanitize sent BlockEntity NBT - - -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java -index d79284a790569141c2ac8178d6ecc20b17cdd0d3..3944852921335c78a04a9dc301882ab5b152b1ed 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java -@@ -17,7 +17,7 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket - private final CompoundTag tag; - - public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, Function<BlockEntity, CompoundTag> nbtGetter) { -- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), nbtGetter.apply(blockEntity)); -+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(nbtGetter.apply(blockEntity))); // Paper - Sanitize sent data - } - - public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) { -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index a44a82d2d5ed4d675dc1a184d5b6b935fda575dd..03b6aa2e3bd871ae59e761866b53a10f72b3cdac 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -145,6 +145,7 @@ public class ClientboundLevelChunkPacketData { - CompoundTag compoundTag = blockEntity.getUpdateTag(); - BlockPos blockPos = blockEntity.getBlockPos(); - int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); -+ blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data - return new ClientboundLevelChunkPacketData.BlockEntityInfo(i, blockPos.getY(), blockEntity.getType(), compoundTag.isEmpty() ? null : compoundTag); - } - } -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index 4893eaf93738da860014ddf3ad003334c9ebc9fa..20201430ee8f28245aa845acb172d0f5d80458ff 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -253,4 +253,11 @@ public abstract class BlockEntity { - return null; - } - // CraftBukkit end -+ // Paper start - Sanitize sent data -+ public CompoundTag sanitizeSentNbt(CompoundTag tag) { -+ tag.remove("PublicBukkitValues"); -+ -+ return tag; -+ } -+ // Paper end - Sanitize sent data - } diff --git a/patches/unapplied/server/0759-Disable-component-selector-resolving-in-books-by-def.patch b/patches/unapplied/server/0759-Disable-component-selector-resolving-in-books-by-def.patch deleted file mode 100644 index 97082feba7..0000000000 --- a/patches/unapplied/server/0759-Disable-component-selector-resolving-in-books-by-def.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Nassim Jahnke <[email protected]> -Date: Thu, 2 Jun 2022 20:35:58 +0200 -Subject: [PATCH] Disable component selector resolving in books by default - - -diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java -index 81bb0abea7ebd2705f84fae31e4a3d2de92d7d18..793ab8acd7445984cff2628e3f001661dc20c8e5 100644 ---- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java -+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java -@@ -112,7 +112,7 @@ public class WrittenBookItem extends Item { - - public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) { - CompoundTag compoundTag = book.getTag(); -- if (compoundTag != null && !compoundTag.getBoolean("resolved")) { -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper - Disable component selector resolving in books by default - compoundTag.putBoolean("resolved", true); - if (!makeSureTagIsValid(compoundTag)) { - return false; diff --git a/patches/unapplied/server/0760-Prevent-entity-loading-causing-async-lookups.patch b/patches/unapplied/server/0760-Prevent-entity-loading-causing-async-lookups.patch deleted file mode 100644 index d02ab57220..0000000000 --- a/patches/unapplied/server/0760-Prevent-entity-loading-causing-async-lookups.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sun, 6 Mar 2022 11:09:09 -0500 -Subject: [PATCH] Prevent entity loading causing async lookups - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f08908238cc9680310a2b37089b051bf6fdf5ee3..936ce33bffd93ed7210b6659c27c476e1db348bb 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -727,6 +727,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - - public void baseTick() { - this.level().getProfiler().push("entityBaseTick"); -+ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups - this.feetBlockState = null; - if (this.isPassenger() && this.getVehicle().isRemoved()) { - this.stopRiding(); -diff --git a/src/main/java/net/minecraft/world/entity/NeutralMob.java b/src/main/java/net/minecraft/world/entity/NeutralMob.java -index fa64c7baa7587f2cfe80b78ed83be011239618cf..47d5a0928f3c86d71f851738bfe7beedc98cfbb3 100644 ---- a/src/main/java/net/minecraft/world/entity/NeutralMob.java -+++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java -@@ -42,18 +42,11 @@ public interface NeutralMob { - UUID uuid = nbt.getUUID("AngryAt"); - - this.setPersistentAngerTarget(uuid); -- Entity entity = ((ServerLevel) world).getEntity(uuid); -- -- if (entity != null) { -- if (entity instanceof Mob) { -- this.setLastHurtByMob((Mob) entity); -- } -- -- if (entity.getType() == EntityType.PLAYER) { -- this.setLastHurtByPlayer((Player) entity); -- } -- -- } -+ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method -+ // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively -+ // tick the initial persistent anger. -+ // If not, let the first tick on the baseTick call the method later down the line. -+ if (this instanceof Entity entity && !entity.firstTick) this.tickInitialPersistentAnger(world); - } - } - } -@@ -127,4 +120,27 @@ public interface NeutralMob { - - @Nullable - LivingEntity getTarget(); -+ -+ // Paper start - Prevent entity loading causing async lookups -+ // Update last hurt when ticking -+ default void tickInitialPersistentAnger(Level level) { -+ UUID target = getPersistentAngerTarget(); -+ if (target == null) { -+ return; -+ } -+ -+ Entity entity = ((ServerLevel) level).getEntity(target); -+ -+ if (entity != null) { -+ if (entity instanceof Mob) { -+ this.setLastHurtByMob((Mob) entity); -+ } -+ -+ if (entity.getType() == EntityType.PLAYER) { -+ this.setLastHurtByPlayer((Player) entity); -+ } -+ -+ } -+ } -+ // Paper end - Prevent entity loading causing async lookups - } diff --git a/patches/unapplied/server/0761-Throw-exception-on-world-create-while-being-ticked.patch b/patches/unapplied/server/0761-Throw-exception-on-world-create-while-being-ticked.patch deleted file mode 100644 index 42eeeb0a1e..0000000000 --- a/patches/unapplied/server/0761-Throw-exception-on-world-create-while-being-ticked.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Tue, 22 Mar 2022 12:44:30 -0700 -Subject: [PATCH] Throw exception on world create while being ticked - -There are no plans to support creating worlds while worlds are -being ticked themselvess. - -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 88821acddee03c30c2630d3d6c39cc93702ed35b..2a96d128dd42b937b16e25274b39fb66c3d9a097 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -307,6 +307,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa - // Spigot end - public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files - public static long currentTickLong = 0L; // Paper - track current tick as a long -+ public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked - - public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) { - AtomicReference<S> atomicreference = new AtomicReference(); -@@ -1501,7 +1502,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa - this.getFunctions().tick(); - MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper - this.profiler.popPush("levels"); -- Iterator iterator = this.getAllLevels().iterator(); -+ //Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; moved down - - // CraftBukkit start - // Run tasks that are waiting on processing -@@ -1533,6 +1534,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa - // Paper end - Perf: Optimize time updates - MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper - -+ this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked -+ Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down - while (iterator.hasNext()) { - ServerLevel worldserver = (ServerLevel) iterator.next(); - worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent -@@ -1571,6 +1574,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa - this.profiler.pop(); - worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions - } -+ this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked - - this.profiler.popPush("connection"); - MinecraftTimings.connectionTimer.startTiming(); // Spigot // Paper -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index f3b461baac5a5de61f6b1c00251961bd25eb4773..562953515e21adc1cffadfe3ffb803c2d5059df0 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -886,6 +886,11 @@ public final class CraftServer implements Server { - return new ArrayList<World>(this.worlds.values()); - } - -+ @Override -+ public boolean isTickingWorlds() { -+ return console.isIteratingOverLevels; -+ } -+ - public DedicatedPlayerList getHandle() { - return this.playerList; - } -@@ -1145,6 +1150,7 @@ public final class CraftServer implements Server { - @Override - public World createWorld(WorldCreator creator) { - Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP"); -+ //Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes. - Preconditions.checkArgument(creator != null, "WorldCreator cannot be null"); - - String name = creator.name(); -@@ -1317,6 +1323,7 @@ public final class CraftServer implements Server { - - @Override - public boolean unloadWorld(World world, boolean save) { -+ //Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot unload a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes. - if (world == null) { - return false; - } diff --git a/patches/unapplied/server/0762-Dont-resent-entity-on-art-update.patch b/patches/unapplied/server/0762-Dont-resent-entity-on-art-update.patch deleted file mode 100644 index 38d1a4ca58..0000000000 --- a/patches/unapplied/server/0762-Dont-resent-entity-on-art-update.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Wed, 8 Jun 2022 11:04:47 -0400 -Subject: [PATCH] Dont resent entity on art update - - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java -index dd02cec9a82794a6b001c3b64f031f78d5fbb812..bcac1359c667ef1ee46384f9c7a5adf4010d2b08 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java -@@ -36,7 +36,7 @@ public class CraftPainting extends CraftHanging implements Painting { - painting.setDirection(painting.getDirection()); - return false; - } -- this.update(); -+ //this.update(); Paper - Don't resent entity on art update - return true; - } - diff --git a/patches/unapplied/server/0763-Add-WardenAngerChangeEvent.patch b/patches/unapplied/server/0763-Add-WardenAngerChangeEvent.patch deleted file mode 100644 index 7bd9e6cd8e..0000000000 --- a/patches/unapplied/server/0763-Add-WardenAngerChangeEvent.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: nopjar <[email protected]> -Date: Sun, 12 Jun 2022 02:26:04 +0200 -Subject: [PATCH] Add WardenAngerChangeEvent - - -diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java -index 27e52ee93ab591e97f37705de64cb5b62c06e253..3d792957f27fd4bdfad8d76262a8e2a2012bf35f 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java -+++ b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java -@@ -146,7 +146,7 @@ public class AngerManagement { - - public int increaseAnger(Entity entity, int amount) { - boolean bl = !this.angerBySuspect.containsKey(entity); -- int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); -+ int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); // Paper - diff on change (Warden#increaseAngerAt WardenAngerChangeEvent) - if (bl) { - int j = this.angerByUuid.removeInt(entity.getUUID()); - i += j; -diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index b5185fcb635fbf5e5ed9d6cc9cc517cb46ada5aa..937f81a859953498abe73bea560c86e6560e1c33 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -488,6 +488,15 @@ public class Warden extends Monster implements VibrationSystem { - @VisibleForTesting - public void increaseAngerAt(@Nullable Entity entity, int amount, boolean listening) { - if (!this.isNoAi() && this.canTargetEntity(entity)) { -+ // Paper start - Add WardenAngerChangeEvent -+ int activeAnger = this.angerManagement.getActiveAnger(entity); -+ io.papermc.paper.event.entity.WardenAngerChangeEvent event = new io.papermc.paper.event.entity.WardenAngerChangeEvent((org.bukkit.entity.Warden) this.getBukkitEntity(), entity.getBukkitEntity(), activeAnger, Math.min(150, activeAnger + amount)); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ amount = event.getNewAnger() - activeAnger; -+ // Paper end - Add WardenAngerChangeEvent - WardenAi.setDigCooldown(this); - boolean flag1 = !(this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null) instanceof Player); // CraftBukkit - decompile error - int j = this.angerManagement.increaseAnger(entity, amount); diff --git a/patches/unapplied/server/0764-Add-option-for-strict-advancement-dimension-checks.patch b/patches/unapplied/server/0764-Add-option-for-strict-advancement-dimension-checks.patch deleted file mode 100644 index 7d0540d1db..0000000000 --- a/patches/unapplied/server/0764-Add-option-for-strict-advancement-dimension-checks.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Sun, 12 Jun 2022 11:47:24 -0700 -Subject: [PATCH] Add option for strict advancement dimension checks - -Craftbukkit attempts to translate worlds that use the -same generation as the Overworld, The Nether, or The End -to use those dimensions when checking the `changed_dimension` -criteria trigger, or whether to trigger the `NETHER_TRAVEL` -distance trigger. This adds a config option to ignore that -and use the exact dimension key of the worlds involved. - -diff --git a/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java b/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java -index 079e3af44a964321d360b979f64f572057235ab8..8f2c00cd70bc99855f23f3db58567233a1fda84e 100644 ---- a/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java -+++ b/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java -@@ -62,7 +62,7 @@ public record LocationPredicate( - public boolean matches(ServerLevel world, double x, double y, double z) { - if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { - return false; -- } else if (this.dimension.isPresent() && this.dimension.get() != world.dimension()) { -+ } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? world.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(world))) { // Paper - Add option for strict advancement dimension checks - return false; - } else { - BlockPos blockPos = BlockPos.containing(x, y, z); -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 3f8f0e88339d847c44120b7657161bf43402db74..c99a672dd2d2e4972e9d4025e10e8863d0af1e6a 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -1272,6 +1272,12 @@ public class ServerPlayer extends Player { - ResourceKey<Level> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(origin); - ResourceKey<Level> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level()); - -+ // Paper start - Add option for strict advancement dimension checks -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck) { -+ maindimensionkey = resourcekey; -+ maindimensionkey1 = resourcekey1; -+ } -+ // Paper end - Add option for strict advancement dimension checks - CriteriaTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1); - if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { - CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); diff --git a/patches/unapplied/server/0765-Add-missing-important-BlockStateListPopulator-method.patch b/patches/unapplied/server/0765-Add-missing-important-BlockStateListPopulator-method.patch deleted file mode 100644 index 5db34c9fe3..0000000000 --- a/patches/unapplied/server/0765-Add-missing-important-BlockStateListPopulator-method.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sun, 12 Jun 2022 13:25:52 -0400 -Subject: [PATCH] Add missing important BlockStateListPopulator methods - -Without these methods it causes exceptions due to these being used by certain feature generators. - -diff --git a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java -index ffe6881d93153838cd23f125980b832e6fd1d0eb..f5cbe9ae5802fa48e57092b1e5ca8a5f5f69ee60 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java -@@ -129,7 +129,7 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { - - @Override - public boolean isFluidAtPosition(BlockPos pos, Predicate<FluidState> state) { -- return this.world.isFluidAtPosition(pos, state); -+ return state.test(this.getFluidState(pos)); // Paper - fix - } - - @Override -@@ -152,4 +152,33 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { - public long nextSubTickCount() { - return this.world.nextSubTickCount(); - } -+ -+ // Paper start -+ @Override -+ public <T extends BlockEntity> java.util.Optional<T> getBlockEntity(BlockPos pos, net.minecraft.world.level.block.entity.BlockEntityType<T> type) { -+ BlockEntity tileentity = this.getBlockEntity(pos); -+ -+ return tileentity != null && tileentity.getType() == type ? (java.util.Optional<T>) java.util.Optional.of(tileentity) : java.util.Optional.empty(); -+ } -+ -+ @Override -+ public BlockPos getHeightmapPos(net.minecraft.world.level.levelgen.Heightmap.Types heightmap, BlockPos pos) { -+ return world.getHeightmapPos(heightmap, pos); -+ } -+ -+ @Override -+ public int getHeight(net.minecraft.world.level.levelgen.Heightmap.Types heightmap, int x, int z) { -+ return world.getHeight(heightmap, x, z); -+ } -+ -+ @Override -+ public int getRawBrightness(BlockPos pos, int ambientDarkness) { -+ return world.getRawBrightness(pos, ambientDarkness); -+ } -+ -+ @Override -+ public int getBrightness(net.minecraft.world.level.LightLayer type, BlockPos pos) { -+ return world.getBrightness(type, pos); -+ } -+ // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java -index 440660dfa70d57e94ae4eef1dce783aee5034f7e..67c9009b735429e887e706baf50a6023d572a46c 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java -@@ -258,4 +258,14 @@ public class DummyGeneratorAccess implements WorldGenLevel { - public boolean destroyBlock(BlockPos pos, boolean drop, Entity breakingEntity, int maxUpdateDepth) { - return false; // SPIGOT-6515 - } -+ -+ // Paper start - add more methods -+ public void scheduleTick(BlockPos pos, Fluid fluid, int delay) {} -+ -+ @Override -+ public void scheduleTick(BlockPos pos, Block block, int delay, net.minecraft.world.ticks.TickPriority priority) {} -+ -+ @Override -+ public void scheduleTick(BlockPos pos, Fluid fluid, int delay, net.minecraft.world.ticks.TickPriority priority) {} -+ // Paper end - add more methods - } diff --git a/patches/unapplied/server/0766-Nameable-Banner-API.patch b/patches/unapplied/server/0766-Nameable-Banner-API.patch deleted file mode 100644 index 351d3597e0..0000000000 --- a/patches/unapplied/server/0766-Nameable-Banner-API.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Thu, 7 Apr 2022 17:49:25 -0400 -Subject: [PATCH] Nameable Banner API - - -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java -index 2b7fcd30b6eb0ab60b44de31ad0e0b20033f45c5..0a80bd370dd41ffbfbbe6b0d88cd6fa8a47a5725 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java -@@ -108,4 +108,26 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem - public CraftBanner copy() { - return new CraftBanner(this); - } -+ -+ // Paper start -+ @Override -+ public net.kyori.adventure.text.Component customName() { -+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCustomName()); -+ } -+ -+ @Override -+ public void customName(net.kyori.adventure.text.Component customName) { -+ this.getSnapshot().setCustomName(io.papermc.paper.adventure.PaperAdventure.asVanilla(customName)); -+ } -+ -+ @Override -+ public String getCustomName() { -+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(this.customName()); -+ } -+ -+ @Override -+ public void setCustomName(String name) { -+ this.customName(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(name)); -+ } -+ // Paper end - } diff --git a/patches/unapplied/server/0767-Don-t-broadcast-messages-to-command-blocks.patch b/patches/unapplied/server/0767-Don-t-broadcast-messages-to-command-blocks.patch deleted file mode 100644 index fa6488648d..0000000000 --- a/patches/unapplied/server/0767-Don-t-broadcast-messages-to-command-blocks.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Thu, 16 Jun 2022 14:22:56 -0700 -Subject: [PATCH] Don't broadcast messages to command blocks - -Previously the broadcast method would update the last output -in command blocks, and if called asynchronously, would throw -an error - -diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -index c56f5173fda6b38c2dcaea196217f2f5a7d7c641..524b0f1086c01888fe0b76e180c40915d16a1eb9 100644 ---- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -@@ -172,6 +172,7 @@ public abstract class BaseCommandBlock implements CommandSource { - @Override - public void sendSystemMessage(Component message) { - if (this.trackOutput) { -+ org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks - SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT; - Date date = new Date(); - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 562953515e21adc1cffadfe3ffb803c2d5059df0..e849e706660bf0b0ef1748dfee3ba75e5aff9863 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1880,7 +1880,7 @@ public final class CraftServer implements Server { - // Paper end - Set<CommandSender> recipients = new HashSet<>(); - for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) { -- if (permissible instanceof CommandSender && permissible.hasPermission(permission)) { -+ if (permissible instanceof CommandSender && !(permissible instanceof org.bukkit.command.BlockCommandSender) && permissible.hasPermission(permission)) { // Paper - Don't broadcast messages to command blocks - recipients.add((CommandSender) permissible); - } - } diff --git a/patches/unapplied/server/0768-Prevent-empty-items-from-being-added-to-world.patch b/patches/unapplied/server/0768-Prevent-empty-items-from-being-added-to-world.patch deleted file mode 100644 index c3d0b8413a..0000000000 --- a/patches/unapplied/server/0768-Prevent-empty-items-from-being-added-to-world.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Wed, 15 Jun 2022 21:52:57 -0400 -Subject: [PATCH] Prevent empty items from being added to world - -The previous solution caused a bunch of bandaid fixes inorder to resolve edge cases where minecraft/the api might spawn items that are air. -Just simply prevent them from being added to the world instead. - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 024f32155feb31365c8233f94b1e15ed85e929fb..57f54e3399f9d2d7fecdae62858d20e50caf7afd 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1231,6 +1231,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit - return false; - } else { -+ if (entity instanceof net.minecraft.world.entity.item.ItemEntity itemEntity && itemEntity.getItem().isEmpty()) return false; // Paper - Prevent empty items from being added - // Paper start - capture all item additions to the world - if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) { - captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity); diff --git a/patches/unapplied/server/0769-Fix-CCE-for-SplashPotion-and-LingeringPotion-spawnin.patch b/patches/unapplied/server/0769-Fix-CCE-for-SplashPotion-and-LingeringPotion-spawnin.patch deleted file mode 100644 index 5816232b91..0000000000 --- a/patches/unapplied/server/0769-Fix-CCE-for-SplashPotion-and-LingeringPotion-spawnin.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Thu, 21 Apr 2022 18:18:02 -0700 -Subject: [PATCH] Fix CCE for SplashPotion and LingeringPotion spawning - -Remove in 1.19 along with the SplashPotion and -LingeringPotion interfaces - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -index d5f1681a476c8fe2ae128a84910f4bf04063b75a..d3aeb4b614b2b17d9613aa3ffa34ebfc81666f79 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -@@ -13,7 +13,7 @@ import org.bukkit.entity.ThrownPotion; - import org.bukkit.inventory.ItemStack; - import org.bukkit.potion.PotionEffect; - --public class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion { -+public class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion, org.bukkit.entity.SplashPotion, org.bukkit.entity.LingeringPotion { // Paper - implement other classes to avoid violating spawn method generic contracts - public CraftThrownPotion(CraftServer server, net.minecraft.world.entity.projectile.ThrownPotion entity) { - super(server, entity); - } diff --git a/patches/unapplied/server/0770-Add-Player-getFishHook.patch b/patches/unapplied/server/0770-Add-Player-getFishHook.patch deleted file mode 100644 index d5f8b5dc18..0000000000 --- a/patches/unapplied/server/0770-Add-Player-getFishHook.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: u9g <[email protected]> -Date: Tue, 14 Jun 2022 19:36:10 -0400 -Subject: [PATCH] Add Player#getFishHook - - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index b895b3972dc48ec91dba9d44546508badef73865..98ee3a7eff6cd1dd3fdbd7cc6a94deebcefbc565 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -@@ -162,6 +162,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - return new Location(worldServer.getWorld(), bed.getX(), bed.getY(), bed.getZ()); - } - // Paper end -+ // Paper start -+ @Override -+ public org.bukkit.entity.FishHook getFishHook() { -+ if (getHandle().fishing == null) { -+ return null; -+ } -+ return (org.bukkit.entity.FishHook) getHandle().fishing.getBukkitEntity(); -+ } -+ // Paper end - @Override - public boolean sleep(Location location, boolean force) { - Preconditions.checkArgument(location != null, "Location cannot be null"); diff --git a/patches/unapplied/server/0771-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch b/patches/unapplied/server/0771-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch deleted file mode 100644 index b5557f95ef..0000000000 --- a/patches/unapplied/server/0771-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf <[email protected]> -Date: Sun, 3 Jul 2022 22:31:37 -0700 -Subject: [PATCH] Do not sync load chunk for dynamic game event listener - registration - -These can be called while an entity is being added to the world, -and if the entity is being added from a chunk load context the -sync load will block indefinitely (because the chunk load context -is for completing the chunk to FULL). - -This does raise questions about the current system for these -dynamic registrations, as it looks like there is _zero_ logic -to account for the case where the chunk is _not_ currently loaded -and then later loaded. - -diff --git a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -index 53eeb59257e3e943cbe7dc113674135077f0c20d..fc316f6c6db1d39bb24daa1d272e5128c71320dd 100644 ---- a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -+++ b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -41,7 +41,7 @@ public class DynamicGameEventListener<T extends GameEventListener> { - - private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) { - if (sectionPos != null) { -- ChunkAccess chunkAccess = world.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false); -+ ChunkAccess chunkAccess = world.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - Perf: can cause sync loads while completing a chunk, resulting in deadlock - if (chunkAccess != null) { - dispatcherConsumer.accept(chunkAccess.getListenerRegistry(sectionPos.y())); - } diff --git a/patches/unapplied/server/0772-Add-various-missing-EntityDropItemEvent-calls.patch b/patches/unapplied/server/0772-Add-various-missing-EntityDropItemEvent-calls.patch deleted file mode 100644 index d3b144009b..0000000000 --- a/patches/unapplied/server/0772-Add-various-missing-EntityDropItemEvent-calls.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Tue, 20 Jul 2021 21:35:47 -0700 -Subject: [PATCH] Add various missing EntityDropItemEvent calls - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 936ce33bffd93ed7210b6659c27c476e1db348bb..319bb4d94f8221e20557c0e0805c581447e2ee57 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2491,6 +2491,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe - - entityitem.setDefaultPickUpDelay(); -+ // Paper start - Call EntityDropItemEvent -+ return this.spawnAtLocation(entityitem); -+ } -+ } -+ @Nullable -+ public ItemEntity spawnAtLocation(ItemEntity entityitem) { -+ { -+ // Paper end - Call EntityDropItemEvent - // CraftBukkit start - EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); - Bukkit.getPluginManager().callEvent(event); -diff --git a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java -index 1a37be6015fb5c11301850d455a4f3807076c9be..45646c69ea73936a8916756fde37dd3f39db0d04 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java -@@ -593,7 +593,7 @@ public class Dolphin extends WaterAnimal { - float f2 = 0.02F * Dolphin.this.random.nextFloat(); - - entityitem.setDeltaMovement((double) (0.3F * -Mth.sin(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.cos(f1) * f2), (double) (0.3F * Mth.sin(Dolphin.this.getXRot() * 0.017453292F) * 1.5F), (double) (0.3F * Mth.cos(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.sin(f1) * f2)); -- Dolphin.this.level().addFreshEntity(entityitem); -+ Dolphin.this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent - } - } - } -diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java -index 4ac32078cb074a78a2bb83307013b849f8d59f23..4c2e090a72dbd5bfb928e6ccbcedb1a25231d5b1 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Fox.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java -@@ -513,14 +513,14 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> { - entityitem.setPickUpDelay(40); - entityitem.setThrower(this); - this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); -- this.level().addFreshEntity(entityitem); -+ this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent - } - } - - private void dropItemStack(ItemStack stack) { - ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), stack); - -- this.level().addFreshEntity(entityitem); -+ this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent - } - - @Override -diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -index ee1b2c1fec4b76a821e1d52fbb07e1f302b2efa1..110dd5418b0512a2f27f0c4d5a5f1812356a6a12 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -@@ -357,8 +357,7 @@ public class Goat extends Animal { - double d2 = (double) Mth.randomBetween(this.random, -0.2F, 0.2F); - ItemEntity entityitem = new ItemEntity(this.level(), vec3d.x(), vec3d.y(), vec3d.z(), itemstack, d0, d1, d2); - -- this.level().addFreshEntity(entityitem); -- return true; -+ return this.spawnAtLocation(entityitem) != null; // Paper - Call EntityDropItemEvent - } - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -index 1d9913cbc7fd0c6e29278b02c38703b52af1245b..0e85e3ab58d848b119212fa7d2eb4f92d3efe29b 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -352,8 +352,9 @@ public class Sniffer extends Animal { - - entityitem.setDefaultPickUpDelay(); - this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null); -+ if (this.spawnAtLocation(entityitem) != null) { // Paper - Call EntityDropItemEvent - this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F); -- world.addFreshEntity(entityitem); -+ } // Paper - Call EntityDropItemEvent - } - - @Override diff --git a/patches/unapplied/server/0773-Fix-Bee-flower-NPE.patch b/patches/unapplied/server/0773-Fix-Bee-flower-NPE.patch deleted file mode 100644 index 21a3d68e76..0000000000 --- a/patches/unapplied/server/0773-Fix-Bee-flower-NPE.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Wed, 6 Jul 2022 14:59:38 -0700 -Subject: [PATCH] Fix Bee flower NPE - - -diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index 91ea960ba223bae42655c581b9b6c0981f333c9b..f9521a6e115f0c975a7885b024c99eae300b63bf 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Bee.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java -@@ -810,7 +810,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { - ++this.pollinatingTicks; - if (this.pollinatingTicks > 600) { - Bee.this.savedFlowerPos = null; -- } else { -+ } else if (Bee.this.savedFlowerPos != null) { // Paper - add null check since API can manipulate this - Vec3 vec3d = Vec3.atBottomCenterOf(Bee.this.savedFlowerPos).add(0.0D, 0.6000000238418579D, 0.0D); - - if (vec3d.distanceTo(Bee.this.position()) > 1.0D) { diff --git a/patches/unapplied/server/0774-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch b/patches/unapplied/server/0774-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch deleted file mode 100644 index 03696ce783..0000000000 --- a/patches/unapplied/server/0774-Fix-Spigot-Config-not-using-commands.spam-exclusions.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Doc <[email protected]> -Date: Sun, 17 Jul 2022 11:49:43 -0400 -Subject: [PATCH] Fix Spigot Config not using commands.spam-exclusions - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 19bc63da6bca5b3ff62bb2a148b35e0d3f93bb1d..c26eea3adbe7013ee226f2337e85e423aac11977 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2299,7 +2299,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - } - // Spigot end - // this.chatSpamTickCount += 20; -- if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { -+ if (counted && this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper - exclude from SpigotConfig.spamExclusions - // CraftBukkit end - this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - kick event cause - } diff --git a/patches/unapplied/server/0775-More-Teleport-API.patch b/patches/unapplied/server/0775-More-Teleport-API.patch deleted file mode 100644 index 3cbd69aa87..0000000000 --- a/patches/unapplied/server/0775-More-Teleport-API.patch +++ /dev/null @@ -1,269 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sun, 5 Sep 2021 12:15:59 -0400 -Subject: [PATCH] More Teleport API - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c26eea3adbe7013ee226f2337e85e423aac11977..f2b865d4e28c3d99d50088c61d0b93bf47300a02 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1558,11 +1558,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - return false; // CraftBukkit - Return event status - } - -- PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause); -+ // Paper start - Teleport API -+ Set<io.papermc.paper.entity.TeleportFlag.Relative> relativeFlags = java.util.EnumSet.noneOf(io.papermc.paper.entity.TeleportFlag.Relative.class); -+ for (RelativeMovement relativeArgument : set) { -+ relativeFlags.add(org.bukkit.craftbukkit.entity.CraftPlayer.toApiRelativeFlag(relativeArgument)); -+ } -+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags)); -+ // Paper end - Teleport API - this.cserver.getPluginManager().callEvent(event); - - if (event.isCancelled() || !to.equals(event.getTo())) { -- set.clear(); // Can't relative teleport -+ // set.clear(); // Can't relative teleport // Paper - Teleport API; Now you can! - to = event.isCancelled() ? event.getFrom() : event.getTo(); - d0 = to.getX(); - d1 = to.getY(); -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 46bc34741394740de46546bd4ce7db35c757316c..79e58d7a72a599cd84d479be62f72c523e37dd07 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -219,15 +219,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - - @Override - public boolean teleport(Location location, TeleportCause cause) { -+ // Paper start - Teleport passenger API -+ return teleport(location, cause, new io.papermc.paper.entity.TeleportFlag[0]); -+ } -+ -+ @Override -+ public boolean teleport(Location location, TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) { -+ // Paper end - Preconditions.checkArgument(location != null, "location cannot be null"); - location.checkFinite(); -+ // Paper start - Teleport passenger API -+ Set<io.papermc.paper.entity.TeleportFlag> flagSet = Set.of(flags); -+ boolean dismount = !flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE); -+ boolean ignorePassengers = flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS); -+ // Don't allow teleporting between worlds while keeping passengers -+ if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) { -+ return false; -+ } -+ -+ // Don't allow to teleport between worlds if remaining on vehicle -+ if (!dismount && this.entity.isPassenger() && location.getWorld() != this.getWorld()) { -+ return false; -+ } -+ // Paper end - -- if (this.entity.isVehicle() || this.entity.isRemoved()) { -+ if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API - return false; - } - - // If this entity is riding another entity, we must dismount before teleporting. -- this.entity.stopRiding(); -+ if (dismount) this.entity.stopRiding(); // Paper - Teleport passenger API - - // Let the server handle cross world teleports - if (location.getWorld() != null && !location.getWorld().equals(this.getWorld())) { -@@ -948,6 +969,39 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - return CraftEntity.perm; - } - -+ // Paper start - more teleport API / async chunk API -+ @Override -+ public java.util.concurrent.CompletableFuture<Boolean> teleportAsync(final Location location, final TeleportCause cause, final io.papermc.paper.entity.TeleportFlag... teleportFlags) { -+ Preconditions.checkArgument(location != null, "location"); -+ location.checkFinite(); -+ Location locationClone = location.clone(); // clone so we don't need to worry about mutations after this call. -+ -+ net.minecraft.server.level.ServerLevel world = ((CraftWorld)locationClone.getWorld()).getHandle(); -+ java.util.concurrent.CompletableFuture<Boolean> ret = new java.util.concurrent.CompletableFuture<>(); -+ -+ world.loadChunksForMoveAsync(getHandle().getBoundingBoxAt(locationClone.getX(), locationClone.getY(), locationClone.getZ()), -+ this instanceof CraftPlayer ? ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER : ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, (list) -> { -+ net.minecraft.server.level.ServerChunkCache chunkProviderServer = world.getChunkSource(); -+ for (net.minecraft.world.level.chunk.ChunkAccess chunk : list) { -+ chunkProviderServer.addTicketAtLevel(net.minecraft.server.level.TicketType.POST_TELEPORT, chunk.getPos(), 33, CraftEntity.this.getEntityId()); -+ } -+ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { -+ try { -+ ret.complete(CraftEntity.this.teleport(locationClone, cause, teleportFlags) ? Boolean.TRUE : Boolean.FALSE); -+ } catch (Throwable throwable) { -+ if (throwable instanceof ThreadDeath) { -+ throw (ThreadDeath)throwable; -+ } -+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to teleport entity " + CraftEntity.this, throwable); -+ ret.completeExceptionally(throwable); -+ } -+ }); -+ }); -+ -+ return ret; -+ } -+ // Paper end - more teleport API / async chunk API -+ - // Spigot start - private final org.bukkit.entity.Entity.Spigot spigot = new org.bukkit.entity.Entity.Spigot() - { -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index b0e552d959f349878fc36f136f4d541f85d032fe..c5175427fdb6e990c47c014f99d1784959d83658 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -1197,13 +1197,101 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - - @Override - public void setRotation(float yaw, float pitch) { -- throw new UnsupportedOperationException("Cannot set rotation of players. Consider teleporting instead."); -+ // Paper start - Teleport API -+ Location targetLocation = this.getEyeLocation(); -+ targetLocation.setYaw(yaw); -+ targetLocation.setPitch(pitch); -+ -+ org.bukkit.util.Vector direction = targetLocation.getDirection(); -+ direction.multiply(9999999); // We need to move the target block.. FAR out -+ targetLocation.add(direction); -+ this.lookAt(targetLocation, io.papermc.paper.entity.LookAnchor.EYES); -+ // Paper end - } - - @Override - public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) { -+ // Paper start - Teleport API -+ return this.teleport(location, cause, new io.papermc.paper.entity.TeleportFlag[0]); -+ } -+ -+ @Override -+ public void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor, @NotNull io.papermc.paper.entity.LookAnchor entityAnchor) { -+ this.getHandle().lookAt(toNmsAnchor(playerAnchor), ((CraftEntity) entity).getHandle(), toNmsAnchor(entityAnchor)); -+ } -+ -+ @Override -+ public void lookAt(double x, double y, double z, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor) { -+ this.getHandle().lookAt(toNmsAnchor(playerAnchor), new Vec3(x, y, z)); -+ } -+ -+ public static net.minecraft.commands.arguments.EntityAnchorArgument.Anchor toNmsAnchor(io.papermc.paper.entity.LookAnchor nmsAnchor) { -+ return switch (nmsAnchor) { -+ case EYES -> net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.EYES; -+ case FEET -> net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.FEET; -+ }; -+ } -+ -+ public static io.papermc.paper.entity.LookAnchor toApiAnchor(net.minecraft.commands.arguments.EntityAnchorArgument.Anchor playerAnchor) { -+ return switch (playerAnchor) { -+ case EYES -> io.papermc.paper.entity.LookAnchor.EYES; -+ case FEET -> io.papermc.paper.entity.LookAnchor.FEET; -+ }; -+ } -+ -+ public static net.minecraft.world.entity.RelativeMovement toNmsRelativeFlag(io.papermc.paper.entity.TeleportFlag.Relative apiFlag) { -+ return switch (apiFlag) { -+ case X -> net.minecraft.world.entity.RelativeMovement.X; -+ case Y -> net.minecraft.world.entity.RelativeMovement.Y; -+ case Z -> net.minecraft.world.entity.RelativeMovement.Z; -+ case PITCH -> net.minecraft.world.entity.RelativeMovement.X_ROT; -+ case YAW -> net.minecraft.world.entity.RelativeMovement.Y_ROT; -+ }; -+ } -+ -+ public static io.papermc.paper.entity.TeleportFlag.Relative toApiRelativeFlag(net.minecraft.world.entity.RelativeMovement nmsFlag) { -+ return switch (nmsFlag) { -+ case X -> io.papermc.paper.entity.TeleportFlag.Relative.X; -+ case Y -> io.papermc.paper.entity.TeleportFlag.Relative.Y; -+ case Z -> io.papermc.paper.entity.TeleportFlag.Relative.Z; -+ case X_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.PITCH; -+ case Y_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.YAW; -+ }; -+ } -+ -+ @Override -+ public boolean teleport(Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) { -+ Set<io.papermc.paper.entity.TeleportFlag.Relative> relativeArguments; -+ Set<io.papermc.paper.entity.TeleportFlag> allFlags; -+ if (flags.length == 0) { -+ relativeArguments = Set.of(); -+ allFlags = Set.of(); -+ } else { -+ relativeArguments = java.util.EnumSet.noneOf(io.papermc.paper.entity.TeleportFlag.Relative.class); -+ allFlags = new HashSet<>(); -+ for (io.papermc.paper.entity.TeleportFlag flag : flags) { -+ if (flag instanceof final io.papermc.paper.entity.TeleportFlag.Relative relativeTeleportFlag) { -+ relativeArguments.add(relativeTeleportFlag); -+ } -+ allFlags.add(flag); -+ } -+ } -+ boolean dismount = !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE); -+ boolean ignorePassengers = allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS); -+ // Paper end - Teleport API - Preconditions.checkArgument(location != null, "location"); - Preconditions.checkArgument(location.getWorld() != null, "location.world"); -+ // Paper start - Teleport passenger API -+ // Don't allow teleporting between worlds while keeping passengers -+ if (ignorePassengers && entity.isVehicle() && location.getWorld() != this.getWorld()) { -+ return false; -+ } -+ -+ // Don't allow to teleport between worlds if remaining on vehicle -+ if (!dismount && entity.isPassenger() && location.getWorld() != this.getWorld()) { -+ return false; -+ } -+ // Paper end - location.checkFinite(); - - ServerPlayer entity = this.getHandle(); -@@ -1216,7 +1304,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return false; - } - -- if (entity.isVehicle()) { -+ if (entity.isVehicle() && !ignorePassengers) { // Paper - Teleport API - return false; - } - -@@ -1225,7 +1313,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - // To = Players new Location if Teleport is Successful - Location to = location; - // Create & Call the Teleport Event. -- PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause); -+ PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause, Set.copyOf(relativeArguments)); // Paper - Teleport API - this.server.getPluginManager().callEvent(event); - - // Return False to inform the Plugin that the Teleport was unsuccessful/cancelled. -@@ -1234,7 +1322,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - } - - // If this player is riding another entity, we must dismount before teleporting. -- entity.stopRiding(); -+ if (dismount) entity.stopRiding(); // Paper - Teleport API - - // SPIGOT-5509: Wakeup, similar to riding - if (this.isSleeping()) { -@@ -1250,13 +1338,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - ServerLevel toWorld = ((CraftWorld) to.getWorld()).getHandle(); - - // Close any foreign inventory -- if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) { -+ if (this.getHandle().containerMenu != this.getHandle().inventoryMenu && !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_OPEN_INVENTORY)) { // Paper - this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper - Inventory close reason - } - - // Check if the fromWorld and toWorld are the same. - if (fromWorld == toWorld) { -- entity.connection.teleport(to); -+ // Paper start - Teleport API -+ final Set<net.minecraft.world.entity.RelativeMovement> nms = java.util.EnumSet.noneOf(net.minecraft.world.entity.RelativeMovement.class); -+ for (final io.papermc.paper.entity.TeleportFlag.Relative bukkit : relativeArguments) { -+ nms.add(toNmsRelativeFlag(bukkit)); -+ } -+ entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), nms); -+ // Paper end - Teleport API - } else { - // The respawn reason should never be used if the passed location is non null. - this.server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper diff --git a/patches/unapplied/server/0776-Add-EntityPortalReadyEvent.patch b/patches/unapplied/server/0776-Add-EntityPortalReadyEvent.patch deleted file mode 100644 index 99fe9a8280..0000000000 --- a/patches/unapplied/server/0776-Add-EntityPortalReadyEvent.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Wed, 12 May 2021 04:30:42 -0700 -Subject: [PATCH] Add EntityPortalReadyEvent - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 319bb4d94f8221e20557c0e0805c581447e2ee57..8b44dc6cfddf77bdfe3684d1cdb15bb9125c4137 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2832,6 +2832,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit - this.level().getProfiler().push("portal"); - this.portalTime = i; -+ // Paper start - Add EntityPortalReadyEvent -+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER); -+ if (!event.callEvent()) { -+ this.portalTime = 0; -+ } else { -+ worldserver1 = event.getTargetWorld() == null ? null : ((CraftWorld) event.getTargetWorld()).getHandle(); -+ // Paper end - Add EntityPortalReadyEvent - this.setPortalCooldown(); - // CraftBukkit start - if (this instanceof ServerPlayer) { -@@ -2839,6 +2846,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - } else { - this.changeDimension(worldserver1); - } -+ } // Paper - Add EntityPortalReadyEvent - // CraftBukkit end - this.level().getProfiler().pop(); - } diff --git a/patches/unapplied/server/0777-Don-t-use-level-random-in-entity-constructors.patch b/patches/unapplied/server/0777-Don-t-use-level-random-in-entity-constructors.patch deleted file mode 100644 index ef3475e3a3..0000000000 --- a/patches/unapplied/server/0777-Don-t-use-level-random-in-entity-constructors.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic <[email protected]> -Date: Sun, 10 Jul 2022 14:13:22 -0700 -Subject: [PATCH] Don't use level random in entity constructors - -Paper makes the entity random thread-safe -and constructing an entity off the main thread -should be supported. Some entities (for whatever -reason) use the level's random in some places. - -diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 78acc580d66917e52d89632e3f0b7c1e979714d4..d0dac3dc89b9bb645a1d8498802fb8c6bff6a78e 100644 ---- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -67,7 +67,12 @@ public class ItemEntity extends Entity implements TraceableEntity { - } - - public ItemEntity(Level world, double x, double y, double z, ItemStack stack) { -- this(world, x, y, z, stack, world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D); -+ // Paper start - Don't use level random in entity constructors (to make them thread-safe) -+ this(EntityType.ITEM, world); -+ this.setPos(x, y, z); -+ this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); -+ this.setItem(stack); -+ // Paper end - Don't use level random in entity constructors - } - - public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) { -diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 16f9d38687c0fdda18468b5bfb61b09b98254968..e712bd07ea2946167782473a536e0c72fab4bccd 100644 ---- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -44,7 +44,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { - public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { - this(EntityType.TNT, world); - this.setPos(x, y, z); -- double d3 = world.random.nextDouble() * 6.2831854820251465D; -+ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors - - this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); - this.setFuse(80); diff --git a/patches/unapplied/server/0778-Send-block-entities-after-destroy-prediction.patch b/patches/unapplied/server/0778-Send-block-entities-after-destroy-prediction.patch deleted file mode 100644 index a6024df886..0000000000 --- a/patches/unapplied/server/0778-Send-block-entities-after-destroy-prediction.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sat, 25 Jun 2022 19:45:20 -0400 -Subject: [PATCH] Send block entities after destroy prediction - -Minecraft's prediction system does not handle block entities, so if we are manually sending block entities during -block breaking we need to set it after the prediction is finished. This fixes block entities not showing when cancelling the BlockBreakEvent. - -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 8f4c9b99b638cfce8cc7c55f6369f62e757f4e48..f3389dc345d8b6e5389ae37848d9b268d4bbad83 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -62,6 +62,8 @@ public class ServerPlayerGameMode { - private BlockPos delayedDestroyPos; - private int delayedTickStart; - private int lastSentState; -+ public boolean captureSentBlockEntities = false; // Paper - Send block entities after destroy prediction -+ public boolean capturedBlockEntity = false; // Paper - Send block entities after destroy prediction - - public ServerPlayerGameMode(ServerPlayer player) { - this.gameModeForPlayer = GameType.DEFAULT_MODE; -@@ -188,10 +190,7 @@ public class ServerPlayerGameMode { - this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); - this.debugLogging(pos, false, sequence, "may not interact"); - // Update any tile entity data for this block -- BlockEntity tileentity = this.level.getBlockEntity(pos); -- if (tileentity != null) { -- this.player.connection.send(tileentity.getUpdatePacket()); -- } -+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction - // CraftBukkit end - return; - } -@@ -202,10 +201,7 @@ public class ServerPlayerGameMode { - // Let the client know the block still exists - this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); - // Update any tile entity data for this block -- BlockEntity tileentity = this.level.getBlockEntity(pos); -- if (tileentity != null) { -- this.player.connection.send(tileentity.getUpdatePacket()); -- } -+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction - return; - } - // CraftBukkit end -@@ -387,10 +383,12 @@ public class ServerPlayerGameMode { - } - - // Update any tile entity data for this block -+ if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction - BlockEntity tileentity = this.level.getBlockEntity(pos); - if (tileentity != null) { - this.player.connection.send(tileentity.getUpdatePacket()); - } -+ } else {capturedBlockEntity = true;} // Paper - Send block entities after destroy prediction - return false; - } - } -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f2b865d4e28c3d99d50088c61d0b93bf47300a02..faa43550844fd3a3595bd9621b5730c209a54124 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1704,8 +1704,28 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - return; - } - // Paper end - Don't allow digging into unloaded chunks -+ // Paper start - Send block entities after destroy prediction -+ this.player.gameMode.capturedBlockEntity = false; -+ this.player.gameMode.captureSentBlockEntities = true; -+ // Paper end - Send block entities after destroy prediction - this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxBuildHeight(), packet.getSequence()); - this.player.connection.ackBlockChangesUpTo(packet.getSequence()); -+ // Paper start - Send block entities after destroy prediction -+ this.player.gameMode.captureSentBlockEntities = false; -+ // If a block entity was modified speedup the block change ack to avoid the block entity -+ // being overriden. -+ if (this.player.gameMode.capturedBlockEntity) { -+ // manually tick -+ this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo)); -+ this.player.connection.ackBlockChangesUpTo = -1; -+ -+ this.player.gameMode.capturedBlockEntity = false; -+ BlockEntity tileentity = this.player.level().getBlockEntity(blockposition); -+ if (tileentity != null) { -+ this.player.connection.send(tileentity.getUpdatePacket()); -+ } -+ } -+ // Paper end - Send block entities after destroy prediction - return; - default: - throw new IllegalArgumentException("Invalid player action"); diff --git a/patches/unapplied/server/0779-Warn-on-plugins-accessing-faraway-chunks.patch b/patches/unapplied/server/0779-Warn-on-plugins-accessing-faraway-chunks.patch deleted file mode 100644 index 2b9d9f5b89..0000000000 --- a/patches/unapplied/server/0779-Warn-on-plugins-accessing-faraway-chunks.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Fri, 29 Jul 2022 12:35:19 -0400 -Subject: [PATCH] Warn on plugins accessing faraway chunks - - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 1ed82afbc3aaa826f8067c65fdfc3ffce36a2ce5..59dba562e17e9463c1e00dee4979b61a0f68643e 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -345,7 +345,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - private static boolean isInWorldBoundsHorizontal(BlockPos pos) { -- return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; -+ return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Diff on change warnUnsafeChunk() - } - - private static boolean isOutsideSpawnableHeight(int y) { -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index f2e4494a31dd7ca7e099c6960a9e6378ecac8727..51e709beb32499f2f56189a0426bba93c43e1c0d 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -319,9 +319,24 @@ public class CraftWorld extends CraftRegionAccessor implements World { - public boolean setSpawnLocation(int x, int y, int z) { - return this.setSpawnLocation(x, y, z, 0.0F); - } -+ // Paper start -+ private static void warnUnsafeChunk(String reason, int x, int z) { -+ // if any chunk coord is outside of 30 million blocks -+ if (x > 1875000 || z > 1875000 || x < -1875000 || z < -1875000) { -+ Plugin plugin = io.papermc.paper.util.StackWalkerUtil.getFirstPluginCaller(); -+ if (plugin != null) { -+ plugin.getLogger().warning("Plugin is %s at (%s, %s), this might cause issues.".formatted(reason, x, z)); -+ } -+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) { -+ io.papermc.paper.util.TraceUtil.dumpTraceForThread("Dangerous chunk retrieval"); -+ } -+ } -+ } -+ // Paper end - - @Override - public Chunk getChunkAt(int x, int z) { -+ warnUnsafeChunk("getting a faraway chunk", x, z); // Paper - // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it - net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); - if (chunk == null) { -@@ -422,6 +437,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - @Override - public boolean regenerateChunk(int x, int z) { - org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot -+ warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper - // Paper start - implement regenerateChunk method - final ServerLevel serverLevel = this.world; - final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource(); -@@ -516,6 +532,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - @Override - public boolean loadChunk(int x, int z, boolean generate) { - org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot -+ warnUnsafeChunk("loading a faraway chunk", x, z); // Paper - ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper - - // If generate = false, but the chunk already exists, we will get this back. -@@ -548,6 +565,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - @Override - public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { -+ warnUnsafeChunk("adding a faraway chunk ticket", x, z); // Paper - Preconditions.checkArgument(plugin != null, "null plugin"); - Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled"); - -@@ -648,6 +666,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - @Override - public void setChunkForceLoaded(int x, int z, boolean forced) { -+ warnUnsafeChunk("forceloading a faraway chunk", x, z); // Paper - this.getHandle().setChunkForced(x, z, forced); - } - -@@ -967,6 +986,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - @Override - public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { -+ warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper - // Transient load for this tick - return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); - } -@@ -2400,6 +2420,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - // Spigot end - // Paper start - public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { -+ warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper - if (Bukkit.isPrimaryThread()) { - net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); - if (immediate != null) { diff --git a/patches/unapplied/server/0780-Custom-Chat-Completion-Suggestions-API.patch b/patches/unapplied/server/0780-Custom-Chat-Completion-Suggestions-API.patch deleted file mode 100644 index ef47ad0def..0000000000 --- a/patches/unapplied/server/0780-Custom-Chat-Completion-Suggestions-API.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sat, 30 Jul 2022 11:23:05 -0400 -Subject: [PATCH] Custom Chat Completion Suggestions API - - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index c5175427fdb6e990c47c014f99d1784959d83658..ccc706733689f07f9b4e1635db4a0259817f71aa 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -613,6 +613,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - } - // Paper end - Add sendOpLevel API - -+ // Paper start - custom chat completions API -+ @Override -+ public void addAdditionalChatCompletions(@NotNull Collection<String> completions) { -+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( -+ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.ADD, -+ new ArrayList<>(completions) -+ )); -+ } -+ -+ @Override -+ public void removeAdditionalChatCompletions(@NotNull Collection<String> completions) { -+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( -+ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.REMOVE, -+ new ArrayList<>(completions) -+ )); -+ } -+ // Paper end - custom chat completions API -+ - @Override - public void setCompassTarget(Location loc) { - Preconditions.checkArgument(loc != null, "Location cannot be null"); diff --git a/patches/unapplied/server/0781-Add-and-fix-missing-BlockFadeEvents.patch b/patches/unapplied/server/0781-Add-and-fix-missing-BlockFadeEvents.patch deleted file mode 100644 index d164ac2642..0000000000 --- a/patches/unapplied/server/0781-Add-and-fix-missing-BlockFadeEvents.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Thu, 21 Jul 2022 12:07:54 -0400 -Subject: [PATCH] Add and fix missing BlockFadeEvents - -Beyond calling the BlockFadeEvent in more places, this patch also aims -to pass the proper replacement state to the event, specifically for -potentially waterlogged block states fading. - -Co-authored-by: Lulu13022002 <[email protected] - -diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java -index 6e283e8c3db31f03dd95c94887e647b8d82a3604..1a842694c076d71b14733904c2052183d86d1f5d 100644 ---- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java -@@ -92,6 +92,11 @@ public class FrogspawnBlock extends Block { - } - - private void hatchFrogspawn(ServerLevel world, BlockPos pos, RandomSource random) { -+ // Paper start - Call BlockFadeEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) { -+ return; -+ } -+ // Paper end - Call BlockFadeEvent - this.destroyBlock(world, pos); - world.playSound(null, pos, SoundEvents.FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F); - this.spawnTadpoles(world, pos, random); -diff --git a/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java b/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java -index f660e58badfcc2a90e6dd618428a21bf5ad34969..13ee09f93ec325e416a2b29e3608e870e7f06aed 100644 ---- a/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java -@@ -103,7 +103,7 @@ public class ScaffoldingBlock extends Block implements SimpleWaterloggedBlock { - int i = ScaffoldingBlock.getDistance(world, pos); - BlockState iblockdata1 = (BlockState) ((BlockState) state.setValue(ScaffoldingBlock.DISTANCE, i)).setValue(ScaffoldingBlock.BOTTOM, this.isBottom(world, pos, i)); - -- if ((Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit - BlockFadeEvent -+ if ((Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, iblockdata1.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state - if ((Integer) state.getValue(ScaffoldingBlock.DISTANCE) == 7) { - FallingBlockEntity.fall(world, pos, iblockdata1); - } else { -diff --git a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java -index 41bc7180d7657d43215fcb283afe1a9ccdd54e9d..1ff0e5c120418c3e5f92326580af7254fb4c699f 100644 ---- a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java -@@ -60,12 +60,26 @@ public class SnifferEggBlock extends Block { - return this.getHatchLevel(state) == 2; - } - -+ // Paper start - Call BlockFadeEvent -+ private void rescheduleTick(ServerLevel world, BlockPos pos) { -+ int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS; -+ world.scheduleTick(pos, this, (baseDelay / 3) + world.random.nextInt(RANDOM_HATCH_OFFSET_TICKS)); -+ // reschedule to avoid being stuck here and behave like the other calls (see #onPlace) -+ } -+ // Paper end - Call BlockFadeEvent -+ - @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { - if (!this.isReadyToHatch(state)) { - world.playSound(null, pos, SoundEvents.SNIFFER_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); - world.setBlock(pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2); - } else { -+ // Paper start - Call BlockFadeEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, state.getFluidState().createLegacyBlock()).isCancelled()) { -+ this.rescheduleTick(world, pos); -+ return; -+ } -+ // Paper end - Call BlockFadeEvent - world.playSound(null, pos, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); - world.destroyBlock(pos, false); - Sniffer sniffer = EntityType.SNIFFER.create(world); diff --git a/patches/unapplied/server/0782-Collision-API.patch b/patches/unapplied/server/0782-Collision-API.patch deleted file mode 100644 index 67db25ca90..0000000000 --- a/patches/unapplied/server/0782-Collision-API.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Wed, 6 Oct 2021 20:10:44 -0400 -Subject: [PATCH] Collision API - - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -index fbcf1320ef9c1817b24aa8724cd6cf07319c20b9..5680e9772a2d90e997d2d0aacdda9eddb7edef56 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -@@ -539,5 +539,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor { - - return this.getHandle().clip(new net.minecraft.world.level.ClipContext(start, end, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, net.minecraft.world.phys.shapes.CollisionContext.empty())).getType() == net.minecraft.world.phys.HitResult.Type.MISS; - } -+ -+ @Override -+ public boolean hasCollisionsIn(@org.jetbrains.annotations.NotNull org.bukkit.util.BoundingBox boundingBox) { -+ net.minecraft.world.phys.AABB aabb = new net.minecraft.world.phys.AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ()); -+ -+ return !this.getHandle().noCollision(aabb); -+ } - // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 79e58d7a72a599cd84d479be62f72c523e37dd07..f6d6b2c7aefc39a6e6e2b0e61fd9afb334bee764 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -1164,4 +1164,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - return this.getHandle().noPhysics; - } - // Paper end - missing entity api -+ -+ // Paper start - Collision API -+ @Override -+ public boolean collidesAt(@org.jetbrains.annotations.NotNull Location location) { -+ net.minecraft.world.phys.AABB aabb = this.getHandle().getBoundingBoxAt(location.getX(), location.getY(), location.getZ()); -+ -+ return !this.getHandle().level().noCollision(this.getHandle(), aabb); -+ } -+ -+ @Override -+ public boolean wouldCollideUsing(@org.jetbrains.annotations.NotNull BoundingBox boundingBox) { -+ net.minecraft.world.phys.AABB aabb = new AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ()); -+ -+ return !this.getHandle().level().noCollision(this.getHandle(), aabb); -+ } -+ // Paper end - Collision API - } diff --git a/patches/unapplied/server/0783-Fix-suggest-command-message-for-brigadier-syntax-exc.patch b/patches/unapplied/server/0783-Fix-suggest-command-message-for-brigadier-syntax-exc.patch deleted file mode 100644 index 8645146d61..0000000000 --- a/patches/unapplied/server/0783-Fix-suggest-command-message-for-brigadier-syntax-exc.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: chickeneer <[email protected]> -Date: Mon, 1 Aug 2022 20:13:02 -0500 -Subject: [PATCH] Fix suggest command message for brigadier syntax exceptions - -This is a bug accidentally introduced in upstream CB - -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 8be58d29f2a4753a241e68bd305b3e30186ca0e9..dd7c1ac97505ce7a846aa8ee91bb654d060acc1a 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -392,7 +392,7 @@ public class Commands { - if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { - int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); - MutableComponent ichatmutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((chatmodifier) -> { -- return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, label)); // CraftBukkit -+ return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label)); // CraftBukkit // Paper - }); - - if (i > 10) { diff --git a/patches/unapplied/server/0784-Block-Ticking-API.patch b/patches/unapplied/server/0784-Block-Ticking-API.patch deleted file mode 100644 index d26cc16750..0000000000 --- a/patches/unapplied/server/0784-Block-Ticking-API.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <[email protected]> -Date: Sun, 26 Dec 2021 13:23:46 -0500 -Subject: [PATCH] Block Ticking API - - -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index 6d10396347b69d9243ab902ecc68ede93fa17b7d..af219df5267589300f0ad1d30fa5c81a1f50234f 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -@@ -78,6 +78,12 @@ public class CraftBlock implements Block { - return this.world.getBlockState(this.position); - } - -+ // Paper start -+ public net.minecraft.world.level.material.FluidState getNMSFluid() { -+ return this.world.getFluidState(this.position); -+ } -+ // Paper end -+ - public BlockPos getPosition() { - return this.position; - } -@@ -709,5 +715,23 @@ public class CraftBlock implements Block { - public boolean isValidTool(ItemStack itemStack) { - return getDrops(itemStack).size() != 0; - } -+ -+ @Override -+ public void tick() { -+ final ServerLevel level = this.world.getMinecraftWorld(); -+ this.getNMS().tick(level, this.position, level.random); -+ } -+ -+ -+ @Override -+ public void fluidTick() { -+ this.getNMSFluid().tick(this.world.getMinecraftWorld(), this.position); -+ } -+ -+ @Override -+ public void randomTick() { -+ final ServerLevel level = this.world.getMinecraftWorld(); -+ this.getNMS().randomTick(level, this.position, level.random); -+ } - // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java -index a4252f9078c3ab7e458504496ebcdeb6875724d1..37c5d66dafd877d2231c8d191f5a84748bf24551 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java -@@ -735,4 +735,11 @@ public class CraftBlockData implements BlockData { - return speed; - } - // Paper end - destroy speed API -+ -+ // Paper start - Block tick API -+ @Override -+ public boolean isRandomlyTicked() { -+ return this.state.isRandomlyTicking(); -+ } -+ // Paper end - Block tick API - } diff --git a/patches/unapplied/server/0785-Add-Velocity-IP-Forwarding-Support.patch b/patches/unapplied/server/0785-Add-Velocity-IP-Forwarding-Support.patch deleted file mode 100644 index 64983350da..0000000000 --- a/patches/unapplied/server/0785-Add-Velocity-IP-Forwarding-Support.patch +++ /dev/null @@ -1,242 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andrew Steinborn <[email protected]> -Date: Mon, 8 Oct 2018 14:36:14 -0400 -Subject: [PATCH] Add Velocity IP Forwarding Support - -While Velocity supports BungeeCord-style IP forwarding, it is not secure. Users -have a lot of problems setting up firewalls or setting up plugins like IPWhitelist. -Further, the BungeeCord IP forwarding protocol still retains essentially its original -form, when there is brand new support for custom login plugin messages in 1.13. - -Velocity's modern IP forwarding uses an HMAC-SHA256 code to ensure authenticity -of messages, is packed into a binary format that is smaller than BungeeCord's -forwarding, and is integrated into the Minecraft login process by using the 1.13 -login plugin message packet. - -diff --git a/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java -new file mode 100644 -index 0000000000000000000000000000000000000000..3c31ff3330c2e925e205c0c9ff4f0b832682b576 ---- /dev/null -+++ b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java -@@ -0,0 +1,86 @@ -+package com.destroystokyo.paper.proxy; -+ -+import io.papermc.paper.configuration.GlobalConfiguration; -+import com.google.common.net.InetAddresses; -+import com.mojang.authlib.GameProfile; -+import com.mojang.authlib.properties.Property; -+import java.net.InetAddress; -+import java.security.InvalidKeyException; -+import java.security.MessageDigest; -+import java.security.NoSuchAlgorithmException; -+import java.util.UUID; -+import javax.crypto.Mac; -+import javax.crypto.spec.SecretKeySpec; -+import net.minecraft.network.FriendlyByteBuf; -+import net.minecraft.network.protocol.login.custom.CustomQueryPayload; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.world.entity.player.ProfilePublicKey; -+ -+/** -+ * While Velocity supports BungeeCord-style IP forwarding, it is not secure. Users -+ * have a lot of problems setting up firewalls or setting up plugins like IPWhitelist. -+ * Further, the BungeeCord IP forwarding protocol still retains essentially its original -+ * form, when there is brand-new support for custom login plugin messages in 1.13. -+ * <p> -+ * Velocity's modern IP forwarding uses an HMAC-SHA256 code to ensure authenticity -+ * of messages, is packed into a binary format that is smaller than BungeeCord's -+ * forwarding, and is integrated into the Minecraft login process by using the 1.13 -+ * login plugin message packet. -+ */ -+public class VelocityProxy { -+ private static final int SUPPORTED_FORWARDING_VERSION = 1; -+ public static final int MODERN_FORWARDING_WITH_KEY = 2; -+ public static final int MODERN_FORWARDING_WITH_KEY_V2 = 3; -+ public static final int MODERN_LAZY_SESSION = 4; -+ public static final byte MAX_SUPPORTED_FORWARDING_VERSION = MODERN_LAZY_SESSION; -+ public static final ResourceLocation PLAYER_INFO_CHANNEL = new ResourceLocation("velocity", "player_info"); -+ -+ public static boolean checkIntegrity(final FriendlyByteBuf buf) { -+ final byte[] signature = new byte[32]; -+ buf.readBytes(signature); -+ -+ final byte[] data = new byte[buf.readableBytes()]; -+ buf.getBytes(buf.readerIndex(), data); -+ -+ try { -+ final Mac mac = Mac.getInstance("HmacSHA256"); -+ mac.init(new SecretKeySpec(GlobalConfiguration.get().proxies.velocity.secret.getBytes(java.nio.charset.StandardCharsets.UTF_8), "HmacSHA256")); -+ final byte[] mySignature = mac.doFinal(data); -+ if (!MessageDigest.isEqual(signature, mySignature)) { -+ return false; -+ } -+ } catch (final InvalidKeyException | NoSuchAlgorithmException e) { -+ throw new AssertionError(e); -+ } -+ -+ return true; -+ } -+ -+ public static InetAddress readAddress(final FriendlyByteBuf buf) { -+ return InetAddresses.forString(buf.readUtf(Short.MAX_VALUE)); -+ } -+ -+ public static GameProfile createProfile(final FriendlyByteBuf buf) { -+ final GameProfile profile = new GameProfile(buf.readUUID(), buf.readUtf(16)); -+ readProperties(buf, profile); -+ return profile; -+ } -+ -+ private static void readProperties(final FriendlyByteBuf buf, final GameProfile profile) { -+ final int properties = buf.readVarInt(); -+ for (int i1 = 0; i1 < properties; i1++) { -+ final String name = buf.readUtf(Short.MAX_VALUE); -+ final String value = buf.readUtf(Short.MAX_VALUE); -+ final String signature = buf.readBoolean() ? buf.readUtf(Short.MAX_VALUE) : null; -+ profile.getProperties().put(name, new Property(name, value, signature)); -+ } -+ } -+ -+ public static ProfilePublicKey.Data readForwardedKey(FriendlyByteBuf buf) { -+ return new ProfilePublicKey.Data(buf); -+ } -+ -+ public static UUID readSignerUuidOrElse(FriendlyByteBuf buf, UUID orElse) { -+ return buf.readBoolean() ? buf.readUUID() : orElse; -+ } -+} -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 608d860b940dee870a3df3d52efaed5e9eab17cf..5675931fe3ea896027a510944fc484f41f5ef555 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -274,13 +274,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); - // CraftBukkit end - -+ // Paper start - Add Velocity IP Forwarding Support -+ boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled; -+ String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; -+ String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; -+ // Paper end - Add Velocity IP Forwarding Support - if (!this.usesAuthentication()) { - DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); - // Spigot start -- if (org.spigotmc.SpigotConfig.bungee) { -- DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); -- DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information."); -+ // Paper start - Add Velocity IP Forwarding Support -+ if (usingProxy) { -+ DedicatedServer.LOGGER.warn("Whilst this makes it possible to use " + proxyFlavor + ", unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); -+ DedicatedServer.LOGGER.warn("Please see " + proxyLink + " for further information."); -+ // Paper end - Add Velocity IP Forwarding Support - } else { - DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); - } -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index fb582acfe9e5cb68314ee39e1d54a550d6700e76..b8d8f14c30786321949901ca5184c43bee716355 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -64,6 +64,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - private final String serverId; - private ServerPlayer player; // CraftBukkit - public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding -+ private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support - - public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) { - this.state = ServerLoginPacketListenerImpl.State.HELLO; -@@ -149,6 +150,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - this.state = ServerLoginPacketListenerImpl.State.KEY; - this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge)); - } else { -+ // Paper start - Add Velocity IP Forwarding Support -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { -+ this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt(); -+ net.minecraft.network.FriendlyByteBuf buf = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()); -+ buf.writeByte(com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION); -+ net.minecraft.network.protocol.login.ClientboundCustomQueryPacket packet1 = new net.minecraft.network.protocol.login.ClientboundCustomQueryPacket(this.velocityLoginMessageId, new net.minecraft.network.protocol.login.ClientboundCustomQueryPacket.PlayerInfoChannelPayload(com.destroystokyo.paper.proxy.VelocityProxy.PLAYER_INFO_CHANNEL, buf)); -+ this.connection.send(packet1); -+ return; -+ } -+ // Paper end - Add Velocity IP Forwarding Support - // CraftBukkit start - // Paper start - Cache authenticator threads - authenticatorPool.execute(new Runnable() { -@@ -289,6 +300,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - // CraftBukkit start - private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent -+ // Paper start - Add Velocity IP Forwarding Support -+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { -+ disconnect("This server requires you to connect with Velocity."); -+ return gameprofile; -+ } -+ // Paper end - Add Velocity IP Forwarding Support - String playerName = gameprofile.getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); - java.util.UUID uniqueId = gameprofile.getId(); -@@ -334,6 +351,51 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket packet) { -+ // Paper start - Add Velocity IP Forwarding Support -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && packet.transactionId() == this.velocityLoginMessageId) { -+ ServerboundCustomQueryAnswerPacket.QueryAnswerPayload payload = (ServerboundCustomQueryAnswerPacket.QueryAnswerPayload)packet.payload(); -+ if (payload == null) { -+ this.disconnect("This server requires you to connect with Velocity."); -+ return; -+ } -+ -+ net.minecraft.network.FriendlyByteBuf buf = payload.buffer; -+ -+ if (!com.destroystokyo.paper.proxy.VelocityProxy.checkIntegrity(buf)) { -+ this.disconnect("Unable to verify player details"); -+ return; -+ } -+ -+ int version = buf.readVarInt(); -+ if (version > com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION) { -+ throw new IllegalStateException("Unsupported forwarding version " + version + ", wanted upto " + com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION); -+ } -+ -+ java.net.SocketAddress listening = this.connection.getRemoteAddress(); -+ int port = 0; -+ if (listening instanceof java.net.InetSocketAddress) { -+ port = ((java.net.InetSocketAddress) listening).getPort(); -+ } -+ this.connection.address = new java.net.InetSocketAddress(com.destroystokyo.paper.proxy.VelocityProxy.readAddress(buf), port); -+ -+ this.authenticatedProfile = com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf); -+ -+ //TODO Update handling for lazy sessions, might not even have to do anything? -+ -+ // Proceed with login -+ authenticatorPool.execute(() -> { -+ try { -+ final GameProfile gameprofile = this.callPlayerPreLoginEvents(this.authenticatedProfile); -+ ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId()); -+ ServerLoginPacketListenerImpl.this.startClientVerification(gameprofile); -+ } catch (Exception ex) { -+ disconnect("Failed to verify username!"); -+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + this.authenticatedProfile.getName(), ex); -+ } -+ }); -+ return; -+ } -+ // Paper end - Add Velocity IP Forwarding Support - this.disconnect(ServerLoginPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); - } - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index e849e706660bf0b0ef1748dfee3ba75e5aff9863..10450a2bb6973a647fb6969d3c142e7a6a1011a4 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -815,7 +815,7 @@ public final class CraftServer implements Server { - @Override - public long getConnectionThrottle() { - // Spigot Start - Automatically set connection throttle for bungee configurations -- if (org.spigotmc.SpigotConfig.bungee) { -+ if (org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { // Paper - Add Velocity IP Forwarding Support - return -1; - } else { - return this.configuration.getInt("settings.connection-throttle"); |