From 19f3fb5d2631d511837a765125a89df2e4a78667 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 17:10:27 +0100 Subject: [PATCH 01/16] Base commit --- gradle.properties | 2 +- paper-server/build.gradle.kts | 11 +- .../mojang/math/OctahedralGroup.java.patch | 14 +- .../criterion/LocationPredicate.java.patch | 10 +- .../minecraft/commands/Commands.java.patch | 28 ++- .../net/minecraft/core/Direction.java.patch | 14 +- .../minecraft/core/HolderLookup.java.patch | 20 +- .../minecraft/core/MappedRegistry.java.patch | 16 +- .../net/minecraft/core/Rotations.java.patch | 10 +- .../cauldron/CauldronInteractions.java.patch | 30 ++- .../component/DataComponentPatch.java.patch | 24 +- .../dispenser/DispenseItemBehavior.java.patch | 40 ++-- .../EquipmentDispenseItemBehavior.java.patch | 12 +- .../ShulkerBoxDispenseBehavior.java.patch | 10 +- .../dispenser/SpawnEggItemBehavior.java.patch | 10 +- .../framework/GameTestServer.java.patch | 16 +- .../minecraft/network/Connection.java.patch | 36 +-- .../network/FriendlyByteBuf.java.patch | 14 +- .../network/PacketProcessor.java.patch | 14 +- .../chat/SignedMessageChain.java.patch | 12 +- .../chat/contents/SelectorContents.java.patch | 10 +- .../minecraft/resources/Identifier.java.patch | 16 +- .../NetworkRegistryLoadTask.java.patch | 10 +- .../net/minecraft/server/Bootstrap.java.patch | 12 +- .../net/minecraft/server/Main.java.patch | 26 ++- .../server/MinecraftServer.java.patch | 153 ++++++------- .../server/commands/BanIpCommands.java.patch | 10 +- .../commands/DifficultyCommand.java.patch | 10 +- .../server/commands/GiveCommand.java.patch | 14 +- .../server/commands/KickCommand.java.patch | 10 +- .../server/commands/PlaceCommand.java.patch | 10 +- .../server/commands/RideCommand.java.patch | 10 +- .../commands/ScheduleCommand.java.patch | 14 +- .../server/commands/SummonCommand.java.patch | 14 +- .../commands/TeleportCommand.java.patch | 10 +- .../server/commands/TimeCommand.java.patch | 18 +- .../dedicated/DedicatedServer.java.patch | 46 ++-- .../server/level/ChunkHolder.java.patch | 26 ++- .../server/level/ChunkMap.java.patch | 56 +++-- .../server/level/ServerChunkCache.java.patch | 36 +-- .../server/level/ServerLevel.java.patch | 123 ++++++----- .../server/level/ServerPlayer.java.patch | 164 +++++++------- .../level/ServerPlayerGameMode.java.patch | 61 +++--- .../server/level/WorldGenRegion.java.patch | 20 +- .../ServerConnectionListener.java.patch | 16 +- .../ServerGamePacketListenerImpl.java.patch | 200 ++++++++--------- .../ServerLoginPacketListenerImpl.java.patch | 48 ++-- .../config/PrepareSpawnTask.java.patch | 18 +- .../CachedUserNameToIdResolver.java.patch | 29 ++- .../players/OldUsersConverter.java.patch | 20 +- .../server/players/PlayerList.java.patch | 83 +++---- .../rcon/thread/QueryThreadGs4.java.patch | 12 +- .../server/rcon/thread/RconClient.java.patch | 14 +- .../util/SimpleBitStorage.java.patch | 18 +- .../minecraft/util/ZeroBitStorage.java.patch | 10 +- .../ItemStackTheFlatteningFix.java.patch | 10 +- .../world/InteractionResult.java.patch | 10 +- .../world/RandomizableContainer.java.patch | 16 +- .../world/effect/MobEffectInstance.java.patch | 16 +- .../world/effect/WeavingMobEffect.java.patch | 12 +- .../minecraft/world/entity/Entity.java.patch | 197 +++++++++-------- .../world/entity/ExperienceOrb.java.patch | 29 ++- .../entity/InsideBlockEffectType.java.patch | 10 +- .../world/entity/LivingEntity.java.patch | 205 +++++++++--------- .../net/minecraft/world/entity/Mob.java.patch | 46 ++-- .../world/entity/TamableAnimal.java.patch | 18 +- .../entity/ai/behavior/AcquirePoi.java.patch | 10 +- .../AssignProfessionFromJobSite.java.patch | 10 +- .../entity/ai/behavior/SleepInBed.java.patch | 10 +- .../ai/behavior/StartAttacking.java.patch | 10 +- .../StopAttackingIfTargetInvalid.java.patch | 10 +- ...TransportItemsBetweenContainers.java.patch | 10 +- .../ai/behavior/VillagerMakeLove.java.patch | 10 +- .../world/entity/ai/goal/Goal.java.patch | 12 +- .../entity/ai/goal/RemoveBlockGoal.java.patch | 14 +- .../ai/goal/target/TargetGoal.java.patch | 12 +- .../GroundPathNavigation.java.patch | 14 +- .../ai/navigation/PathNavigation.java.patch | 20 +- .../entity/ai/village/VillageSiege.java.patch | 10 +- .../world/entity/ambient/Bat.java.patch | 16 +- .../animal/armadillo/Armadillo.java.patch | 16 +- .../world/entity/animal/bee/Bee.java.patch | 28 ++- .../entity/animal/camel/Camel.java.patch | 18 +- .../world/entity/animal/goat/Goat.java.patch | 14 +- .../entity/animal/parrot/Parrot.java.patch | 16 +- .../world/entity/animal/wolf/Wolf.java.patch | 20 +- .../boss/enderdragon/EndCrystal.java.patch | 20 +- .../entity/decoration/ArmorStand.java.patch | 42 ++-- .../decoration/BlockAttachedEntity.java.patch | 55 +++-- .../entity/decoration/ItemFrame.java.patch | 26 ++- .../LeashFenceKnotEntity.java.patch | 14 +- .../world/entity/item/ItemEntity.java.patch | 36 +-- .../world/entity/monster/EnderMan.java.patch | 26 ++- .../world/entity/monster/Endermite.java.patch | 12 +- .../world/entity/monster/Monster.java.patch | 10 +- .../world/entity/monster/Phantom.java.patch | 18 +- .../entity/monster/Silverfish.java.patch | 14 +- .../entity/monster/piglin/Piglin.java.patch | 22 +- .../skeleton/WitherSkeleton.java.patch | 12 +- .../entity/monster/zombie/Zombie.java.patch | 46 ++-- .../WanderingTraderSpawner.java.patch | 14 +- .../world/entity/player/Player.java.patch | 81 +++---- .../entity/projectile/Projectile.java.patch | 34 +-- .../world/entity/raid/Raid.java.patch | 44 ++-- .../world/entity/raid/Raids.java.patch | 12 +- .../entity/vehicle/VehicleEntity.java.patch | 12 +- .../minecart/NewMinecartBehavior.java.patch | 18 +- .../minecart/OldMinecartBehavior.java.patch | 14 +- .../AbstractContainerMenu.java.patch | 57 ++--- .../world/inventory/BeaconMenu.java.patch | 18 +- .../inventory/CartographyTableMenu.java.patch | 18 +- .../inventory/EnchantmentMenu.java.patch | 50 +++-- .../world/inventory/GrindstoneMenu.java.patch | 22 +- .../inventory/ItemCombinerMenu.java.patch | 20 +- .../world/inventory/LecternMenu.java.patch | 33 +-- .../world/inventory/LoomMenu.java.patch | 47 ++-- .../inventory/StonecutterMenu.java.patch | 42 ++-- .../world/item/ArmorStandItem.java.patch | 10 +- .../minecraft/world/item/AxeItem.java.patch | 10 +- .../minecraft/world/item/BlockItem.java.patch | 16 +- .../minecraft/world/item/BoatItem.java.patch | 14 +- .../minecraft/world/item/BowItem.java.patch | 10 +- .../world/item/BucketItem.java.patch | 20 +- .../world/item/CrossbowItem.java.patch | 16 +- .../world/item/EndCrystalItem.java.patch | 10 +- .../world/item/EnderEyeItem.java.patch | 14 +- .../world/item/FireworkRocketItem.java.patch | 14 +- .../world/item/HangingEntityItem.java.patch | 10 +- .../minecraft/world/item/ItemStack.java.patch | 28 ++- .../minecraft/world/item/LeadItem.java.patch | 12 +- .../world/item/MinecartItem.java.patch | 10 +- .../item/ProjectileWeaponItem.java.patch | 16 +- .../world/item/ShovelItem.java.patch | 10 +- .../world/item/SpawnEggItem.java.patch | 14 +- .../world/item/TridentItem.java.patch | 12 +- .../item/alchemy/PotionBrewing.java.patch | 24 +- .../component/LodestoneTracker.java.patch | 10 +- .../component/ResolvableProfile.java.patch | 12 +- ...ApplyStatusEffectsConsumeEffect.java.patch | 10 +- .../crafting/SmithingTrimRecipe.java.patch | 16 +- .../item/trading/MerchantOffer.java.patch | 24 +- .../world/level/BaseCommandBlock.java.patch | 22 +- .../minecraft/world/level/Level.java.patch | 54 +++-- .../world/level/NaturalSpawner.java.patch | 34 +-- .../world/level/block/BedBlock.java.patch | 14 +- .../world/level/block/ButtonBlock.java.patch | 16 +- .../world/level/block/CakeBlock.java.patch | 12 +- .../world/level/block/ChestBlock.java.patch | 18 +- .../level/block/ComparatorBlock.java.patch | 12 +- .../level/block/ComposterBlock.java.patch | 30 ++- .../block/CopperGolemStatueBlock.java.patch | 10 +- .../block/DoubleBlockCombiner.java.patch | 10 +- .../level/block/EndPortalBlock.java.patch | 16 +- .../level/block/EnderChestBlock.java.patch | 10 +- .../level/block/FlowerPotBlock.java.patch | 12 +- .../level/block/MushroomBlock.java.patch | 16 +- .../level/block/NetherPortalBlock.java.patch | 22 +- .../level/block/RespawnAnchorBlock.java.patch | 14 +- .../world/level/block/TntBlock.java.patch | 20 +- .../level/block/TripWireHookBlock.java.patch | 19 +- .../entity/BeehiveBlockEntity.java.patch | 38 ++-- .../entity/BrushableBlockEntity.java.patch | 18 +- .../entity/CommandBlockEntity.java.patch | 12 +- .../block/entity/HopperBlockEntity.java.patch | 35 +-- .../entity/LecternBlockEntity.java.patch | 20 +- .../block/entity/SignBlockEntity.java.patch | 20 +- .../level/block/grower/TreeGrower.java.patch | 14 +- .../block/piston/PistonBaseBlock.java.patch | 20 +- .../world/level/border/WorldBorder.java.patch | 26 ++- .../level/chunk/ChunkGenerator.java.patch | 26 ++- .../ChunkGeneratorStructureState.java.patch | 19 +- .../world/level/chunk/LevelChunk.java.patch | 34 +-- .../world/level/chunk/ProtoChunk.java.patch | 10 +- .../level/chunk/storage/RegionFile.java.patch | 16 +- .../storage/RegionFileStorage.java.patch | 16 +- .../storage/SerializableChunkData.java.patch | 28 ++- .../storage/SimpleRegionStorage.java.patch | 12 +- .../PersistentEntitySectionManager.java.patch | 44 ++-- .../vibrations/VibrationSystem.java.patch | 12 +- .../level/levelgen/PatrolSpawner.java.patch | 12 +- .../structure/StructureCheck.java.patch | 16 +- .../StructureTemplate.java.patch | 30 ++- .../level/material/FlowingFluid.java.patch | 24 +- .../level/portal/PortalForcer.java.patch | 22 +- .../world/level/portal/PortalShape.java.patch | 28 ++- .../level/redstone/NeighborUpdater.java.patch | 10 +- .../storage/LevelStorageSource.java.patch | 14 +- .../storage/PlayerDataStorage.java.patch | 16 +- .../level/storage/SavedDataStorage.java.patch | 12 +- .../ExplorationMapFunction.java.patch | 10 +- .../net/minecraft/CrashReport.java.patch | 2 +- .../arguments/EntityArgument.java.patch | 4 +- .../core/RegistrySetBuilder.java.patch | 4 +- .../cauldron/CauldronInteraction.java.patch | 2 +- .../net/minecraft/nbt/CompoundTag.java.patch | 8 +- .../net/minecraft/nbt/NbtAccounter.java.patch | 4 +- .../net/minecraft/nbt/NbtIo.java.patch | 2 +- .../network/PacketEncoder.java.patch | 2 +- .../chat/OutgoingChatMessage.java.patch | 10 +- .../ClientIntentionPacket.java.patch | 2 +- .../syncher/SynchedEntityData.java.patch | 2 +- .../server/commands/DebugCommand.java.patch | 4 +- .../dedicated/ServerWatchdog.java.patch | 2 +- .../server/dedicated/Settings.java.patch | 16 +- .../server/gui/MinecraftServerGui.java.patch | 14 +- .../server/level/DistanceManager.java.patch | 4 +- .../network/LegacyQueryHandler.java.patch | 24 +- ...ConfigurationPacketListenerImpl.java.patch | 6 +- .../server/players/ProfileResolver.java.patch | 4 +- .../players/UserBanListEntry.java.patch | 2 +- .../ServerWaypointManager.java.patch | 2 +- .../stats/ServerStatsCounter.java.patch | 2 +- .../net/minecraft/tags/TagLoader.java.patch | 8 +- .../util/PlaceholderLookupProvider.java.patch | 2 +- .../util/datafix/DataFixTypes.java.patch | 4 +- .../util/parsing/packrat/Scope.java.patch | 2 +- .../net/minecraft/world/Container.java.patch | 4 +- .../net/minecraft/world/LockCode.java.patch | 2 +- .../world/entity/EntitySelector.java.patch | 10 +- .../world/entity/EntityType.java.patch | 2 +- .../InsideBlockEffectApplier.java.patch | 2 +- .../world/entity/NeutralMob.java.patch | 4 +- .../ai/behavior/HarvestFarmland.java.patch | 4 +- .../entity/ai/goal/FollowOwnerGoal.java.patch | 2 +- .../entity/animal/allay/Allay.java.patch | 6 +- .../entity/animal/axolotl/Axolotl.java.patch | 6 +- .../entity/animal/dolphin/Dolphin.java.patch | 2 +- .../equine/AbstractChestedHorse.java.patch | 2 +- .../animal/equine/AbstractHorse.java.patch | 22 +- .../world/entity/animal/feline/Cat.java.patch | 4 +- .../world/entity/animal/fox/Fox.java.patch | 18 +- .../animal/golem/CopperGolem.java.patch | 6 +- .../entity/animal/golem/IronGolem.java.patch | 4 +- .../animal/happyghast/HappyGhast.java.patch | 4 +- .../nautilus/AbstractNautilus.java.patch | 4 +- .../entity/animal/panda/Panda.java.patch | 12 +- .../world/entity/animal/pig/Pig.java.patch | 2 +- .../boss/enderdragon/EnderDragon.java.patch | 8 +- .../entity/boss/wither/WitherBoss.java.patch | 14 +- .../world/entity/monster/Ghast.java.patch | 2 +- .../world/entity/monster/Shulker.java.patch | 6 +- .../world/entity/monster/Vex.java.patch | 4 +- .../monster/creaking/Creaking.java.patch | 6 +- .../entity/monster/illager/Evoker.java.patch | 2 +- .../monster/illager/Illusioner.java.patch | 8 +- .../illager/SpellcasterIllager.java.patch | 2 +- .../entity/monster/piglin/PiglinAi.java.patch | 12 +- .../skeleton/AbstractSkeleton.java.patch | 14 +- .../entity/monster/warden/Warden.java.patch | 4 +- .../entity/npc/villager/Villager.java.patch | 22 +- .../WanderingTrader.java.patch | 8 +- .../projectile/arrow/ThrownTrident.java.patch | 2 +- .../Snowball.java.patch | 2 +- .../world/entity/raid/Raider.java.patch | 4 +- .../entity/vehicle/ContainerEntity.java.patch | 8 +- .../vehicle/boat/AbstractBoat.java.patch | 2 +- .../vehicle/boat/AbstractChestBoat.java.patch | 10 +- .../minecart/MinecartCommandBlock.java.patch | 10 +- .../inventory/AbstractCraftingMenu.java.patch | 2 +- .../inventory/AbstractFurnaceMenu.java.patch | 6 +- .../world/inventory/InventoryMenu.java.patch | 4 +- .../world/item/DebugStickItem.java.patch | 4 +- .../world/item/EmptyMapItem.java.patch | 2 +- .../item/component/TypedEntityData.java.patch | 2 +- .../consume_effects/ConsumeEffect.java.patch | 2 +- .../world/item/crafting/Ingredient.java.patch | 4 +- .../enchantment/EnchantmentHelper.java.patch | 2 +- .../world/level/EntityGetter.java.patch | 2 +- .../level/PathNavigationRegion.java.patch | 2 +- .../world/level/ServerExplosion.java.patch | 16 +- .../world/level/TicketStorage.java.patch | 4 +- .../level/block/BaseFireBlock.java.patch | 4 +- .../world/level/block/Block.java.patch | 16 +- .../level/block/CopperBulbBlock.java.patch | 2 +- .../world/level/block/LecternBlock.java.patch | 2 +- .../level/block/MultifaceSpreader.java.patch | 4 +- .../block/PointedDripstoneBlock.java.patch | 10 +- .../level/block/PoweredRailBlock.java.patch | 2 +- .../world/level/block/RailState.java.patch | 6 +- .../level/block/RedStoneOreBlock.java.patch | 4 +- .../level/block/SculkVeinBlock.java.patch | 4 +- .../block/SpreadingSnowyBlock.java.patch | 4 +- .../block/SweetBerryBushBlock.java.patch | 4 +- .../world/level/block/VineBlock.java.patch | 8 +- .../AbstractFurnaceBlockEntity.java.patch | 18 +- .../block/entity/BarrelBlockEntity.java.patch | 2 +- .../block/entity/BeaconBlockEntity.java.patch | 20 +- .../level/block/entity/BlockEntity.java.patch | 20 +- .../entity/BrewingStandBlockEntity.java.patch | 18 +- ...alibratedSculkSensorBlockEntity.java.patch | 4 +- .../entity/CampfireBlockEntity.java.patch | 2 +- .../block/entity/ChestBlockEntity.java.patch | 2 +- .../entity/ConduitBlockEntity.java.patch | 6 +- .../entity/CrafterBlockEntity.java.patch | 2 +- .../entity/SculkSensorBlockEntity.java.patch | 6 +- .../SculkShriekerBlockEntity.java.patch | 4 +- .../trialspawner/TrialSpawner.java.patch | 6 +- .../entity/vault/VaultServerData.java.patch | 2 +- .../block/state/BlockBehaviour.java.patch | 18 +- .../level/block/state/StateHolder.java.patch | 2 +- .../properties/IntegerProperty.java.patch | 2 +- .../level/chunk/LevelChunkSection.java.patch | 8 +- .../level/chunk/PalettedContainer.java.patch | 12 +- .../placement/StructurePlacement.java.patch | 2 +- .../structures/EndCityPieces.java.patch | 2 +- .../structures/MineshaftPieces.java.patch | 2 +- .../NetherFortressPieces.java.patch | 2 +- .../structures/StrongholdPieces.java.patch | 2 +- .../pathfinder/WalkNodeEvaluator.java.patch | 2 +- .../maps/MapItemSavedData.java.patch | 10 +- .../level/storage/PrimaryLevelData.java.patch | 2 +- .../LootPoolSingletonContainer.java.patch | 6 +- .../world/scores/Scoreboard.java.patch | 2 +- 313 files changed, 3455 insertions(+), 2008 deletions(-) rename paper-server/patches/{sources => rejected}/com/mojang/math/OctahedralGroup.java.patch (68%) rename paper-server/patches/{sources => rejected}/net/minecraft/advancements/criterion/LocationPredicate.java.patch (64%) rename paper-server/patches/{sources => rejected}/net/minecraft/commands/Commands.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/Direction.java.patch (70%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/HolderLookup.java.patch (70%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/MappedRegistry.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/Rotations.java.patch (72%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/cauldron/CauldronInteractions.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/component/DataComponentPatch.java.patch (82%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch (82%) rename paper-server/patches/{sources => rejected}/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/gametest/framework/GameTestServer.java.patch (72%) rename paper-server/patches/{sources => rejected}/net/minecraft/network/Connection.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/network/FriendlyByteBuf.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/network/PacketProcessor.java.patch (85%) rename paper-server/patches/{sources => rejected}/net/minecraft/network/chat/SignedMessageChain.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/network/chat/contents/SelectorContents.java.patch (56%) rename paper-server/patches/{sources => rejected}/net/minecraft/resources/Identifier.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/resources/NetworkRegistryLoadTask.java.patch (56%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/Bootstrap.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/Main.java.patch (95%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/MinecraftServer.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/BanIpCommands.java.patch (54%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/DifficultyCommand.java.patch (68%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/GiveCommand.java.patch (76%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/KickCommand.java.patch (59%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/PlaceCommand.java.patch (63%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/RideCommand.java.patch (62%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/ScheduleCommand.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/SummonCommand.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/TeleportCommand.java.patch (65%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/commands/TimeCommand.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/dedicated/DedicatedServer.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ChunkHolder.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ChunkMap.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ServerChunkCache.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ServerLevel.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ServerPlayer.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/ServerPlayerGameMode.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/level/WorldGenRegion.java.patch (82%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/network/ServerConnectionListener.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch (96%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/network/config/PrepareSpawnTask.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/players/OldUsersConverter.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/players/PlayerList.java.patch (96%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch (93%) rename paper-server/patches/{sources => rejected}/net/minecraft/server/rcon/thread/RconClient.java.patch (74%) rename paper-server/patches/{sources => rejected}/net/minecraft/util/SimpleBitStorage.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/util/ZeroBitStorage.java.patch (77%) rename paper-server/patches/{sources => rejected}/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch (56%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/InteractionResult.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/RandomizableContainer.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/effect/MobEffectInstance.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/effect/WeavingMobEffect.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/Entity.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ExperienceOrb.java.patch (93%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/InsideBlockEffectType.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/LivingEntity.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/Mob.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/TamableAnimal.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch (65%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch (74%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch (59%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch (82%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch (62%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch (69%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/goal/Goal.java.patch (71%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch (55%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch (63%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ai/village/VillageSiege.java.patch (64%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/ambient/Bat.java.patch (77%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch (76%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/bee/Bee.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/camel/Camel.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/goat/Goat.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/parrot/Parrot.java.patch (69%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/animal/wolf/Wolf.java.patch (82%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/decoration/ArmorStand.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/decoration/ItemFrame.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch (69%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/item/ItemEntity.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/EnderMan.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/Endermite.java.patch (61%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/Monster.java.patch (58%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/Phantom.java.patch (76%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/Silverfish.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/piglin/Piglin.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch (62%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/monster/zombie/Zombie.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/player/Player.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/projectile/Projectile.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/raid/Raid.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/raid/Raids.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/AbstractContainerMenu.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/BeaconMenu.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/CartographyTableMenu.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/EnchantmentMenu.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/GrindstoneMenu.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/ItemCombinerMenu.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/LecternMenu.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/LoomMenu.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/inventory/StonecutterMenu.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/ArmorStandItem.java.patch (70%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/AxeItem.java.patch (61%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/BlockItem.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/BoatItem.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/BowItem.java.patch (61%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/BucketItem.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/CrossbowItem.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/EndCrystalItem.java.patch (73%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/EnderEyeItem.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/FireworkRocketItem.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/HangingEntityItem.java.patch (79%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/ItemStack.java.patch (94%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/LeadItem.java.patch (85%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/MinecartItem.java.patch (68%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/ProjectileWeaponItem.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/ShovelItem.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/SpawnEggItem.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/TridentItem.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/alchemy/PotionBrewing.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/component/LodestoneTracker.java.patch (57%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/component/ResolvableProfile.java.patch (75%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch (62%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/item/trading/MerchantOffer.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/BaseCommandBlock.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/Level.java.patch (93%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/NaturalSpawner.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/BedBlock.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/ButtonBlock.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/CakeBlock.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/ChestBlock.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/ComparatorBlock.java.patch (73%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/ComposterBlock.java.patch (86%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch (73%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch (69%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/EndPortalBlock.java.patch (85%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/EnderChestBlock.java.patch (77%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/FlowerPotBlock.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/MushroomBlock.java.patch (68%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/NetherPortalBlock.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch (79%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/TntBlock.java.patch (85%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/TripWireHookBlock.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch (70%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/grower/TreeGrower.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/border/WorldBorder.java.patch (87%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/ChunkGenerator.java.patch (91%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch (93%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/LevelChunk.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/ProtoChunk.java.patch (74%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/storage/RegionFile.java.patch (78%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch (84%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch (79%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch (88%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch (81%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/material/FlowingFluid.java.patch (89%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/portal/PortalForcer.java.patch (90%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/portal/PortalShape.java.patch (92%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/redstone/NeighborUpdater.java.patch (77%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/storage/LevelStorageSource.java.patch (83%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/storage/PlayerDataStorage.java.patch (80%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/storage/SavedDataStorage.java.patch (70%) rename paper-server/patches/{sources => rejected}/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch (81%) diff --git a/gradle.properties b/gradle.properties index 99224ed0a3a6..1985598b777c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ apiVersion=26.1.2 channel=STABLE # Set to true while updating Minecraft version -updatingMinecraft=false +updatingMinecraft=true org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 51c9f5460198..aa72cb431f80 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -1,5 +1,6 @@ import io.papermc.fill.model.BuildChannel import io.papermc.paperweight.attribute.DevBundleOutput +import io.papermc.paperweight.core.tasks.patchroulette.AbstractPatchRouletteTask import io.papermc.paperweight.util.* import java.time.Instant @@ -13,17 +14,23 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" +repositories { + mavenLocal() +} dependencies { - mache("io.papermc:mache:26.1.2+build.1") + mache("io.papermc:mache:26.1.2+build.local-SNAPSHOT") paperclip("io.papermc:paperclip:3.0.4") } +tasks.withType().configureEach { + endpoint = "http://127.0.0.1:8080/api" +} paperweight { minecraftVersion = providers.gradleProperty("mcVersion") gitFilePatches = false updatingMinecraft { - // oldPaperCommit = "7e80cef5198561d0db53406127e5b8bc7af51577" + oldPaperCommit = "711c5de2b05df39b72c44ff54e9f9381f8d153cb" } } diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch similarity index 68% rename from paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch rename to paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch index 590b8b09adbb..bc69eda6f58b 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/com/mojang/math/OctahedralGroup.java b/com/mojang/math/OctahedralGroup.java +index 9b0864614728596b9c885305d540fd8a39277aee..9be2c8e912f52a3099b9a358ed3e5b17f31dd4ae 100644 --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -99,6 +_,12 @@ +@@ -99,6 +99,12 @@ public enum OctahedralGroup implements StringRepresentable { .map(f -> Arrays.stream(values()).filter(s -> f.compose(s) == IDENTITY).findAny().get()) .toArray(OctahedralGroup[]::new); @@ -13,7 +21,7 @@ private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -139,7 +_,7 @@ +@@ -139,7 +145,7 @@ public enum OctahedralGroup implements StringRepresentable { return this.name; } @@ -22,7 +30,7 @@ if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, facing -> { Direction.Axis oldAxis = facing.getAxis(); -@@ -150,6 +_,11 @@ +@@ -150,6 +156,11 @@ public enum OctahedralGroup implements StringRepresentable { }); } diff --git a/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch b/paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch similarity index 64% rename from paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch rename to paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch index 1f1c3031b202..5cbea554c724 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch +++ b/paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/advancements/criterion/LocationPredicate.java b/net/minecraft/advancements/criterion/LocationPredicate.java +index 6ba5ffb666d68be734a70323c0eb942708b8e77e..1d5209fa2cb129e59fa9b311bbe0ac9fe11e362c 100644 --- a/net/minecraft/advancements/criterion/LocationPredicate.java +++ b/net/minecraft/advancements/criterion/LocationPredicate.java -@@ -44,7 +_,7 @@ +@@ -44,7 +44,7 @@ public record LocationPredicate( public boolean matches(final ServerLevel level, final double x, final double y, final double z) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { return false; diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/commands/Commands.java.patch rename to paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch index cfed6bb42dec..5ff202861060 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java +index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786eef5c3031 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -157,6 +_,7 @@ +@@ -157,6 +157,7 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public class Commands { @@ -8,7 +16,7 @@ public static final String COMMAND_PREFIX = "/"; private static final ThreadLocal<@Nullable ExecutionContext> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); private static final Logger LOGGER = LogUtils.getLogger(); -@@ -181,6 +_,7 @@ +@@ -181,6 +182,7 @@ public class Commands { @Override public boolean isRestricted(final CommandNode node) { @@ -16,7 +24,7 @@ Predicate requirement = node.getRequirement(); return !requirement.test(this.noPermissionSource); } -@@ -188,6 +_,11 @@ +@@ -188,6 +190,11 @@ public class Commands { private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(final Commands.CommandSelection commandSelection, final CommandBuildContext context) { @@ -28,7 +36,7 @@ AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -299,6 +_,42 @@ +@@ -299,6 +306,42 @@ public class Commands { PublishCommand.register(this.dispatcher); } @@ -71,7 +79,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -318,6 +_,13 @@ +@@ -318,6 +361,13 @@ public class Commands { } public void performCommand(final ParseResults command, final String commandString) { @@ -85,7 +93,7 @@ CommandSourceStack sender = command.getContext().getSource(); Profiler.get().push(() -> "/" + commandString); ContextChain commandChain = finishParsing(command, commandString, sender); -@@ -331,10 +_,12 @@ +@@ -331,10 +381,12 @@ public class Commands { ) ); } @@ -101,7 +109,7 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -365,7 +_,11 @@ +@@ -365,7 +417,11 @@ public class Commands { return ContextChain.tryFlatten(command.getContext().build(commandString)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(command.getReader())); } catch (CommandSyntaxException var7) { @@ -114,7 +122,7 @@ if (var7.getInput() != null && var7.getCursor() >= 0) { int cursor = Math.min(var7.getInput().length(), var7.getCursor()); MutableComponent context = Component.empty() -@@ -382,7 +_,17 @@ +@@ -382,7 +438,17 @@ public class Commands { } context.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -133,7 +141,7 @@ } return null; -@@ -410,19 +_,112 @@ +@@ -410,19 +476,112 @@ public class Commands { } public void sendCommands(final ServerPlayer player) { @@ -249,7 +257,7 @@ if (builder.getRedirect() != null) { builder.redirect(converted.get(builder.getRedirect())); } -@@ -431,7 +_,7 @@ +@@ -431,7 +590,7 @@ public class Commands { converted.put(child, node); target.addChild(node); if (!child.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/core/Direction.java.patch b/paper-server/patches/rejected/net/minecraft/core/Direction.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/core/Direction.java.patch rename to paper-server/patches/rejected/net/minecraft/core/Direction.java.patch index 4d521d485ece..58e852aecd2d 100644 --- a/paper-server/patches/sources/net/minecraft/core/Direction.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/Direction.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java +index a47cff508b912c9eb2e545710f37fe8105c37ca2..3f516ffd7a76f1d17daaa865f7446803b8217bcc 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -63,6 +_,12 @@ +@@ -63,6 +63,12 @@ public enum Direction implements StringRepresentable { .sorted(Comparator.comparingInt(d -> d.data2d)) .toArray(Direction[]::new); @@ -13,7 +21,7 @@ private Direction( final int data3d, final int oppositeIndex, -@@ -81,6 +_,11 @@ +@@ -81,6 +87,11 @@ public enum Direction implements StringRepresentable { this.normal = normal; this.normalVec3 = Vec3.atLowerCornerOf(normal); this.normalVec3f = new Vector3f(normal.getX(), normal.getY(), normal.getZ()); @@ -25,7 +33,7 @@ } public static Direction[] orderedByNearest(final Entity entity) { -@@ -253,15 +_,15 @@ +@@ -253,15 +264,15 @@ public enum Direction implements StringRepresentable { } public int getStepX() { diff --git a/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch b/paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch rename to paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch index fb7582690da5..e2b9baa5bb86 100644 --- a/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/HolderLookup.java b/net/minecraft/core/HolderLookup.java +index ff8a3ae629ec89a79c6508cd5f5bbcd15616802c..36dc097890a276768a1dabb9ff48e430ad833c8c 100644 --- a/net/minecraft/core/HolderLookup.java +++ b/net/minecraft/core/HolderLookup.java -@@ -69,6 +_,9 @@ +@@ -69,6 +69,9 @@ public interface HolderLookup extends HolderGetter { } public interface RegistryLookup extends HolderLookup, HolderOwner { @@ -10,7 +18,7 @@ ResourceKey> key(); Lifecycle registryLifecycle(); -@@ -83,6 +_,13 @@ +@@ -83,6 +86,13 @@ public interface HolderLookup extends HolderGetter { Objects.requireNonNull(RegistryLookup.this); } @@ -24,17 +32,17 @@ @Override public HolderLookup.RegistryLookup parent() { return RegistryLookup.this; -@@ -102,6 +_,13 @@ - +@@ -103,6 +113,13 @@ public interface HolderLookup extends HolderGetter { public interface Delegate extends HolderLookup.RegistryLookup { HolderLookup.RegistryLookup parent(); -+ + + // Paper start - add getValueForCopying + @Override + default Optional getValueForCopying(ResourceKey resourceKey) { + return this.parent().getValueForCopying(resourceKey); + } + // Paper end - add getValueForCopying - ++ @Override default ResourceKey> key() { + return this.parent().key(); diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch rename to paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch index 3ea652f70b8c..3b1d12debe1a 100644 --- a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java +index 299d0e1a4304b6e95ccba2424488176ad2669ef7..3c1490ac7c259da04031db2f170e0c0a5f512191 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -33,17 +_,25 @@ +@@ -33,17 +33,25 @@ import org.jspecify.annotations.Nullable; public class MappedRegistry implements WritableRegistry { private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); @@ -31,7 +39,7 @@ @Override public Stream> listTags() { -@@ -114,6 +_,7 @@ +@@ -114,6 +122,7 @@ public class MappedRegistry implements WritableRegistry { this.toId.put(value, newId); this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); @@ -39,7 +47,7 @@ return holder; } } -@@ -275,6 +_,7 @@ +@@ -275,6 +284,7 @@ public class MappedRegistry implements WritableRegistry { return this; } else { this.frozen = true; @@ -47,7 +55,7 @@ this.byValue.forEach((value, holder) -> holder.bindValue((T)value)); List unboundEntries = this.byKey .entrySet() -@@ -522,4 +_,13 @@ +@@ -522,4 +532,13 @@ public class MappedRegistry implements WritableRegistry { Stream> getTags(); } diff --git a/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch b/paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch similarity index 72% rename from paper-server/patches/sources/net/minecraft/core/Rotations.java.patch rename to paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch index 1aeb50910287..fef9d2911a86 100644 --- a/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/Rotations.java b/net/minecraft/core/Rotations.java +index 97a83c78923e707a1c3050842793084e37edf00e..5c3271029b0a09a6f3a4bc39e64f65f9ded46097 100644 --- a/net/minecraft/core/Rotations.java +++ b/net/minecraft/core/Rotations.java -@@ -26,11 +_,22 @@ +@@ -26,11 +26,22 @@ public record Rotations(float x, float y, float z) { output.writeFloat(value.z); } }; diff --git a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch b/paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch rename to paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch index 831d64efa7bb..a4455d3e567e 100644 --- a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/cauldron/CauldronInteractions.java b/net/minecraft/core/cauldron/CauldronInteractions.java +index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef5310da5f 100644 --- a/net/minecraft/core/cauldron/CauldronInteractions.java +++ b/net/minecraft/core/cauldron/CauldronInteractions.java -@@ -46,15 +_,20 @@ +@@ -46,15 +46,20 @@ public class CauldronInteractions { public static void bootStrap() { addDefaultInteractions(EMPTY); @@ -23,7 +31,7 @@ level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -67,7 +_,7 @@ +@@ -67,7 +72,7 @@ public class CauldronInteractions { addDefaultInteractions(WATER); WATER.put( Items.BUCKET, @@ -32,7 +40,7 @@ state, level, pos, -@@ -76,33 +_,43 @@ +@@ -76,33 +81,43 @@ public class CauldronInteractions { itemInHand, new ItemStack(Items.WATER_BUCKET), s -> s.getValue(LayeredCauldronBlock.LEVEL) == 3, @@ -81,7 +89,7 @@ level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -148,14 +_,14 @@ +@@ -148,14 +163,14 @@ public class CauldronInteractions { WATER.put(Items.YELLOW_SHULKER_BOX, CauldronInteractions::shulkerBoxInteraction); LAVA.put( Items.BUCKET, @@ -99,7 +107,7 @@ state, level, pos, -@@ -164,7 +_,7 @@ +@@ -164,7 +179,7 @@ public class CauldronInteractions { itemInHand, new ItemStack(Items.POWDER_SNOW_BUCKET), s -> s.getValue(LayeredCauldronBlock.LEVEL) == 3, @@ -108,7 +116,7 @@ ) ); addDefaultInteractions(POWDER_SNOW); -@@ -187,15 +_,46 @@ +@@ -187,15 +202,46 @@ public class CauldronInteractions { final Predicate canFill, final SoundEvent soundEvent ) { @@ -156,7 +164,7 @@ level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PICKUP, pos); } -@@ -213,12 +_,42 @@ +@@ -213,12 +259,42 @@ public class CauldronInteractions { final BlockState newState, final SoundEvent soundEvent ) { @@ -201,7 +209,7 @@ level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -227,23 +_,23 @@ +@@ -227,23 +303,23 @@ public class CauldronInteractions { } private static InteractionResult fillWaterInteraction( @@ -230,7 +238,7 @@ ) { return (InteractionResult)(isUnderWater(level, pos) ? InteractionResult.CONSUME -@@ -254,22 +_,27 @@ +@@ -254,22 +330,27 @@ public class CauldronInteractions { hand, itemInHand, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), @@ -261,7 +269,7 @@ } return InteractionResult.SUCCESS; -@@ -277,18 +_,23 @@ +@@ -277,18 +358,23 @@ public class CauldronInteractions { } private static InteractionResult bannerInteraction( @@ -287,7 +295,7 @@ } return InteractionResult.SUCCESS; -@@ -296,15 +_,20 @@ +@@ -296,15 +382,20 @@ public class CauldronInteractions { } private static InteractionResult dyedItemIteration( diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch rename to paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch index 1de1c463cb95..9415190e5717 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/component/DataComponentPatch.java b/net/minecraft/core/component/DataComponentPatch.java +index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896526417bc 100644 --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -106,6 +_,11 @@ +@@ -106,6 +106,11 @@ public final class DataComponentPatch { output.writeVarInt(0); output.writeVarInt(0); } else { @@ -12,7 +20,7 @@ int positiveCount = 0; int negativeCount = 0; -@@ -113,7 +_,7 @@ +@@ -113,7 +118,7 @@ public final class DataComponentPatch { patch.map )) { if (entry.getValue().isPresent()) { @@ -21,7 +29,7 @@ } else { negativeCount++; } -@@ -126,6 +_,7 @@ +@@ -126,6 +131,7 @@ public final class DataComponentPatch { patch.map )) { Optional value = entryx.getValue(); @@ -29,7 +37,7 @@ if (value.isPresent()) { DataComponentType type = entryx.getKey(); DataComponentType.STREAM_CODEC.encode(output, type); -@@ -145,7 +_,13 @@ +@@ -145,7 +151,13 @@ public final class DataComponentPatch { } private void encodeComponent(final RegistryFriendlyByteBuf output, final DataComponentType type, final Object value) { @@ -44,11 +52,10 @@ } }; } -@@ -255,6 +_,42 @@ - +@@ -256,6 +268,42 @@ public final class DataComponentPatch { private Builder() { } -+ + + // CraftBukkit start + public void copy(DataComponentPatch orig) { + this.map.putAll(orig.map); @@ -84,6 +91,7 @@ + return this.map.hashCode(); + } + // CraftBukkit end - ++ public DataComponentPatch.Builder set(final DataComponentType type, final T value) { this.map.put(type, Optional.of(value)); + return this; diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index de3f5d8968e0..56e44c58eb0d 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java +index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e7d61139b 100644 --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -87,12 +_,38 @@ +@@ -87,12 +87,38 @@ public interface DispenseItemBehavior { Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos pos = source.pos().relative(direction); ServerLevel serverLevel = source.level(); @@ -41,7 +49,7 @@ } return dispensed; -@@ -110,8 +_,33 @@ +@@ -110,8 +136,33 @@ public interface DispenseItemBehavior { .getEntitiesOfClass(AbstractChestedHorse.class, new AABB(pos), entity -> entity.isAlive() && !entity.hasChest())) { if (abstractChestedHorse.isTamed()) { SlotAccess slot = abstractChestedHorse.getSlot(AbstractHorse.CHEST_SLOT_OFFSET); @@ -77,7 +85,7 @@ this.setSuccess(true); return dispensed; } -@@ -150,8 +_,45 @@ +@@ -150,8 +201,45 @@ public interface DispenseItemBehavior { DispensibleContainerItem bucket = (DispensibleContainerItem)dispensed.getItem(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); Level level = source.level(); @@ -124,7 +132,7 @@ return this.consumeWithRemainder(source, dispensed, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(source, dispensed); -@@ -174,12 +_,19 @@ +@@ -174,12 +262,19 @@ public interface DispenseItemBehavior { BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState blockState = level.getBlockState(target); if (blockState.getBlock() instanceof BucketPickup bucket) { @@ -145,7 +153,7 @@ return this.consumeWithRemainder(source, dispensed, new ItemStack(targetType)); } } else { -@@ -194,15 +_,26 @@ +@@ -194,15 +289,26 @@ public interface DispenseItemBehavior { this.setSuccess(true); Direction facing = source.state().getValue(DispenserBlock.FACING); BlockPos targetPos = source.pos().relative(facing); @@ -173,7 +181,7 @@ level.removeBlock(targetPos, false); } else { this.setSuccess(false); -@@ -224,11 +_,46 @@ +@@ -224,11 +330,46 @@ public interface DispenseItemBehavior { this.setSuccess(true); Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); @@ -220,7 +228,7 @@ return dispensed; } -@@ -242,11 +_,36 @@ +@@ -242,11 +383,36 @@ public interface DispenseItemBehavior { return dispensed; } else { BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); @@ -260,7 +268,7 @@ this.setSuccess(true); return dispensed; } -@@ -260,6 +_,13 @@ +@@ -260,6 +426,13 @@ public interface DispenseItemBehavior { Level level = source.level(); Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos target = source.pos().relative(direction); @@ -274,7 +282,7 @@ if (level.isEmptyBlock(target) && WitherSkullBlock.canSpawnMob(level, target, dispensed)) { level.setBlock( target, -@@ -275,7 +_,7 @@ +@@ -275,7 +448,7 @@ public interface DispenseItemBehavior { dispensed.shrink(1); this.setSuccess(true); } else { @@ -283,7 +291,7 @@ } return dispensed; -@@ -288,6 +_,13 @@ +@@ -288,6 +461,13 @@ public interface DispenseItemBehavior { Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock pumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -297,7 +305,7 @@ if (level.isEmptyBlock(target) && pumpkinBlock.canSpawnGolem(level, target)) { if (!level.isClientSide()) { level.setBlock(target, pumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); -@@ -297,7 +_,7 @@ +@@ -297,7 +477,7 @@ public interface DispenseItemBehavior { dispensed.shrink(1); this.setSuccess(true); } else { @@ -306,7 +314,7 @@ } return dispensed; -@@ -335,6 +_,12 @@ +@@ -335,6 +515,12 @@ public interface DispenseItemBehavior { ServerLevel level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState state = level.getBlockState(target); @@ -319,7 +327,7 @@ if (state.is(BlockTags.BEEHIVES, s -> s.hasProperty(BeehiveBlock.HONEY_LEVEL) && s.getBlock() instanceof BeehiveBlock) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { ((BeehiveBlock)state.getBlock()) -@@ -360,6 +_,13 @@ +@@ -360,6 +546,13 @@ public interface DispenseItemBehavior { this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -333,7 +341,7 @@ RespawnAnchorBlock.charge(null, level, pos, blockState); dispensed.shrink(1); } else { -@@ -383,6 +_,28 @@ +@@ -383,6 +576,28 @@ public interface DispenseItemBehavior { this.setSuccess(false); return dispensed; } else { @@ -362,7 +370,7 @@ for (Armadillo armadillo : armadillos) { if (armadillo.brushOffScute(null, dispensed)) { dispensed.hurtAndBreak(16, level, null, item -> {}); -@@ -403,6 +_,13 @@ +@@ -403,6 +618,13 @@ public interface DispenseItemBehavior { BlockState blockState = level.getBlockState(pos); Optional maybeWaxed = HoneycombItem.getWaxed(blockState); if (maybeWaxed.isPresent()) { @@ -376,7 +384,7 @@ level.setBlockAndUpdate(pos, maybeWaxed.get()); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, pos, 0); dispensed.shrink(1); -@@ -430,6 +_,12 @@ +@@ -430,6 +652,12 @@ public interface DispenseItemBehavior { if (!level.getBlockState(target).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(source, dispensed); } else { diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch index fd59898eb292..2f20671b23f2 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +index 19f2b508e0fb688e41bd9852c8058216473fc177..369b1efd45c2a945715d0be47084961a897e635b 100644 --- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java -@@ -14,10 +_,17 @@ +@@ -14,10 +14,17 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior { @Override protected ItemStack execute(final BlockSource source, final ItemStack dispensed) { @@ -19,7 +27,7 @@ BlockPos pos = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); List entities = source.level().getEntitiesOfClass(LivingEntity.class, new AABB(pos), entity -> entity.canEquipWithDispenser(dispensed)); if (entities.isEmpty()) { -@@ -25,13 +_,39 @@ +@@ -25,13 +32,39 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior { } else { LivingEntity target = entities.getFirst(); EquipmentSlot slot = target.getEquipmentSlotForItem(dispensed); diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch index acc9e4c90c27..446fcf38c57b 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +index 9f0e541626a73190de31b1576577626808ce2dcd..1f5363c71d897400b39edb34bd6e2ad1f9d6a6b1 100644 --- a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -@@ -22,10 +_,36 @@ +@@ -22,10 +22,36 @@ public class ShulkerBoxDispenseBehavior extends OptionalDispenseItemBehavior { BlockPos relativePos = source.pos().relative(facing); Direction clickedFace = source.level().isEmptyBlock(relativePos.below()) ? facing : Direction.UP; diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch index 026114b948d0..47398136c946 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java +index 9950d8d5baa7318ab5383c16d2450039e44458e1..2c633b052bae5437e4f9748df2b588681fd9e049 100644 --- a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java +++ b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java -@@ -18,14 +_,37 @@ +@@ -18,14 +18,37 @@ public class SpawnEggItemBehavior extends DefaultDispenseItemBehavior { if (type == null) { return dispensed; } else { diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch similarity index 72% rename from paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch rename to paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch index 3cd39b15ac0a..1482a3588d07 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/gametest/framework/GameTestServer.java b/net/minecraft/gametest/framework/GameTestServer.java +index 6e368ce9256beb9db4dec8037d9d77dd2b4519c1..17541fbe120bcb21689ac2a08c4c65913ee03cb7 100644 --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -155,6 +_,8 @@ +@@ -155,6 +155,8 @@ public class GameTestServer extends MinecraftServer { final int repeatCount ) { super( @@ -9,7 +17,7 @@ serverThread, levelStorageSource, packRepository, -@@ -173,13 +_,21 @@ +@@ -173,13 +175,21 @@ public class GameTestServer extends MinecraftServer { @Override protected boolean initServer() { @@ -32,7 +40,7 @@ ServerLevel level = this.overworld(); this.testBatches = this.evaluateTestsToRun(level); LOGGER.info("Started game test server"); -@@ -385,6 +_,13 @@ +@@ -385,6 +395,13 @@ public class GameTestServer extends MinecraftServer { return false; } @@ -46,7 +54,7 @@ @Override public boolean isSingleplayerOwner(final NameAndId nameAndId) { return false; -@@ -432,5 +_,16 @@ +@@ -432,5 +449,16 @@ public class GameTestServer extends MinecraftServer { @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch b/paper-server/patches/rejected/net/minecraft/network/Connection.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/network/Connection.java.patch rename to paper-server/patches/rejected/net/minecraft/network/Connection.java.patch index a2aae515dd33..fc296bed14cb 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/rejected/net/minecraft/network/Connection.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java +index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d539fe0f0 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -68,6 +_,11 @@ +@@ -68,6 +68,11 @@ public class Connection extends SimpleChannelInboundHandler> { private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); public Channel channel; public SocketAddress address; @@ -12,7 +20,7 @@ private volatile @Nullable PacketListener disconnectListener; private volatile @Nullable PacketListener packetListener; private @Nullable DisconnectionDetails disconnectionDetails; -@@ -81,6 +_,44 @@ +@@ -81,6 +86,44 @@ public class Connection extends SimpleChannelInboundHandler> { private boolean handlingFault; private volatile @Nullable DisconnectionDetails delayedDisconnect; private @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; @@ -57,7 +65,7 @@ public Connection(final PacketFlow receiving) { this.receiving = receiving; -@@ -91,6 +_,7 @@ +@@ -91,6 +134,7 @@ public class Connection extends SimpleChannelInboundHandler> { super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -65,7 +73,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -102,15 +_,32 @@ +@@ -102,15 +146,32 @@ public class Connection extends SimpleChannelInboundHandler> { } @Override @@ -99,7 +107,7 @@ this.disconnect(Component.translatable("disconnect.timeout")); } else { Component reason = Component.translatable("disconnect.genericReason", "Internal Exception: " + cause); -@@ -122,9 +_,11 @@ +@@ -122,9 +183,11 @@ public class Connection extends SimpleChannelInboundHandler> { details = new DisconnectionDetails(reason); } @@ -112,7 +120,7 @@ Packet packet = (Packet)(this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(reason) : new ClientboundDisconnectPacket(reason)); -@@ -141,6 +_,7 @@ +@@ -141,6 +204,7 @@ public class Connection extends SimpleChannelInboundHandler> { } } } @@ -120,7 +128,7 @@ } @Override -@@ -150,10 +_,60 @@ +@@ -150,10 +214,60 @@ public class Connection extends SimpleChannelInboundHandler> { if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); } else { @@ -181,7 +189,7 @@ } catch (RejectedExecutionException var6) { this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); } catch (ClassCastException var7) { -@@ -344,10 +_,30 @@ +@@ -344,10 +458,30 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -212,7 +220,7 @@ } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -355,7 +_,7 @@ +@@ -355,7 +489,7 @@ public class Connection extends SimpleChannelInboundHandler> { } if (this.channel != null) { @@ -221,7 +229,7 @@ } if (this.tickCount++ % 20 == 0) { -@@ -391,6 +_,7 @@ +@@ -391,6 +525,7 @@ public class Connection extends SimpleChannelInboundHandler> { } public void disconnect(final DisconnectionDetails details) { @@ -229,7 +237,7 @@ if (this.channel == null) { this.delayedDisconnect = details; } -@@ -543,6 +_,14 @@ +@@ -543,6 +678,14 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -244,7 +252,7 @@ public void setupCompression(final int threshold, final boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder compressionDecoder) { -@@ -556,6 +_,7 @@ +@@ -556,6 +699,7 @@ public class Connection extends SimpleChannelInboundHandler> { } else { this.channel.pipeline().addAfter(HandlerNames.PREPENDER, HandlerNames.COMPRESS, new CompressionEncoder(threshold)); } @@ -252,7 +260,7 @@ } else { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder) { this.channel.pipeline().remove(HandlerNames.DECOMPRESS); -@@ -564,6 +_,7 @@ +@@ -564,6 +708,7 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.channel.pipeline().get(HandlerNames.COMPRESS) instanceof CompressionEncoder) { this.channel.pipeline().remove(HandlerNames.COMPRESS); } @@ -260,7 +268,7 @@ } } -@@ -581,6 +_,26 @@ +@@ -581,6 +726,26 @@ public class Connection extends SimpleChannelInboundHandler> { ); disconnectListener.onDisconnect(details); } diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch rename to paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch index d477f5aab15b..17d4ad7064ce 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/network/FriendlyByteBuf.java b/net/minecraft/network/FriendlyByteBuf.java +index 8048aaf25ef496470ba948787ae65d3251ebac9a..351e3b891121c42ceb10e2171e2565877aee519b 100644 --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -70,14 +_,20 @@ +@@ -70,14 +70,20 @@ import org.jspecify.annotations.Nullable; public class FriendlyByteBuf extends ByteBuf { private final ByteBuf source; @@ -21,7 +29,7 @@ this.source = source; } -@@ -106,8 +_,13 @@ +@@ -106,8 +112,13 @@ public class FriendlyByteBuf extends ByteBuf { } public void writeJsonWithCodec(final Codec codec, final T value) { @@ -36,7 +44,7 @@ } public static IntFunction limitValue(final IntFunction original, final int limit) { -@@ -530,7 +_,7 @@ +@@ -530,7 +541,7 @@ public class FriendlyByteBuf extends ByteBuf { try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(output)); diff --git a/paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch b/paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch rename to paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch index 03a36be3541b..f429ff4f9845 100644 --- a/paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch +++ b/paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java +index 82bd316d094e2c1a43938313fab2283035610ef3..197adf43de3618fbd4c72bb2a4736b1cd61fbee7 100644 --- a/net/minecraft/network/PacketProcessor.java +++ b/net/minecraft/network/PacketProcessor.java -@@ -19,15 +_,42 @@ +@@ -19,15 +19,42 @@ public class PacketProcessor implements AutoCloseable { this.runningThread = runningThread; } @@ -45,7 +53,7 @@ } } -@@ -44,8 +_,28 @@ +@@ -44,8 +71,28 @@ public class PacketProcessor implements AutoCloseable { this.closed = true; } @@ -74,7 +82,7 @@ if (this.listener.shouldHandleMessage(this.packet)) { try { this.packet.handle(this.listener); -@@ -59,6 +_,12 @@ +@@ -59,6 +106,12 @@ public class PacketProcessor implements AutoCloseable { } else { PacketProcessor.LOGGER.debug("Ignoring packet due to disconnection: {}", this.packet); } diff --git a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch rename to paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch index bd43bcbeab6e..cd749cae11ae 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch +++ b/paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java +index ece327e088f0abab844b1d9e2f5bfaee8f196828..99a8a8b5cb65bd94d9496ddb6ff11b8a67f3a870 100644 --- a/net/minecraft/network/chat/SignedMessageChain.java +++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -44,14 +_,14 @@ +@@ -44,14 +44,14 @@ public class SignedMessageChain { if (signature == null) { throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.MISSING_PROFILE_KEY); } else if (profilePublicKey.data().hasExpired()) { @@ -17,7 +25,7 @@ } else { SignedMessageChain.this.lastTimeStamp = body.timeStamp(); PlayerChatMessage unpacked = new PlayerChatMessage(link, signature, body, null, FilterMask.PASS_THROUGH); -@@ -84,8 +_,15 @@ +@@ -84,8 +84,15 @@ public class SignedMessageChain { private static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); private static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch b/paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch similarity index 56% rename from paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch rename to paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch index d7fd00d307ee..1abc156e0efa 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch +++ b/paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/network/chat/contents/SelectorContents.java b/net/minecraft/network/chat/contents/SelectorContents.java +index a3cd99bcf2b5c4efb245b3ae96ac3e12bdb987b3..06d0674e3e9460b44a63504c2ea5a3b0a277e973 100644 --- a/net/minecraft/network/chat/contents/SelectorContents.java +++ b/net/minecraft/network/chat/contents/SelectorContents.java -@@ -37,7 +_,7 @@ +@@ -37,7 +37,7 @@ public record SelectorContents(CompilableString selector, Option if (source == null) { return Component.empty(); } else { diff --git a/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch b/paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch rename to paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch index 9e5183c80408..84301abc706f 100644 --- a/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch +++ b/paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/resources/Identifier.java b/net/minecraft/resources/Identifier.java +index 36d1be7a09ff65ecca69240c5b819292d2e070ed..98ea140232e191f7c0fee8da77d02e957865de2a 100644 --- a/net/minecraft/resources/Identifier.java +++ b/net/minecraft/resources/Identifier.java -@@ -22,6 +_,7 @@ +@@ -22,6 +22,7 @@ public final class Identifier implements Comparable { public static final String DEFAULT_NAMESPACE = "minecraft"; public static final String REALMS_NAMESPACE = "realms"; public static final String ALLOWED_NAMESPACE_CHARACTERS = "[a-z0-9_.-]"; @@ -8,7 +16,7 @@ private final String namespace; private final String path; -@@ -30,6 +_,13 @@ +@@ -30,6 +31,13 @@ public final class Identifier implements Comparable { assert isValidPath(path); @@ -22,7 +30,7 @@ this.namespace = namespace; this.path = path; } -@@ -242,7 +_,7 @@ +@@ -242,7 +250,7 @@ public final class Identifier implements Comparable { private static String assertValidNamespace(final String namespace, final String path) { if (!isValidNamespace(namespace)) { @@ -31,7 +39,7 @@ } else { return namespace; } -@@ -258,7 +_,7 @@ +@@ -258,7 +266,7 @@ public final class Identifier implements Comparable { private static String assertValidPath(final String namespace, final String path) { if (!isValidPath(path)) { diff --git a/paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch b/paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch similarity index 56% rename from paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch rename to paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch index 2f7996f97cc3..25be2bf2dfe5 100644 --- a/paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch +++ b/paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/resources/NetworkRegistryLoadTask.java b/net/minecraft/resources/NetworkRegistryLoadTask.java +index 9b51116f171a024b8851f8e4f5aedb11d692dc28..98026e9ea60fe3d12a1206cc4d4b5933f9a29055 100644 --- a/net/minecraft/resources/NetworkRegistryLoadTask.java +++ b/net/minecraft/resources/NetworkRegistryLoadTask.java -@@ -79,7 +_,7 @@ +@@ -79,7 +79,7 @@ public class NetworkRegistryLoadTask extends RegistryLoadTask { } return Util.sequence(elements).thenAcceptAsync(pendingRegistrations -> { diff --git a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch rename to paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch index 89768f069023..c9abcb446638 100644 --- a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/Bootstrap.java b/net/minecraft/server/Bootstrap.java +index c667484cbbd54863537e428c0f792c55de82ee3f..749cca9ae9a1af6a15fdfb2e3f23fd9e40412efc 100644 --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -43,6 +_,7 @@ +@@ -43,6 +43,7 @@ public class Bootstrap { if (!isBootstrapped) { isBootstrapped = true; Instant start = Instant.now(); @@ -8,7 +16,7 @@ if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); } else { -@@ -54,11 +_,85 @@ +@@ -54,11 +55,85 @@ public class Bootstrap { EntitySelectorOptions.bootStrap(); DispenseItemBehavior.bootStrap(); CauldronInteractions.bootStrap(); diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/rejected/net/minecraft/server/Main.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/server/Main.java.patch rename to paper-server/patches/rejected/net/minecraft/server/Main.java.patch index c55839fbe739..e8b62200d775 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/Main.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java +index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee7945062099197c25 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -63,8 +_,10 @@ +@@ -63,8 +63,10 @@ public class Main { private static final Logger LOGGER = LogUtils.getLogger(); @SuppressForbidden(reason = "System.out needed before bootstrap") @@ -12,7 +20,7 @@ OptionParser parser = new OptionParser(); OptionSpec nogui = parser.accepts("nogui"); OptionSpec initSettings = parser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -89,39 +_,95 @@ +@@ -89,39 +91,95 @@ public class Main { parser.printHelpOn(System.err); return; } @@ -116,7 +124,7 @@ LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(universePath.toPath()); LevelStorageSource.LevelStorageAccess access = levelStorageSource.validateAndCreateAccess(levelName); Dynamic levelDataTag; -@@ -149,13 +_,38 @@ +@@ -149,13 +207,38 @@ public class Main { } else { levelDataTag = null; } @@ -156,7 +164,7 @@ WorldStem worldStem; try { -@@ -164,17 +_,31 @@ +@@ -164,17 +247,31 @@ public class Main { executor -> WorldLoader.load( worldLoadConfig, context -> { @@ -190,7 +198,7 @@ } }, WorldStem::new, -@@ -191,6 +_,7 @@ +@@ -191,6 +288,7 @@ public class Main { return; } @@ -198,7 +206,7 @@ RegistryAccess.Frozen registryHolder = worldStem.registries().compositeAccess(); WorldData data = worldStem.worldDataAndGenSettings().data(); boolean recreateRegionFilesValue = options.has(recreateRegionFiles); -@@ -199,22 +_,51 @@ +@@ -199,22 +297,51 @@ public class Main { } access.saveDataTag(data); @@ -253,7 +261,7 @@ Thread shutdownThread = new Thread("Server Shutdown Thread") { @Override public void run() { -@@ -223,12 +_,13 @@ +@@ -223,12 +350,13 @@ public class Main { }; shutdownThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(shutdownThread); @@ -268,7 +276,7 @@ final DedicatedServerSettings settings, final WorldLoader.DataLoadContext context, final Registry datapackDimensions, -@@ -299,7 +_,11 @@ +@@ -299,7 +427,11 @@ public class Main { final RegistryAccess registryAccess, final boolean recreateRegionFiles ) { @@ -281,7 +289,7 @@ try (WorldUpgrader upgrader = new WorldUpgrader(storageSource, fixerUpper, registryAccess, eraseCache, recreateRegionFiles)) { Component lastStatus = null; -@@ -327,5 +_,6 @@ +@@ -327,5 +459,6 @@ public class Main { } } } diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch rename to paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch index 73dcdaec0643..b7cf69f15fed 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f155e986406 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -192,11 +_,13 @@ +@@ -192,11 +192,13 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements CommandSource, ServerInfo, ChunkIOErrorReporter { @@ -15,7 +23,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -219,7 +_,7 @@ +@@ -219,7 +221,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); @@ -24,7 +32,7 @@ private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; private Consumer onMetricsRecordingStopped = results -> this.stopRecordingMetrics(); private Consumer onMetricsRecordingFinished = ignored -> {}; -@@ -227,7 +_,7 @@ +@@ -227,7 +229,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -49,7 +57,7 @@ private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -272,7 +_,7 @@ +@@ -272,7 +275,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 4) { thread.setPriority(8); } -@@ -309,7 +_,124 @@ +@@ -309,7 +313,124 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop blockLookup = this.registries -@@ -362,8 +_,40 @@ +@@ -362,8 +483,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop overworldCustomSpawners = ImmutableList.of( - new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(this.savedDataStorage) -- ); ++ new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(savedDataStorage) // Paper - save to world data + ); - LevelStem overworldData = dimensions.getValue(LevelStem.OVERWORLD); - ServerLevel overworld = new ServerLevel( - this, this.executor, this.storageSource, levelData, Level.OVERWORLD, overworldData, isDebug, biomeZoomSeed, overworldCustomSpawners, true -- ); -- this.levels.put(Level.OVERWORLD, overworld); -+ new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(savedDataStorage) // Paper - save to world data -+ ); + final org.bukkit.generator.ChunkGenerator chunkGenerator = this.server.getGenerator(loading.data().bukkitName()); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(loading.data().bukkitName()); + final org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo( @@ -373,7 +377,8 @@ + levelStem.generator(), + this.registryAccess(), + loading.data().uuid() -+ ); + ); +- this.levels.put(Level.OVERWORLD, overworld); + if (biomeProvider == null && chunkGenerator != null) { + biomeProvider = chunkGenerator.getDefaultBiomeProvider(worldInfo); + } @@ -465,7 +470,7 @@ } } catch (Throwable var20) { CrashReport report = CrashReport.forThrowable(var20, "Exception initializing level"); -@@ -465,25 +_,7 @@ +@@ -465,25 +735,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { TicketStorage savedTickets = level.getDataStorage().get(TicketStorage.TYPE); if (savedTickets != null) { -@@ -565,17 +_,19 @@ +@@ -565,17 +842,19 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop sample = new ObjectArrayList<>(sampleSize); int offset = Mth.nextInt(this.random, 0, players.size() - sampleSize); -@@ -1104,12 +_,46 @@ +@@ -1104,12 +1647,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop playerx.connection.suspendFlushing()); @@ -1144,7 +1149,7 @@ profiler.pop(); } -@@ -1119,10 +_,20 @@ +@@ -1119,10 +1696,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop level + " " + level.dimension().identifier()); profiler.push("tick"); -@@ -1136,7 +_,9 @@ +@@ -1136,7 +1723,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> levelKeys() { return this.levels.keySet(); } -@@ -1230,7 +_,7 @@ +@@ -1230,7 +1842,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop result = CompletableFuture.supplyAsync( () -> packsToEnable.stream() .map(this.packRepository::getPack) -@@ -1534,7 +_,7 @@ +@@ -1534,7 +2179,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { CloseableResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, packsToLoad); @@ -1361,7 +1366,7 @@ return ReloadableServerResources.loadResources( resources, this.registries, -@@ -1554,18 +_,37 @@ +@@ -1554,18 +2199,37 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { @@ -1401,7 +1406,7 @@ }, this); if (this.isSameThread()) { this.managedBlock(result::isDone); -@@ -1580,7 +_,7 @@ +@@ -1580,7 +2244,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop selected, final FeatureFlagSet forcedFeatures, final boolean disableInactive ) { @@ -1419,7 +1424,7 @@ enableForcedFeaturePacks(packRepository, forcedFeatures); DataPackConfig packConfig = getSelectedPacks(packRepository, disableInactive); FeatureFlagSet packRequestedFeatures = packRepository.getRequestedFeatureFlags().join(forcedFeatures); -@@ -1667,7 +_,7 @@ +@@ -1667,7 +2331,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entries = Lists.newArrayList(); @@ -1489,7 +1494,7 @@ gameRules.visitGameRuleTypes(new GameRuleTypeVisitor() { { Objects.requireNonNull(MinecraftServer.this); -@@ -1951,6 +_,17 @@ +@@ -1951,6 +2618,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/BanIpCommands.java b/net/minecraft/server/commands/BanIpCommands.java +index 82f565f54749c630f01a6f50b67d93518170152e..36b858bfe123edc2f1c5c7861dd0e4475ef7a5f1 100644 --- a/net/minecraft/server/commands/BanIpCommands.java +++ b/net/minecraft/server/commands/BanIpCommands.java -@@ -62,7 +_,7 @@ +@@ -62,7 +62,7 @@ public class BanIpCommands { } for (ServerPlayer player : players) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch similarity index 68% rename from paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch index 940dc6091475..adc880aedecc 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/DifficultyCommand.java b/net/minecraft/server/commands/DifficultyCommand.java +index 5f9f6bda3cee7fecd4e6bd1cd82f0b1a71446014..1536602f1c5f3d57ae6396cdea4d4c75a146355b 100644 --- a/net/minecraft/server/commands/DifficultyCommand.java +++ b/net/minecraft/server/commands/DifficultyCommand.java -@@ -31,10 +_,10 @@ +@@ -31,10 +31,10 @@ public class DifficultyCommand { public static int setDifficulty(final CommandSourceStack source, final Difficulty difficulty) throws CommandSyntaxException { MinecraftServer server = source.getServer(); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch index 341dc8af2e35..7b785b6d596a 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/GiveCommand.java b/net/minecraft/server/commands/GiveCommand.java +index db01e15e20585856c04bb3248875d996fbd26548..b6ca9adb5361ebbbb53737806bff7bb3101e5e61 100644 --- a/net/minecraft/server/commands/GiveCommand.java +++ b/net/minecraft/server/commands/GiveCommand.java -@@ -62,7 +_,7 @@ +@@ -62,7 +62,7 @@ public class GiveCommand { ItemStack copyToDrop = prototypeItemStack.copyWithCount(size); boolean added = player.getInventory().add(copyToDrop); if (added && copyToDrop.isEmpty()) { @@ -9,7 +17,7 @@ if (drop != null) { drop.makeFakeItem(); } -@@ -80,7 +_,7 @@ +@@ -80,7 +80,7 @@ public class GiveCommand { ); player.containerMenu.broadcastChanges(); } else { @@ -18,7 +26,7 @@ if (drop != null) { drop.setNoPickUpDelay(); drop.setTarget(player.getUUID()); -@@ -98,7 +_,7 @@ +@@ -98,7 +98,7 @@ public class GiveCommand { ); } else { source.sendSuccess( diff --git a/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch similarity index 59% rename from paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch index 6427c3df646f..a2fadd15a902 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/KickCommand.java b/net/minecraft/server/commands/KickCommand.java +index a4151f86e9a8737a45e472a9bbefb7ac9126beca..0227dd63f67537d769494e122616873c18d35350 100644 --- a/net/minecraft/server/commands/KickCommand.java +++ b/net/minecraft/server/commands/KickCommand.java -@@ -42,7 +_,7 @@ +@@ -42,7 +42,7 @@ public class KickCommand { for (ServerPlayer player : players) { if (!source.getServer().isSingleplayerOwner(player.nameAndId())) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch similarity index 63% rename from paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch index e8f8b0c9f58f..e8a06491ba0b 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/PlaceCommand.java b/net/minecraft/server/commands/PlaceCommand.java +index 4c98316d3ad1cffb3d92c94c6b839870c4a2934d..eab9553e89b781332a1026a037d2c5e9d70bd9b7 100644 --- a/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -298,6 +_,7 @@ +@@ -298,6 +298,7 @@ public class PlaceCommand { if (!start.isValid()) { throw ERROR_STRUCTURE_FAILED.create(); } else { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch similarity index 62% rename from paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch index 75ea71d04e42..b2b036905f38 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/RideCommand.java b/net/minecraft/server/commands/RideCommand.java +index ac31d0ae540f350ed634b5561f7a91631f35d963..682dd4b1c21902273de077ed20c7cdc37eedbc46 100644 --- a/net/minecraft/server/commands/RideCommand.java +++ b/net/minecraft/server/commands/RideCommand.java -@@ -54,7 +_,7 @@ +@@ -54,7 +54,7 @@ public class RideCommand { Entity currentVehicle = target.getVehicle(); if (currentVehicle != null) { throw ERROR_ALREADY_RIDING.create(target.getDisplayName(), currentVehicle.getDisplayName()); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch index ea60bef179a9..3ff0c9a64e95 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/ScheduleCommand.java b/net/minecraft/server/commands/ScheduleCommand.java +index 65e60944e928d96524869aad2ced16abb79b94c7..e49571f7116020da818665083ed59e4b475c056c 100644 --- a/net/minecraft/server/commands/ScheduleCommand.java +++ b/net/minecraft/server/commands/ScheduleCommand.java -@@ -32,7 +_,7 @@ +@@ -32,7 +32,7 @@ public class ScheduleCommand { ); private static final SimpleCommandExceptionType ERROR_MACRO = new SimpleCommandExceptionType(Component.translatableEscape("commands.schedule.macro")); private static final SuggestionProvider SUGGEST_SCHEDULE = (c, p) -> SharedSuggestionProvider.suggest( @@ -9,7 +17,7 @@ ); public static void register(final CommandDispatcher dispatcher) { -@@ -101,7 +_,7 @@ +@@ -101,7 +101,7 @@ public class ScheduleCommand { } else { long tickTime = source.getLevel().getGameTime() + time; Identifier callbackId = callback.getFirst(); @@ -18,7 +26,7 @@ Optional> function = callback.getSecond().left(); if (function.isPresent()) { if (function.get() instanceof MacroFunction) { -@@ -132,7 +_,7 @@ +@@ -132,7 +132,7 @@ public class ScheduleCommand { } private static int remove(final CommandSourceStack source, final String id) throws CommandSyntaxException { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch index 3c6f91342b94..d197b870c4c2 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/SummonCommand.java b/net/minecraft/server/commands/SummonCommand.java +index c827ffa69e3bc8f0119c06c55fcc62fd859e4ac6..fd598900ae35b9fd0509281c24ee9f503b78a4e1 100644 --- a/net/minecraft/server/commands/SummonCommand.java +++ b/net/minecraft/server/commands/SummonCommand.java -@@ -78,7 +_,7 @@ +@@ -78,7 +78,7 @@ public class SummonCommand { BlockPos blockPos = BlockPos.containing(pos); if (!Level.isInSpawnableBounds(blockPos)) { throw INVALID_POSITION.create(); @@ -9,7 +17,7 @@ throw ERROR_FAILED_PEACEFUL.create(); } else { CompoundTag entityTag = nbt.copy(); -@@ -86,6 +_,7 @@ +@@ -86,6 +86,7 @@ public class SummonCommand { ServerLevel level = source.getLevel(); Entity entity = EntityType.loadEntityRecursive(entityTag, level, EntitySpawnReason.COMMAND, e -> { e.snapTo(pos.x, pos.y, pos.z, e.getYRot(), e.getXRot()); @@ -17,7 +25,7 @@ return e; }); if (entity == null) { -@@ -95,7 +_,7 @@ +@@ -95,7 +96,7 @@ public class SummonCommand { mob.finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, null); } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch similarity index 65% rename from paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch index 448fd552bf7f..067790ecdb94 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/TeleportCommand.java b/net/minecraft/server/commands/TeleportCommand.java +index b350255b16c148040104d8e37c4fc80cb07a0b4a..7047a0da56459cda404702cf4dbc69e537683ff8 100644 --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -255,7 +_,7 @@ +@@ -255,7 +255,7 @@ public class TeleportCommand { float relativeOrAbsoluteXRot = relatives.contains(Relative.X_ROT) ? xRot - victim.getXRot() : xRot; float newYRot = Mth.wrapDegrees(relativeOrAbsoluteYRot); float newXRot = Mth.wrapDegrees(relativeOrAbsoluteXRot); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch rename to paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch index 49cecb5c7c9c..1e1d87e67902 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/commands/TimeCommand.java b/net/minecraft/server/commands/TimeCommand.java +index ff3fbbeca288d5133a13449fe92f6d0aeae00a01..5d08e4e8ff1ac4f253d855f7f126110244d74847 100644 --- a/net/minecraft/server/commands/TimeCommand.java +++ b/net/minecraft/server/commands/TimeCommand.java -@@ -119,7 +_,7 @@ +@@ -119,7 +119,7 @@ public class TimeCommand { final CommandSourceStack source, final SuggestionsBuilder builder, final Holder clock ) { return SharedSuggestionProvider.suggestResource( @@ -9,7 +17,7 @@ ); } -@@ -141,7 +_,7 @@ +@@ -141,7 +141,7 @@ public class TimeCommand { } private static int queryTime(final CommandSourceStack source, final Holder clock) { @@ -18,7 +26,7 @@ long totalTicks = clockManager.getTotalTicks(clock); source.sendSuccess(() -> Component.translatable("commands.time.query.absolute", clock.getRegisteredName(), totalTicks), false); return wrapTime(totalTicks); -@@ -151,7 +_,7 @@ +@@ -151,7 +151,7 @@ public class TimeCommand { if (!clock.equals(timeline.value().clock())) { throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); } else { @@ -27,7 +35,7 @@ long currentTicks = timeline.value().getCurrentTicks(clockManager); source.sendSuccess(() -> Component.translatable("commands.time.query.timeline", timeline.getRegisteredName(), currentTicks), false); return wrapTime(currentTicks); -@@ -162,33 +_,53 @@ +@@ -162,33 +162,53 @@ public class TimeCommand { if (!clock.equals(timeline.value().clock())) { throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); } else { @@ -90,7 +98,7 @@ source.sendSuccess( () -> Component.translatable("commands.time.set.time_marker", clock.getRegisteredName(), timeMarkerId.identifier().toString()), true ); -@@ -197,13 +_,13 @@ +@@ -197,13 +217,13 @@ public class TimeCommand { } private static int setPaused(final CommandSourceStack source, final Holder clock, final boolean paused) { diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch rename to paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch index c19fea33bc86..dcf3e6b8aac3 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4193b14a4 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -84,9 +_,9 @@ +@@ -84,9 +84,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface private static final Logger LOGGER = LogUtils.getLogger(); private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRIES = 2; @@ -12,7 +20,7 @@ private @Nullable RconThread rconThread; public DedicatedServerSettings settings; private @Nullable MinecraftServerGui gui; -@@ -99,6 +_,7 @@ +@@ -99,6 +99,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface private long lastHeartbeat; public DedicatedServer( @@ -20,7 +28,7 @@ final Thread serverThread, final LevelStorageSource.LevelStorageAccess levelStorageSource, final PackRepository packRepository, -@@ -109,6 +_,7 @@ +@@ -109,6 +110,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface final Services services ) { super( @@ -28,7 +36,7 @@ serverThread, levelStorageSource, packRepository, -@@ -121,7 +_,8 @@ +@@ -121,7 +123,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface true ); this.settings = settings; @@ -38,7 +46,7 @@ this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); if (settings.getProperties().codeOfConduct) { -@@ -211,6 +_,10 @@ +@@ -211,6 +214,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public void run() { @@ -49,7 +57,7 @@ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String line; -@@ -221,16 +_,41 @@ +@@ -221,16 +228,41 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } catch (IOException var4) { DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); } @@ -92,7 +100,7 @@ LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -241,8 +_,45 @@ +@@ -241,8 +273,45 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.setLocalIp(properties.serverIp); } @@ -139,7 +147,7 @@ InetAddress localAddress = null; if (!this.getLocalIp().isEmpty()) { localAddress = InetAddress.getByName(this.getLocalIp()); -@@ -251,46 +_,72 @@ +@@ -251,46 +320,72 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -220,7 +228,7 @@ } if (properties.enableQuery) { -@@ -303,7 +_,7 @@ +@@ -303,7 +398,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.rconThread = RconThread.create(this); } @@ -229,7 +237,7 @@ Thread watchdog = new Thread(new ServerWatchdog(this)); watchdog.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); watchdog.setName("Server Watchdog"); -@@ -322,6 +_,12 @@ +@@ -322,6 +417,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } } @@ -242,7 +250,7 @@ @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -339,6 +_,7 @@ +@@ -339,6 +440,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public void setUsingWhitelist(final boolean usingWhitelist) { @@ -250,7 +258,7 @@ this.settings.update(p -> p.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -400,7 +_,7 @@ +@@ -400,7 +502,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override protected void forceDifficulty() { @@ -259,7 +267,7 @@ } public int viewDistance() { -@@ -456,11 +_,11 @@ +@@ -456,11 +558,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } if (this.rconThread != null) { @@ -273,7 +281,7 @@ } if (this.jsonRpcServer != null) { -@@ -470,6 +_,9 @@ +@@ -470,6 +572,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface LOGGER.error("Interrupted while stopping the management server", (Throwable)var2); } } @@ -283,7 +291,7 @@ } @Override -@@ -479,12 +_,20 @@ +@@ -479,12 +584,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } public void handleConsoleInput(final String msg, final CommandSourceStack source) { @@ -307,7 +315,7 @@ this.getCommands().performPrefixedCommand(input.source, input.msg); } } -@@ -624,12 +_,15 @@ +@@ -624,12 +737,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public String getMotd() { @@ -325,7 +333,7 @@ } @Override -@@ -655,7 +_,11 @@ +@@ -655,7 +771,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -338,7 +346,7 @@ } @Override -@@ -740,21 +_,60 @@ +@@ -740,21 +860,60 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public String getPluginNames() { @@ -404,7 +412,7 @@ } @Override -@@ -882,4 +_,15 @@ +@@ -882,4 +1041,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch index 40e8aed5c903..5d861dd9e7fb 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ChunkHolder.java b/net/minecraft/server/level/ChunkHolder.java +index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e4a44285c 100644 --- a/net/minecraft/server/level/ChunkHolder.java +++ b/net/minecraft/server/level/ChunkHolder.java -@@ -33,9 +_,9 @@ +@@ -33,9 +33,9 @@ public class ChunkHolder extends GenerationChunkHolder { public static final ChunkResult UNLOADED_LEVEL_CHUNK = ChunkResult.error("Unloaded level chunk"); private static final CompletableFuture> UNLOADED_LEVEL_CHUNK_FUTURE = CompletableFuture.completedFuture(UNLOADED_LEVEL_CHUNK); private final LevelHeightAccessor levelHeightAccessor; @@ -13,7 +21,7 @@ public int oldTicketLevel; private int ticketLevel; private int queueLevel; -@@ -71,6 +_,18 @@ +@@ -71,6 +71,18 @@ public class ChunkHolder extends GenerationChunkHolder { this.changedBlocksPerSection = new ShortSet[levelHeightAccessor.getSectionsCount()]; } @@ -32,7 +40,7 @@ public CompletableFuture> getTickingChunkFuture() { return this.tickingChunkFuture; } -@@ -83,7 +_,7 @@ +@@ -83,7 +95,7 @@ public class ChunkHolder extends GenerationChunkHolder { return this.fullChunkFuture; } @@ -41,7 +49,7 @@ return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); } -@@ -127,6 +_,7 @@ +@@ -127,6 +139,7 @@ public class ChunkHolder extends GenerationChunkHolder { } else { boolean hadChangedSections = this.hasChangedSections; int sectionIndex = this.levelHeightAccessor.getSectionIndex(pos.getY()); @@ -49,7 +57,7 @@ ShortSet changedBlocksInSection = this.changedBlocksPerSection[sectionIndex]; if (changedBlocksInSection == null) { this.hasChangedSections = true; -@@ -270,6 +_,38 @@ +@@ -270,6 +283,38 @@ public class ChunkHolder extends GenerationChunkHolder { scheduler.onFullChunkStatusChange(this.pos, status); } @@ -88,7 +96,7 @@ protected void updateFutures(final ChunkMap scheduler, final Executor mainThreadExecutor) { FullChunkStatus oldFullStatus = ChunkLevel.fullStatus(this.oldTicketLevel); FullChunkStatus newFullStatus = ChunkLevel.fullStatus(this.ticketLevel); -@@ -277,12 +_,28 @@ +@@ -277,12 +322,28 @@ public class ChunkHolder extends GenerationChunkHolder { boolean isAccessible = newFullStatus.isOrAfter(FullChunkStatus.FULL); this.wasAccessibleSinceLastSave |= isAccessible; if (!wasAccessible && isAccessible) { @@ -117,7 +125,7 @@ this.fullChunkFuture.complete(UNLOADED_LEVEL_CHUNK); this.fullChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -292,11 +_,25 @@ +@@ -292,11 +353,25 @@ public class ChunkHolder extends GenerationChunkHolder { if (!wasTicking && isTicking) { this.tickingChunkFuture = scheduler.prepareTickingChunk(this); this.scheduleFullChunkPromotion(scheduler, this.tickingChunkFuture, mainThreadExecutor, FullChunkStatus.BLOCK_TICKING); @@ -144,7 +152,7 @@ this.tickingChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -309,11 +_,24 @@ +@@ -309,11 +384,24 @@ public class ChunkHolder extends GenerationChunkHolder { this.entityTickingChunkFuture = scheduler.prepareEntityTickingChunk(this); this.scheduleFullChunkPromotion(scheduler, this.entityTickingChunkFuture, mainThreadExecutor, FullChunkStatus.ENTITY_TICKING); @@ -170,7 +178,7 @@ this.entityTickingChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -323,6 +_,26 @@ +@@ -323,6 +411,26 @@ public class ChunkHolder extends GenerationChunkHolder { this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch index 922dc8e44673..5ff21858af70 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e299a9c3408 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -152,6 +_,33 @@ +@@ -152,6 +152,33 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -34,7 +42,7 @@ public ChunkMap( final ServerLevel level, final LevelStorageSource.LevelStorageAccess levelStorage, -@@ -179,13 +_,19 @@ +@@ -179,13 +206,19 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.level = level; RegistryAccess registryAccess = level.registryAccess(); long levelSeed = level.getSeed(); @@ -56,7 +64,7 @@ this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor worldgen = new ConsecutiveExecutor(executor, "worldgen"); this.chunkStatusListener = chunkStatusListener; -@@ -212,6 +_,12 @@ +@@ -212,6 +245,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.chunksToEagerlySave.add(chunkPos.pack()); } @@ -69,7 +77,7 @@ protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -348,9 +_,9 @@ +@@ -348,9 +387,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } }); sb.append("Updating:").append(System.lineSeparator()); @@ -81,7 +89,7 @@ CrashReport report = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory category = report.addCategory("Chunk loading"); category.setDetail("Details", details); -@@ -385,6 +_,7 @@ +@@ -385,6 +424,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP chunk.setTicketLevel(level); } else { chunk = new ChunkHolder(ChunkPos.unpack(node), level, this.level, this.lightEngine, this::onLevelChange, this); @@ -89,7 +97,7 @@ } this.updatingChunkMap.put(node, chunk); -@@ -413,8 +_,8 @@ +@@ -413,8 +453,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP protected void saveAllChunks(final boolean flushStorage) { if (flushStorage) { @@ -100,7 +108,7 @@ .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -440,7 +_,7 @@ +@@ -440,7 +480,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.nextChunkSaveTime.clear(); long now = Util.getMillis(); @@ -109,7 +117,7 @@ this.saveChunkIfNeeded(chunk, now); } } -@@ -461,6 +_,7 @@ +@@ -461,6 +501,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -117,7 +125,7 @@ || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -519,7 +_,11 @@ +@@ -519,7 +560,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.scheduleUnload(pos, chunkHolder); } else { ChunkAccess chunk = chunkHolder.getLatestChunk(); @@ -130,7 +138,7 @@ if (chunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -532,7 +_,9 @@ +@@ -532,7 +577,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.lightEngine.updateChunkStatus(chunk.getPos()); this.lightEngine.tryScheduleUpdate(); this.nextChunkSaveTime.remove(chunk.getPos().pack()); @@ -141,7 +149,7 @@ } }, this.unloadQueue::add).whenComplete((ignored, throwable) -> { if (throwable != null) { -@@ -841,7 +_,7 @@ +@@ -841,7 +888,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public int size() { @@ -150,7 +158,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -868,10 +_,10 @@ +@@ -868,10 +915,10 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP .addColumn("fluid_ticks") .build(output); @@ -165,7 +173,7 @@ Optional chunk = Optional.ofNullable(holder.getLatestChunk()); Optional fullChunk = chunk.flatMap( chunkAccess -> chunkAccess instanceof LevelChunk ? Optional.of((LevelChunk)chunkAccess) : Optional.empty() -@@ -920,14 +_,14 @@ +@@ -920,14 +967,14 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP return this.upgradeChunkTag( tag, -1, @@ -183,7 +191,7 @@ generatorIdentifier.ifPresent(identifier -> contextTag.putString("generator", identifier.toString())); return contextTag; } -@@ -939,7 +_,7 @@ +@@ -939,7 +986,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ChunkHolder holder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (holder != null) { LevelChunk chunk = holder.getTickingChunk(); @@ -192,7 +200,7 @@ output.add(chunk); } } -@@ -959,8 +_,14 @@ +@@ -959,8 +1006,14 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) { @@ -208,7 +216,7 @@ } boolean anyPlayerCloseEnoughTo(final BlockPos pos, final int maxDistance) { -@@ -976,8 +_,24 @@ +@@ -976,8 +1029,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) { @@ -234,7 +242,7 @@ return true; } } -@@ -993,7 +_,7 @@ +@@ -993,7 +1062,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP Builder builder = ImmutableList.builder(); for (ServerPlayer player : this.playerMap.getAllPlayers()) { @@ -243,7 +251,7 @@ builder.add(player); } } -@@ -1002,12 +_,12 @@ +@@ -1002,12 +1071,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -258,7 +266,7 @@ } } -@@ -1136,9 +_,19 @@ +@@ -1136,9 +1205,19 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void addEntity(final Entity entity) { @@ -278,7 +286,7 @@ if (range != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1162,6 +_,7 @@ +@@ -1162,6 +1241,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } protected void removeEntity(final Entity entity) { @@ -286,7 +294,7 @@ if (entity instanceof ServerPlayer player) { this.updatePlayerStatus(player, false); -@@ -1329,8 +_,8 @@ +@@ -1329,8 +1409,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { Objects.requireNonNull(ChunkMap.this); super(); @@ -297,7 +305,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1377,6 +_,7 @@ +@@ -1377,6 +1457,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void removePlayer(final ServerPlayer player) { @@ -305,7 +313,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1386,23 +_,47 @@ +@@ -1386,23 +1467,47 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void updatePlayer(final ServerPlayer player) { @@ -356,7 +364,7 @@ } } else { this.removePlayer(player); -@@ -1419,6 +_,7 @@ +@@ -1419,6 +1524,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP for (Entity passenger : this.entity.getIndirectPassengers()) { int passengerRange = passenger.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch index 429613b7c742..0130739821bb 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java +index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59e2ed2f5e 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -66,6 +_,7 @@ +@@ -66,6 +66,7 @@ public class ServerChunkCache extends ChunkSource { private final TicketStorage ticketStorage; private long lastInhabitedUpdate; public boolean spawnEnemies = true; @@ -8,7 +16,7 @@ private static final int CACHE_SIZE = 4; private final long[] lastChunkPos = new long[4]; private final @Nullable ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; -@@ -74,6 +_,13 @@ +@@ -74,6 +75,13 @@ public class ServerChunkCache extends ChunkSource { private final Set chunkHoldersToBroadcast = new ReferenceOpenHashSet<>(); @VisibleForDebug private NaturalSpawner.@Nullable SpawnState lastSpawnState; @@ -22,7 +30,7 @@ public ServerChunkCache( final ServerLevel level, -@@ -87,6 +_,7 @@ +@@ -87,6 +95,7 @@ public class ServerChunkCache extends ChunkSource { final boolean syncWrites, final ChunkStatusUpdateListener chunkStatusListener, final Supplier overworldDataStorage @@ -30,7 +38,7 @@ ) { this.level = level; this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(level); -@@ -99,7 +_,7 @@ +@@ -99,7 +108,7 @@ public class ServerChunkCache extends ChunkSource { LOGGER.error("Failed to create dimension data storage directory", (Throwable)var14); } @@ -39,7 +47,7 @@ this.ticketStorage = this.savedDataStorage.computeIfAbsent(TicketStorage.TYPE); this.chunkMap = new ChunkMap( level, -@@ -122,6 +_,64 @@ +@@ -122,6 +131,64 @@ public class ServerChunkCache extends ChunkSource { this.clearCache(); } @@ -104,7 +112,7 @@ @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -155,7 +_,7 @@ +@@ -155,7 +222,7 @@ public class ServerChunkCache extends ChunkSource { for (int i = 0; i < 4; i++) { if (pos == this.lastChunkPos[i] && targetStatus == this.lastChunkStatus[i]) { ChunkAccess chunkAccess = this.lastChunk[i]; @@ -113,7 +121,7 @@ return chunkAccess; } } -@@ -164,6 +_,7 @@ +@@ -164,6 +231,7 @@ public class ServerChunkCache extends ChunkSource { profiler.incrementCounter("getChunkCacheMiss"); CompletableFuture> serverFuture = this.getChunkFutureMainThread(x, z, targetStatus, loadOrGenerate); this.mainThreadProcessor.managedBlock(serverFuture::isDone); @@ -121,7 +129,7 @@ ChunkResult chunkResult = serverFuture.join(); ChunkAccess chunk = chunkResult.orElse(null); if (chunk == null && loadOrGenerate) { -@@ -236,7 +_,15 @@ +@@ -236,7 +304,15 @@ public class ServerChunkCache extends ChunkSource { long key = pos.pack(); int targetTicketLevel = ChunkLevel.byStatus(targetStatus); ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(key); @@ -138,7 +146,7 @@ this.addTicket(new Ticket(TicketType.UNKNOWN, targetTicketLevel), pos); if (this.chunkAbsent(chunkHolder, targetTicketLevel)) { ProfilerFiller profiler = Profiler.get(); -@@ -256,7 +_,7 @@ +@@ -256,7 +332,7 @@ public class ServerChunkCache extends ChunkSource { } private boolean chunkAbsent(final @Nullable ChunkHolder chunkHolder, final int targetTicketLevel) { @@ -147,7 +155,7 @@ } @Override -@@ -310,17 +_,39 @@ +@@ -310,17 +386,39 @@ public class ServerChunkCache extends ChunkSource { @Override public void close() throws IOException { @@ -189,7 +197,7 @@ this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -344,7 +_,7 @@ +@@ -344,7 +442,7 @@ public class ServerChunkCache extends ChunkSource { if (!this.level.isDebug()) { ProfilerFiller profiler = Profiler.get(); profiler.push("pollingChunks"); @@ -198,7 +206,7 @@ profiler.push("tickingChunks"); this.tickChunks(profiler, timeDiff); profiler.pop(); -@@ -376,12 +_,20 @@ +@@ -376,12 +474,20 @@ public class ServerChunkCache extends ChunkSource { chunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnCookie; @@ -223,7 +231,7 @@ } else { spawningCategories = List.of(); } -@@ -556,7 +_,13 @@ +@@ -556,7 +662,13 @@ public class ServerChunkCache extends ChunkSource { @Override public void setSpawnSettings(final boolean spawnEnemies) { @@ -237,7 +245,7 @@ } public String getChunkDebugData(final ChunkPos pos) { -@@ -624,12 +_,18 @@ +@@ -624,12 +736,18 @@ public class ServerChunkCache extends ChunkSource { @Override protected boolean pollTask() { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch index 0ecdec0eace2..493d935eb6cf 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a0d644721 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -194,7 +_,7 @@ +@@ -194,7 +194,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet private final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -9,7 +17,7 @@ private final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; private EnvironmentAttributeSystem environmentAttributes; -@@ -221,24 +_,199 @@ +@@ -221,24 +221,199 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet private final boolean tickTime; private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -211,7 +219,7 @@ boolean syncWrites = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityStorage = new EntityStorage( -@@ -260,16 +_,17 @@ +@@ -260,16 +435,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet server.getStructureManager(), executor, generator, @@ -232,7 +240,7 @@ } this.raids = this.getDataStorage().computeIfAbsent(Raids.TYPE); -@@ -277,14 +_,13 @@ +@@ -277,14 +453,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet levelData.setGameType(server.getDefaultGameType()); } @@ -248,7 +256,7 @@ generator, this.chunkSource.randomState(), this, -@@ -300,10 +_,18 @@ +@@ -300,10 +475,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); @@ -256,7 +264,6 @@ + this.waypointManager = new ServerWaypointManager(this); // Paper - optimize ServerWaypointManager with locator bar disabled this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); this.updateSkyBrightness(); -- } + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + } + @@ -264,12 +271,12 @@ + @Override + public boolean hasChunk(int chunkX, int chunkZ) { + return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null; -+ } + } + // Paper end @Deprecated @VisibleForTesting -@@ -322,7 +_,7 @@ +@@ -322,7 +505,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public ServerClockManager clockManager() { @@ -278,7 +285,7 @@ } @Override -@@ -354,11 +_,24 @@ +@@ -354,11 +537,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet int percentage = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(percentage) && this.sleepStatus.areEnoughDeepSleeping(percentage, this.players)) { Optional> defaultClock = this.dimensionType().defaultClock(); @@ -305,7 +312,7 @@ if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -373,9 +_,9 @@ +@@ -373,9 +569,9 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (!this.isDebug() && runs) { long tick = this.getGameTime(); profiler.push("blockTicks"); @@ -317,7 +324,7 @@ profiler.pop(); } -@@ -393,7 +_,7 @@ +@@ -393,7 +589,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.handlingTick = false; profiler.pop(); @@ -326,7 +333,7 @@ if (isActive) { this.resetEmptyTime(); } -@@ -437,9 +_,12 @@ +@@ -437,9 +633,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } ); @@ -339,7 +346,7 @@ } profiler.push("entityManagement"); -@@ -468,7 +_,7 @@ +@@ -468,7 +667,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet long time = this.levelData.getGameTime() + 1L; this.serverLevelData.setGameTime(time); Profiler.get().push("scheduledFunctions"); @@ -348,7 +355,7 @@ Profiler.get().pop(); } } -@@ -491,11 +_,13 @@ +@@ -491,11 +690,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet ProfilerFiller profiler = Profiler.get(); profiler.push("iceandsnow"); @@ -362,7 +369,7 @@ profiler.popPush("tickBlocks"); if (tickSpeed > 0) { -@@ -536,12 +_,12 @@ +@@ -536,12 +737,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet int minZ = chunkPos.getMinBlockZ(); ProfilerFiller profiler = Profiler.get(); profiler.push("thunder"); @@ -377,7 +384,7 @@ && !this.getBlockState(pos.below()).is(BlockTags.LIGHTNING_RODS); if (isTrap) { SkeletonHorse horse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -549,7 +_,7 @@ +@@ -549,7 +750,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet horse.setTrap(true); horse.setAge(0); horse.setPos(pos.getX(), pos.getY(), pos.getZ()); @@ -386,7 +393,7 @@ } } -@@ -557,7 +_,7 @@ +@@ -557,7 +758,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (bolt != null) { bolt.snapTo(Vec3.atBottomCenterOf(pos)); bolt.setVisualOnly(isTrap); @@ -395,7 +402,7 @@ } } } -@@ -571,7 +_,7 @@ +@@ -571,7 +772,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet BlockPos belowPos = topPos.below(); Biome biome = this.getBiome(topPos).value(); if (biome.shouldFreeze(this, belowPos)) { @@ -404,7 +411,7 @@ } if (this.isRaining()) { -@@ -583,10 +_,10 @@ +@@ -583,10 +784,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (currentLayers < Math.min(maxHeight, 8)) { BlockState newState = state.setValue(SnowLayerBlock.LAYERS, currentLayers + 1); Block.pushEntitiesUp(state, newState, this, topPos); @@ -417,7 +424,7 @@ } } -@@ -611,16 +_,24 @@ +@@ -611,16 +812,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } protected BlockPos findLightningTargetAround(final BlockPos pos) { @@ -443,7 +450,7 @@ if (center.getY() == this.getMinY() - 1) { center = center.above(2); } -@@ -739,8 +_,8 @@ +@@ -739,8 +948,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet weatherData.setThunderTime(thunderTime); weatherData.setRainTime(rainTime); weatherData.setClearWeatherTime(clearWeatherTime); @@ -454,7 +461,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -761,6 +_,7 @@ +@@ -761,6 +970,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -462,7 +469,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -783,15 +_,48 @@ +@@ -783,15 +993,48 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -515,7 +522,7 @@ } public void resetEmptyTime() { -@@ -813,18 +_,46 @@ +@@ -813,18 +1056,46 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } @@ -562,7 +569,7 @@ } private void tickPassenger(final Entity vehicle, final Entity entity) { -@@ -833,10 +_,12 @@ +@@ -833,10 +1104,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } else if (entity instanceof Player || this.entityTickList.contains(entity)) { entity.setOldPosAndRot(); entity.tickCount++; @@ -575,7 +582,7 @@ profiler.pop(); for (Entity passenger : entity.getPassengers()) { -@@ -867,6 +_,7 @@ +@@ -867,6 +1140,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public void save(final @Nullable ProgressListener progressListener, final boolean flush, final boolean noSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!noSave) { @@ -583,7 +590,7 @@ if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -887,6 +_,7 @@ +@@ -887,6 +1161,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet private void saveLevelData(final boolean sync) { SavedDataStorage savedDataStorage = this.getChunkSource().getDataStorage(); @@ -591,7 +598,7 @@ if (sync) { savedDataStorage.saveAndJoin(); } else { -@@ -949,18 +_,40 @@ +@@ -949,18 +1224,40 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public boolean addFreshEntity(final Entity entity) { @@ -635,7 +642,7 @@ } } -@@ -983,42 +_,121 @@ +@@ -983,42 +1280,121 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.entityManager.addNewEntity(player); } @@ -710,15 +717,14 @@ public void removePlayerImmediately(final ServerPlayer player, final Entity.RemovalReason reason) { - player.remove(reason); -- } + player.remove(reason, null); // CraftBukkit - add Bukkit remove cause + } + + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { + return this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.UNKNOWN); -+ } -+ + } + + public boolean strikeLightning(Entity entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause cause) { + org.bukkit.event.weather.LightningStrikeEvent lightning = org.bukkit.craftbukkit.event.CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + @@ -729,7 +735,7 @@ + return this.addFreshEntity(entitylightning); + } + // CraftBukkit end - ++ @Override public void destroyBlockProgress(final int id, final BlockPos blockPos, final int progress) { + // CraftBukkit start @@ -762,7 +768,7 @@ player.connection.send(new ClientboundBlockDestructionPacket(id, blockPos, progress)); } } -@@ -1106,7 +_,7 @@ +@@ -1106,7 +1482,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet pos.getX(), pos.getY(), pos.getZ(), @@ -771,7 +777,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1118,6 +_,11 @@ +@@ -1118,6 +1494,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public void gameEvent(final Holder gameEvent, final Vec3 position, final GameEvent.Context context) { @@ -783,7 +789,7 @@ this.gameEventDispatcher.post(gameEvent, position, context); } -@@ -1130,17 +_,28 @@ +@@ -1130,17 +1511,28 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -812,7 +818,7 @@ try { this.isUpdatingNavigations = true; -@@ -1152,15 +_,23 @@ +@@ -1152,15 +1544,23 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.isUpdatingNavigations = false; } } @@ -836,7 +842,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, null, orientation); } -@@ -1214,6 +_,44 @@ +@@ -1214,6 +1614,44 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet final WeightedList blockParticles, final Holder explosionSound ) { @@ -881,7 +887,7 @@ Explosion.BlockInteraction blockInteraction = switch (interactionType) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); -@@ -1222,10 +_,17 @@ +@@ -1222,10 +1660,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -899,7 +905,7 @@ ParticleOptions explosionParticle = explosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer player : this.players) { -@@ -1234,6 +_,8 @@ +@@ -1234,6 +1679,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet player.connection.send(new ClientboundExplodePacket(center, r, blockCount, playerKnockback, explosionParticle, explosionSound, blockParticles)); } } @@ -908,7 +914,7 @@ } private Explosion.BlockInteraction getDestroyType(final GameRule gameRule) { -@@ -1311,7 +_,7 @@ +@@ -1311,7 +1758,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet final double zDist, final double speed ) { @@ -917,7 +923,7 @@ } public int sendParticles( -@@ -1327,13 +_,49 @@ +@@ -1327,13 +1774,49 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet final double zDist, final double speed ) { @@ -969,7 +975,7 @@ if (this.sendParticles(player, overrideLimiter, x, y, z, packet)) { result++; } -@@ -1421,7 +_,7 @@ +@@ -1421,7 +1904,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public @Nullable BlockPos findNearestMapStructure( final TagKey structureTag, final BlockPos origin, final int maxSearchRadius, final boolean createReference ) { @@ -978,7 +984,7 @@ return null; } else { Optional> tag = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1479,10 +_,36 @@ +@@ -1479,10 +1962,36 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public @Nullable MapItemSavedData getMapData(final MapId id) { @@ -1016,7 +1022,7 @@ this.getServer().getDataStorage().set(MapItemSavedData.type(id), data); } -@@ -1492,7 +_,20 @@ +@@ -1492,7 +2001,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public void setRespawnData(final LevelData.RespawnData respawnData) { @@ -1038,7 +1044,7 @@ } @Override -@@ -1529,6 +_,11 @@ +@@ -1529,6 +2051,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.debugSynchronizers.dropPoi(immutable); })); newType.ifPresent(poiType -> this.getServer().execute(() -> { @@ -1050,7 +1056,7 @@ PoiRecord record = this.getPoiManager().add(immutable, (Holder)poiType); if (record != null) { this.debugSynchronizers.registerPoi(record); -@@ -1677,12 +_,12 @@ +@@ -1677,12 +2204,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public boolean isFlat() { @@ -1065,7 +1071,7 @@ } public @Nullable EnderDragonFight getDragonFight() { -@@ -1690,7 +_,7 @@ +@@ -1690,7 +2217,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public WeatherData getWeatherData() { @@ -1074,7 +1080,7 @@ } @Override -@@ -1737,6 +_,7 @@ +@@ -1737,6 +2264,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public LevelEntityGetter getEntities() { @@ -1082,12 +1088,11 @@ return this.entityManager.getEntityGetter(); } -@@ -1841,8 +_,30 @@ +@@ -1841,8 +2369,30 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public GameRules getGameRules() { - return this.server.getGameRules(); -- } + return this.gameRules; // Paper - per-level GameRules + } + @@ -1110,12 +1115,12 @@ + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlags(), 512); + } -+ } + } + // Paper end - notify observers even if grow failed @Override public CrashReportCategory fillReportDetails(final CrashReport report) { -@@ -1905,6 +_,7 @@ +@@ -1905,6 +2455,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (entity instanceof WaypointTransmitter waypoint && waypoint.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypoint); } @@ -1123,7 +1128,7 @@ } @Override -@@ -1918,17 +_,24 @@ +@@ -1918,17 +2469,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public void onTickingStart(final Entity entity) { @@ -1149,7 +1154,7 @@ if (entity instanceof ServerPlayer player) { ServerLevel.this.players.add(player); if (player.isReceivingWaypoints()) { -@@ -1943,7 +_,7 @@ +@@ -1943,7 +2501,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } if (entity instanceof Mob mob) { @@ -1158,7 +1163,7 @@ String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1960,10 +_,52 @@ +@@ -1960,10 +2518,52 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1211,7 +1216,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer player) { ServerLevel.this.players.remove(player); -@@ -1972,7 +_,7 @@ +@@ -1972,7 +2572,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } if (entity instanceof Mob mob) { @@ -1220,7 +1225,7 @@ String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1990,6 +_,15 @@ +@@ -1990,6 +2590,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1236,7 +1241,7 @@ } @Override -@@ -1997,4 +_,24 @@ +@@ -1997,4 +2606,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch index 353b83ed6014..b1837fc8eed2 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -253,7 +_,8 @@ +@@ -253,7 +253,8 @@ public class ServerPlayer extends Player { private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +18,7 @@ private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -308,6 +_,13 @@ +@@ -308,6 +309,13 @@ public class ServerPlayer extends Player { } } @@ -24,7 +32,7 @@ @Override public void sendSlotChange(final AbstractContainerMenu container, final int slotIndex, final ItemStack itemStack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slotIndex, itemStack)); -@@ -347,6 +_,32 @@ +@@ -347,6 +355,32 @@ public class ServerPlayer extends Player { } } @@ -57,7 +65,7 @@ @Override public void dataChanged(final AbstractContainerMenu container, final int id, final int value) { } -@@ -377,10 +_,43 @@ +@@ -377,10 +411,43 @@ public class ServerPlayer extends Player { public void sendSystemMessage(final Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +109,7 @@ public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) { super(level, gameProfile); -@@ -391,8 +_,14 @@ +@@ -391,8 +458,14 @@ public class ServerPlayer extends Player { this.recipeBook = new ServerRecipeBook((id, output) -> server.getRecipeManager().listDisplaysForRecipe(id, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +125,7 @@ } @Override -@@ -410,6 +_,7 @@ +@@ -410,6 +483,7 @@ public class ServerPlayer extends Player { this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(p -> this.recipeBook.loadUntrusted(p, id -> this.server.getRecipeManager().byKey(id).isPresent())); @@ -125,7 +133,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -417,6 +_,19 @@ +@@ -417,6 +491,19 @@ public class ServerPlayer extends Player { this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +153,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -444,12 +_,24 @@ +@@ -444,12 +531,24 @@ public class ServerPlayer extends Player { if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +179,7 @@ ValueOutput vehicleWrapper = playerOutput.child("RootVehicle"); vehicleWrapper.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(vehicleWrapper.child("Entity")); -@@ -461,7 +_,7 @@ +@@ -461,7 +560,7 @@ public class ServerPlayer extends Player { if (!rootTag.isEmpty()) { ServerLevel serverLevel = this.level(); Entity vehicle = EntityType.loadEntityRecursive( @@ -180,7 +188,7 @@ ); if (vehicle != null) { UUID attachTo = rootTag.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -478,10 +_,10 @@ +@@ -478,10 +577,10 @@ public class ServerPlayer extends Player { if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +201,7 @@ } } } -@@ -493,6 +_,7 @@ +@@ -493,6 +592,7 @@ public class ServerPlayer extends Player { ValueOutput.ValueOutputList pearlsOutput = playerOutput.childrenList("ender_pearls"); for (ThrownEnderpearl enderPearl : this.enderPearls) { @@ -201,7 +209,7 @@ if (enderPearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -527,6 +_,16 @@ +@@ -527,6 +627,16 @@ public class ServerPlayer extends Player { } } @@ -218,7 +226,7 @@ public void setExperiencePoints(final int amount) { float limit = this.getXpNeededForNextLevel(); float max = (limit - 1.0F) / limit; -@@ -591,6 +_,11 @@ +@@ -591,6 +701,11 @@ public class ServerPlayer extends Player { @Override public void tick() { @@ -230,7 +238,7 @@ this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -598,9 +_,18 @@ +@@ -598,9 +713,18 @@ public class ServerPlayer extends Player { this.invulnerableTime--; } @@ -252,7 +260,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -659,10 +_,10 @@ +@@ -659,10 +783,10 @@ public class ServerPlayer extends Player { public void doTick() { try { @@ -265,7 +273,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -692,7 +_,7 @@ +@@ -692,7 +816,7 @@ public class ServerPlayer extends Player { if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +282,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -723,6 +_,12 @@ +@@ -723,6 +847,12 @@ public class ServerPlayer extends Player { this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +295,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -736,6 +_,21 @@ +@@ -736,6 +866,21 @@ public class ServerPlayer extends Player { if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +317,7 @@ } catch (Throwable var4) { CrashReport report = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory category = report.addCategory("Player being ticked"); -@@ -760,7 +_,7 @@ +@@ -760,7 +905,7 @@ public class ServerPlayer extends Player { if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +326,7 @@ } float saturation = this.foodData.getSaturationLevel(); -@@ -780,6 +_,7 @@ +@@ -780,6 +925,7 @@ public class ServerPlayer extends Player { this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +334,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -824,33 +_,62 @@ +@@ -824,33 +970,62 @@ public class ServerPlayer extends Player { @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -396,22 +404,20 @@ } @Override -@@ -887,15 +_,36 @@ +@@ -887,15 +1062,36 @@ public class ServerPlayer extends Player { } private void updateScoreForCriteria(final ObjectiveCriteria criteria, final int value) { - this.level().getScoreboard().forAllObjectives(criteria, this, score -> score.set(value)); -- } -- ++ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(value)); // CraftBukkit - Use our scores instead + } + - @Override - public void die(final DamageSource source) { - this.gameEvent(GameEvent.ENTITY_DIE); - boolean showDeathMessage = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); - if (showDeathMessage) { - Component deathMessage = this.getCombatTracker().getDeathMessage(); -+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(value)); // CraftBukkit - Use our scores instead -+ } -+ + // Paper start - PlayerDeathEvent#getItemsToKeep + private static boolean shouldKeepDeathEventItem( + final org.bukkit.event.entity.PlayerDeathEvent event, @@ -442,7 +448,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -912,6 +_,64 @@ +@@ -912,6 +1108,64 @@ public class ServerPlayer extends Player { } ) ); @@ -507,7 +513,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -921,7 +_,7 @@ +@@ -921,7 +1175,7 @@ public class ServerPlayer extends Player { this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -516,7 +522,7 @@ } this.removeEntitiesOnShoulder(); -@@ -929,11 +_,35 @@ +@@ -929,11 +1183,35 @@ public class ServerPlayer extends Player { this.tellNeutralMobsThatIDied(); } @@ -555,7 +561,7 @@ LivingEntity killer = this.getKillCredit(); if (killer != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killer.getType())); -@@ -967,10 +_,10 @@ +@@ -967,10 +1245,10 @@ public class ServerPlayer extends Player { if (victim != this) { super.awardKillScore(victim, killingBlow); Scoreboard scoreboard = this.level().getScoreboard(); @@ -568,7 +574,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -983,11 +_,11 @@ +@@ -983,11 +1261,11 @@ public class ServerPlayer extends Player { private void handleTeamKill(final ScoreHolder source, final ScoreHolder target, final ObjectiveCriteria[] criteriaByTeam) { Scoreboard scoreboard = this.level().getScoreboard(); @@ -582,7 +588,7 @@ } } } -@@ -998,9 +_,20 @@ +@@ -998,9 +1276,20 @@ public class ServerPlayer extends Player { return false; } else { Entity entity = source.getEntity(); @@ -606,13 +612,12 @@ } } -@@ -1013,24 +_,98 @@ +@@ -1013,24 +1302,98 @@ public class ServerPlayer extends Player { return this.level().isPvpAllowed(); } - public TeleportTransition findRespawnPositionAndUseSpawnBlock( - final boolean consumeSpawnBlock, final TeleportTransition.PostTeleportTransition postTeleportTransition -- ) { + // Paper start + public record RespawnResult(TeleportTransition transition, boolean isBedSpawn, boolean isAnchorSpawn) { + } @@ -628,7 +633,7 @@ + public @Nullable RespawnResult findRespawnPositionAndUseSpawnBlock0( + final boolean consumeSpawnBlock, final TeleportTransition.PostTeleportTransition postTeleportTransition, + final org.bukkit.event.player.PlayerRespawnEvent.RespawnReason respawnReason -+ ) { + ) { + TeleportTransition teleportTransition; + boolean isBedSpawn = false; + boolean isAnchorSpawn = false; @@ -655,10 +660,9 @@ } } else { - return TeleportTransition.createDefault(this, postTeleportTransition); -- } + // CraftBukkit start + teleportTransition = TeleportTransition.createDefault(this, postTeleportTransition); -+ } + } + + org.bukkit.entity.Player respawnPlayer = this.getBukkitEntity(); + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit( @@ -712,7 +716,7 @@ } public boolean isReceivingWaypoints() { -@@ -1064,15 +_,17 @@ +@@ -1064,15 +1427,17 @@ public class ServerPlayer extends Player { if (block instanceof RespawnAnchorBlock && (forced || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, pos) ) { @@ -733,7 +737,7 @@ } else if (!forced) { return Optional.empty(); } else { -@@ -1080,7 +_,7 @@ +@@ -1080,7 +1445,7 @@ public class ServerPlayer extends Player { BlockState topState = level.getBlockState(pos.above()); boolean freeTop = topState.getBlock().isPossibleToRespawnInThis(topState); return freeBottom && freeTop @@ -742,7 +746,7 @@ : Optional.empty(); } } -@@ -1096,7 +_,8 @@ +@@ -1096,7 +1461,8 @@ public class ServerPlayer extends Player { } @Override @@ -752,7 +756,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1107,12 +_,46 @@ +@@ -1107,12 +1473,46 @@ public class ServerPlayer extends Player { ServerLevel newLevel = transition.newLevel(); ServerLevel oldLevel = this.level(); ResourceKey lastDimension = oldLevel.dimension(); @@ -800,7 +804,7 @@ this.connection.resetPosition(); transition.postTeleportTransition().onTransition(this); return this; -@@ -1123,18 +_,19 @@ +@@ -1123,18 +1523,19 @@ public class ServerPlayer extends Player { this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -822,7 +826,7 @@ this.connection.resetPosition(); newLevel.addDuringTeleport(this); profiler.pop(); -@@ -1149,6 +_,15 @@ +@@ -1149,6 +1550,15 @@ public class ServerPlayer extends Player { this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(transition, oldLevel); @@ -838,7 +842,7 @@ return this; } } -@@ -1163,12 +_,26 @@ +@@ -1163,12 +1573,26 @@ public class ServerPlayer extends Player { public void triggerDimensionChangeTriggers(final ServerLevel oldLevel) { ResourceKey oldKey = oldLevel.dimension(); ResourceKey newKey = this.level().dimension(); @@ -868,7 +872,7 @@ this.enteredNetherPosition = null; } } -@@ -1184,10 +_,12 @@ +@@ -1184,10 +1608,12 @@ public class ServerPlayer extends Player { this.containerMenu.broadcastChanges(); } @@ -885,7 +889,7 @@ BedRule rule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); boolean canSleep = rule.canSleep(this.level()); boolean canSetSpawn = rule.canSetSpawn(this.level()); -@@ -1200,7 +_,7 @@ +@@ -1200,7 +1626,7 @@ public class ServerPlayer extends Player { } else { if (canSetSpawn) { this.setRespawnPosition( @@ -894,7 +898,7 @@ ); } -@@ -1229,7 +_,37 @@ +@@ -1229,7 +1655,37 @@ public class ServerPlayer extends Player { } } @@ -933,7 +937,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1239,10 +_,7 @@ +@@ -1239,10 +1695,7 @@ public class ServerPlayer extends Player { this.level().updateSleepingPlayerList(); return result; @@ -944,7 +948,7 @@ } } -@@ -1270,19 +_,30 @@ +@@ -1270,19 +1723,30 @@ public class ServerPlayer extends Player { @Override public void stopSleepInBed(final boolean forcefulWakeUp, final boolean updateLevelList) { @@ -977,7 +981,7 @@ } @Override -@@ -1330,8 +_,9 @@ +@@ -1330,8 +1794,9 @@ public class ServerPlayer extends Player { this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -988,7 +992,7 @@ } @Override -@@ -1339,12 +_,39 @@ +@@ -1339,12 +1804,39 @@ public class ServerPlayer extends Player { if (provider == null) { return OptionalInt.empty(); } else { @@ -1029,7 +1033,7 @@ if (menu == null) { if (this.isSpectator()) { this.sendOverlayMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED)); -@@ -1352,9 +_,13 @@ +@@ -1352,9 +1844,13 @@ public class ServerPlayer extends Player { return OptionalInt.empty(); } else { @@ -1045,7 +1049,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1374,27 +_,49 @@ +@@ -1374,27 +1870,49 @@ public class ServerPlayer extends Player { @Override public void openHorseInventory(final AbstractHorse horse, final Container container) { @@ -1100,7 +1104,7 @@ this.initMenu(this.containerMenu); } -@@ -1416,10 +_,30 @@ +@@ -1416,10 +1934,30 @@ public class ServerPlayer extends Player { @Override public void closeContainer() { @@ -1131,7 +1135,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1442,19 +_,19 @@ +@@ -1442,19 +1980,19 @@ public class ServerPlayer extends Player { int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (distance > 0) { this.awardStat(Stats.SWIM_ONE_CM, distance); @@ -1154,7 +1158,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1465,13 +_,13 @@ +@@ -1465,13 +2003,13 @@ public class ServerPlayer extends Player { if (horizontalDistance > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, horizontalDistance); @@ -1171,7 +1175,7 @@ } } } else if (this.isFallFlying()) { -@@ -1515,13 +_,13 @@ +@@ -1515,13 +2053,13 @@ public class ServerPlayer extends Player { @Override public void awardStat(final Stat stat, final int count) { this.stats.increment(this, stat, count); @@ -1187,7 +1191,7 @@ } @Override -@@ -1552,9 +_,9 @@ +@@ -1552,9 +2090,9 @@ public class ServerPlayer extends Player { super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1199,7 +1203,7 @@ } } -@@ -1569,6 +_,13 @@ +@@ -1569,6 +2107,13 @@ public class ServerPlayer extends Player { public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1213,7 +1217,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1580,6 +_,7 @@ +@@ -1580,6 +2125,7 @@ public class ServerPlayer extends Player { public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1221,7 +1225,7 @@ } @Override -@@ -1609,18 +_,18 @@ +@@ -1609,18 +2155,18 @@ public class ServerPlayer extends Player { this.onUpdateAbilities(); this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); if (restoreAll) { @@ -1243,7 +1247,7 @@ if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || oldPlayer.isSpectator()) { this.transferInventoryXpAndScore(oldPlayer); } -@@ -1632,7 +_,7 @@ +@@ -1632,7 +2178,7 @@ public class ServerPlayer extends Player { this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1252,7 +1256,7 @@ this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1684,9 +_,22 @@ +@@ -1684,9 +2230,22 @@ public class ServerPlayer extends Player { CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1276,7 +1280,7 @@ } @Override -@@ -1704,6 +_,7 @@ +@@ -1704,6 +2263,7 @@ public class ServerPlayer extends Player { final float newYRot, final float newXRot, final boolean resetCamera @@ -1284,7 +1288,7 @@ ) { if (this.isSleeping()) { this.stopSleepInBed(true, true); -@@ -1713,7 +_,7 @@ +@@ -1713,7 +2273,7 @@ public class ServerPlayer extends Player { this.setCamera(this); } @@ -1293,7 +1297,7 @@ if (success) { this.setYHeadRot(relatives.contains(Relative.Y_ROT) ? this.getYHeadRot() + newYRot : newYRot); this.connection.resetFlyingTicks(); -@@ -1752,9 +_,18 @@ +@@ -1752,9 +2312,18 @@ public class ServerPlayer extends Player { } public boolean setGameMode(final GameType mode) { @@ -1314,7 +1318,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, mode.getId())); if (mode == GameType.SPECTATOR) { -@@ -1771,7 +_,7 @@ +@@ -1771,7 +2340,7 @@ public class ServerPlayer extends Player { this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1323,7 +1327,7 @@ } } -@@ -1840,8 +_,13 @@ +@@ -1840,8 +2409,13 @@ public class ServerPlayer extends Player { } public void sendChatMessage(final OutgoingChatMessage message, final boolean filtered, final ChatType.Bound chatType) { @@ -1338,7 +1342,7 @@ } } -@@ -1852,7 +_,42 @@ +@@ -1852,7 +2426,42 @@ public class ServerPlayer extends Player { } public void updateOptions(final ClientInformation information) { @@ -1381,7 +1385,7 @@ this.requestedViewDistance = information.viewDistance(); this.chatVisibility = information.chatVisibility(); this.canChatColor = information.chatColors(); -@@ -1937,8 +_,23 @@ +@@ -1937,8 +2546,23 @@ public class ServerPlayer extends Player { Entity oldCamera = this.getCamera(); this.camera = (Entity)(newCamera == null ? this : newCamera); if (oldCamera != this.camera) { @@ -1406,7 +1410,7 @@ } if (newCamera != null) { -@@ -1962,11 +_,11 @@ +@@ -1962,11 +2586,11 @@ public class ServerPlayer extends Player { } public @Nullable Component getTabListDisplayName() { @@ -1420,7 +1424,7 @@ } @Override -@@ -1996,11 +_,60 @@ +@@ -1996,11 +2620,60 @@ public class ServerPlayer extends Player { } public void setRespawnPosition(final ServerPlayer.@Nullable RespawnConfig respawnConfig, final boolean showMessage) { @@ -1483,7 +1487,7 @@ } public SectionPos getLastSectionPos() { -@@ -2020,16 +_,23 @@ +@@ -2020,16 +2693,23 @@ public class ServerPlayer extends Player { } @Override @@ -1512,7 +1516,7 @@ return entity; } -@@ -2081,7 +_,7 @@ +@@ -2081,7 +2761,7 @@ public class ServerPlayer extends Player { super.updateUsingItem(useItem); } @@ -1521,7 +1525,7 @@ Inventory inventory = this.getInventory(); ItemStack removed = inventory.removeFromSelected(all); this.containerMenu -@@ -2091,7 +_,7 @@ +@@ -2091,7 +2771,7 @@ public class ServerPlayer extends Player { this.stopUsingItem(); } @@ -1530,7 +1534,7 @@ } @Override -@@ -2154,9 +_,9 @@ +@@ -2154,9 +2834,9 @@ public class ServerPlayer extends Player { } @Override @@ -1542,7 +1546,7 @@ if (oldVehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance effect : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(oldVehicle.getId(), effect.getEffect())); -@@ -2278,7 +_,7 @@ +@@ -2278,7 +2958,7 @@ public class ServerPlayer extends Player { } public static long placeEnderPearlTicket(final ServerLevel level, final ChunkPos chunk) { @@ -1551,7 +1555,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2308,9 +_,11 @@ +@@ -2308,9 +2988,11 @@ public class ServerPlayer extends Player { } } @@ -1566,7 +1570,7 @@ } private static float calculateLookAtYaw(final Vec3 position, final BlockPos lookAtBlockPos) { -@@ -2330,4 +_,135 @@ +@@ -2330,4 +3012,135 @@ public class ServerPlayer extends Player { ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch index e05a0ec589bb..8a1b35518558 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java +index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e66daaaa4 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -46,16 +_,37 @@ +@@ -46,16 +46,37 @@ public class ServerPlayerGameMode { private BlockPos delayedDestroyPos = BlockPos.ZERO; private int delayedTickStart; private int lastSentState = -1; @@ -39,7 +47,7 @@ Abilities abilities = this.player.getAbilities(); this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); if (abilities.flying && gameModeForPlayer != GameType.SPECTATOR && this.isInRangeOfGround()) { -@@ -66,13 +_,13 @@ +@@ -66,13 +87,13 @@ public class ServerPlayerGameMode { this.level .getServer() .getPlayerList() @@ -55,7 +63,7 @@ } } -@@ -105,10 +_,11 @@ +@@ -105,10 +126,11 @@ public class ServerPlayerGameMode { } public void tick() { @@ -70,7 +78,7 @@ this.hasDelayedDestroy = false; } else { float destroyProgress = this.incrementDestroyProgress(blockState, this.delayedDestroyPos, this.delayedTickStart); -@@ -118,7 +_,13 @@ +@@ -118,7 +140,13 @@ public class ServerPlayerGameMode { } } } else if (this.isDestroyingBlock) { @@ -85,7 +93,7 @@ if (blockState.isAir()) { this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.lastSentState = -1; -@@ -151,6 +_,7 @@ +@@ -151,6 +179,7 @@ public class ServerPlayerGameMode { final BlockPos pos, final ServerboundPlayerActionPacket.Action action, final Direction direction, final int maxY, final int sequence ) { if (!this.player.isWithinBlockInteractionRange(pos, 1.0)) { @@ -93,7 +101,7 @@ this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxY) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); -@@ -164,16 +_,35 @@ +@@ -164,16 +193,35 @@ public class ServerPlayerGameMode { } if (!this.level.mayInteract(this.player, pos)) { @@ -101,13 +109,11 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "may not interact"); -- return; -- } + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + // CraftBukkit end -+ return; -+ } -+ + return; + } + + // CraftBukkit start + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + if (event.isCancelled()) { @@ -115,7 +121,7 @@ + return; + } + // CraftBukkit end - ++ if (this.player.getAbilities().instabuild) { this.destroyAndAck(pos, sequence, "creative destroy"); return; @@ -131,7 +137,7 @@ if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "block action restricted"); -@@ -183,7 +_,7 @@ +@@ -183,7 +231,7 @@ public class ServerPlayerGameMode { this.destroyProgressStart = this.gameTicks; float progress = 1.0F; BlockState blockState = this.level.getBlockState(pos); @@ -140,7 +146,7 @@ EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -198,6 +_,23 @@ +@@ -198,6 +246,23 @@ public class ServerPlayerGameMode { progress = blockState.getDestroyProgress(this.player, this.player.level(), pos); } @@ -164,7 +170,7 @@ if (!blockState.isAir() && progress >= 1.0F) { this.destroyAndAck(pos, sequence, "insta mine"); } else { -@@ -238,14 +_,22 @@ +@@ -238,14 +303,22 @@ public class ServerPlayerGameMode { this.debugLogging(pos, true, sequence, "stopped destroying"); } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; @@ -189,7 +195,7 @@ } } } -@@ -261,17 +_,62 @@ +@@ -261,17 +334,62 @@ public class ServerPlayerGameMode { public boolean destroyBlock(final BlockPos pos) { BlockState state = this.level.getBlockState(pos); @@ -254,7 +260,7 @@ BlockState adjustedState = block.playerWillDestroy(this.level, pos, state, this.player); boolean changed = this.level.removeBlock(pos, false); if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -282,19 +_,44 @@ +@@ -282,19 +400,44 @@ public class ServerPlayerGameMode { block.destroy(this.level, pos, adjustedState); } @@ -272,14 +278,11 @@ itemStack.mineBlock(this.level, adjustedState, pos, this.player); - if (changed && canDestroy) { - block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith); -- } -- -- return true; -- } + if (changed && canDestroy) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion + block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith, event.isDropItems(), false); // Paper - fix drops not preventing stats/food exhaustion -+ } -+ + } + +- return true; + // return true; // CraftBukkit + } + // CraftBukkit start @@ -292,7 +295,7 @@ + // Drop event experience + if (changed) { + state.getBlock().popExperience(this.level, pos, event.getExpToDrop(), this.player); // Paper -+ } + } + // Paper start - Trigger bee_nest_destroyed trigger in the correct place (check impls of block#playerDestroy) + if (mainHandStack != null) { + if (changed && isCorrectTool && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && blockEntity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above @@ -306,7 +309,7 @@ } } } -@@ -307,6 +_,7 @@ +@@ -307,6 +450,7 @@ public class ServerPlayerGameMode { } else { int oldCount = itemStack.getCount(); int oldDamage = itemStack.getDamageValue(); @@ -314,7 +317,7 @@ InteractionResult result = itemStack.use(level, player, hand); ItemStack resultStack; if (result instanceof InteractionResult.Success success) { -@@ -332,7 +_,14 @@ +@@ -332,7 +476,14 @@ public class ServerPlayerGameMode { } if (!player.isUsingItem()) { @@ -330,7 +333,7 @@ } return result; -@@ -340,17 +_,55 @@ +@@ -340,17 +491,55 @@ public class ServerPlayerGameMode { } } @@ -388,7 +391,7 @@ return InteractionResult.CONSUME; } else { return InteractionResult.PASS; -@@ -375,7 +_,7 @@ +@@ -375,7 +564,7 @@ public class ServerPlayerGameMode { } } @@ -397,7 +400,7 @@ UseOnContext context = new UseOnContext(player, hand, hitResult); InteractionResult success; if (player.hasInfiniteMaterials()) { -@@ -392,6 +_,11 @@ +@@ -392,6 +581,11 @@ public class ServerPlayerGameMode { return success; } else { diff --git a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch rename to paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch index 97ed6a25d732..ea5c6b554ccd 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java +index df9d1b51d333a7497648b0d74236c66bff372205..690bb45bc91e4ca76754ca8f125c844a54484caf 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -146,6 +_,28 @@ +@@ -146,6 +146,28 @@ public class WorldGenRegion implements WorldGenLevel { return distance < this.generatingStep.directDependencies().size(); } @@ -29,7 +37,7 @@ @Override public BlockState getBlockState(final BlockPos pos) { return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -221,6 +_,7 @@ +@@ -221,6 +243,7 @@ public class WorldGenRegion implements WorldGenLevel { } } @@ -37,7 +45,7 @@ @Override public boolean ensureCanWrite(final BlockPos pos) { int chunkX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -238,6 +_,8 @@ +@@ -238,6 +261,8 @@ public class WorldGenRegion implements WorldGenLevel { return true; } else { @@ -46,7 +54,7 @@ Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + chunkX -@@ -249,6 +_,12 @@ +@@ -249,6 +274,12 @@ public class WorldGenRegion implements WorldGenLevel { + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -59,7 +67,7 @@ return false; } } -@@ -273,6 +_,17 @@ +@@ -273,6 +304,17 @@ public class WorldGenRegion implements WorldGenLevel { chunk.removeBlockEntity(pos); } } else { @@ -77,7 +85,7 @@ CompoundTag tag = new CompoundTag(); tag.putInt("x", pos.getX()); tag.putInt("y", pos.getY()); -@@ -301,6 +_,13 @@ +@@ -301,6 +343,13 @@ public class WorldGenRegion implements WorldGenLevel { @Override public boolean addFreshEntity(final Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch b/paper-server/patches/rejected/net/minecraft/server/network/ServerConnectionListener.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch rename to paper-server/patches/rejected/net/minecraft/server/network/ServerConnectionListener.java.patch index 401e8689924f..036c2a80b557 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java +index dc817359a74b1c98e4fcc57aa7285e999520b175..4b3490181278e0b652077d8a523138ce26423873 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -50,9 +_,31 @@ +@@ -50,9 +50,31 @@ public class ServerConnectionListener { this.running = true; } @@ -33,7 +41,7 @@ this.channels .add( new ServerBootstrap() -@@ -80,22 +_,64 @@ +@@ -80,22 +102,64 @@ public class ServerConnectionListener { Connection connection = (Connection)(rateLimitPacketsPerSecond > 0 ? new RateKickingConnection(rateLimitPacketsPerSecond) : new Connection(PacketFlow.SERVERBOUND)); @@ -100,7 +108,7 @@ public SocketAddress startMemoryChannel() { ChannelFuture newChannel; synchronized (this.channels) { -@@ -151,12 +_,26 @@ +@@ -151,12 +215,26 @@ public class ServerConnectionListener { public void tick() { synchronized (this.connections) { @@ -127,7 +135,7 @@ try { connection.tick(); } catch (Exception var7) { -@@ -170,6 +_,7 @@ +@@ -170,6 +248,7 @@ public class ServerConnectionListener { connection.setReadOnly(); } } else { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch rename to paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 535ad83014bf..a33e12f4c435 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173b466817c 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -222,6 +_,38 @@ +@@ -222,6 +222,38 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -39,7 +47,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, -@@ -242,7 +_,9 @@ +@@ -242,7 +274,9 @@ public class ServerGamePacketListenerImpl private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -49,7 +57,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -266,7 +_,23 @@ +@@ -266,7 +300,23 @@ public class ServerGamePacketListenerImpl private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -73,7 +81,7 @@ private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private int nextChatIndex; -@@ -275,6 +_,9 @@ +@@ -275,6 +325,9 @@ public class ServerGamePacketListenerImpl private boolean waitingForSwitchToConfig; private boolean waitingForRespawn; private int clientLoadedTimeoutTimer; @@ -83,12 +91,11 @@ public ServerGamePacketListenerImpl(final MinecraftServer server, final Connection connection, final ServerPlayer player, final CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -284,8 +_,22 @@ +@@ -284,8 +337,22 @@ public class ServerGamePacketListenerImpl player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); - this.chatMessageChain = new FutureChain(server); -- } + this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat + this.tickEndEvent = new io.papermc.paper.event.packet.ClientTickEndEvent(player.getBukkitEntity()); // Paper - add client tick end event + this.playerGameConnection = new io.papermc.paper.connection.PaperPlayerGameConnection(this); // Paper @@ -103,12 +110,12 @@ + @Override + public net.kyori.adventure.audience.Audience getAudience() { + return this.getCraftPlayer(); -+ } + } + // Paper end - configuration phase API @Override public void tick() { -@@ -298,11 +_,13 @@ +@@ -298,11 +365,13 @@ public class ServerGamePacketListenerImpl this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -123,7 +130,7 @@ } } } -@@ -318,8 +_,8 @@ +@@ -318,8 +387,8 @@ public class ServerGamePacketListenerImpl this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -134,7 +141,7 @@ return true; } } else { -@@ -337,8 +_,8 @@ +@@ -337,8 +406,8 @@ public class ServerGamePacketListenerImpl this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +152,7 @@ return true; } } else { -@@ -351,6 +_,12 @@ +@@ -351,6 +420,12 @@ public class ServerGamePacketListenerImpl this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +165,7 @@ return false; } -@@ -416,11 +_,37 @@ +@@ -416,11 +491,37 @@ public class ServerGamePacketListenerImpl @Override public void handlePlayerInput(final ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -186,9 +193,8 @@ if (this.hasClientLoaded()) { this.player.resetLastActionTime(); - this.player.setShiftKeyDown(packet.input().shift()); -- } + // this.player.setShiftKeyDown(packet.input().shift()); // Paper - move up and only set if event is not cancelled. -+ } + } + // Paper start - Add option to make parrots stay + if (packet.input().shift() && this.player.level().paperConfig().entities.behavior.parrotsAreUnaffectedByPlayerMovement) { + this.player.removeEntitiesOnShoulder(); @@ -198,7 +204,7 @@ } private static boolean containsInvalidValues(final double x, final double y, final double z, final float yRot, final float xRot) { -@@ -439,11 +_,23 @@ +@@ -439,11 +540,23 @@ public class ServerGamePacketListenerImpl public void handleMoveVehicle(final ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -223,7 +229,7 @@ double oldX = vehicle.getX(); double oldY = vehicle.getY(); double oldZ = vehicle.getZ(); -@@ -457,7 +_,52 @@ +@@ -457,7 +570,52 @@ public class ServerGamePacketListenerImpl double zDist = targetZ - this.vehicleFirstGoodZ; double expectedDist = vehicle.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -277,7 +283,7 @@ LOGGER.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", vehicle.getPlainTextName(), this.player.getPlainTextName(), xDist, yDist, zDist ); -@@ -466,9 +_,9 @@ +@@ -466,9 +624,9 @@ public class ServerGamePacketListenerImpl } AABB oldAABB = vehicle.getBoundingBox(); @@ -290,7 +296,7 @@ boolean vehicleRestsOnSomething = vehicle.verticalCollisionBelow; if (vehicle instanceof LivingEntity livingVehicle && livingVehicle.onClimbable()) { livingVehicle.resetFallDistance(); -@@ -485,7 +_,7 @@ +@@ -485,7 +643,7 @@ public class ServerGamePacketListenerImpl zDist = targetZ - vehicle.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; boolean fail = false; @@ -299,7 +305,7 @@ fail = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", vehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(movedDist)); } -@@ -498,6 +_,57 @@ +@@ -498,6 +656,57 @@ public class ServerGamePacketListenerImpl } vehicle.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); @@ -357,7 +363,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 clientDeltaMovement = new Vec3(vehicle.getX() - oldX, vehicle.getY() - oldY, vehicle.getZ() - oldZ); this.handlePlayerKnownMovement(clientDeltaMovement); -@@ -528,7 +_,7 @@ +@@ -528,7 +737,7 @@ public class ServerGamePacketListenerImpl PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -366,7 +372,7 @@ return; } -@@ -545,13 +_,14 @@ +@@ -545,13 +754,14 @@ public class ServerGamePacketListenerImpl this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -382,7 +388,7 @@ } @Override -@@ -572,6 +_,7 @@ +@@ -572,6 +782,7 @@ public class ServerGamePacketListenerImpl @Override public void handleRecipeBookChangeSettingsPacket(final ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -390,7 +396,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -587,25 +_,112 @@ +@@ -587,25 +798,112 @@ public class ServerGamePacketListenerImpl } } @@ -507,7 +513,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = null; -@@ -666,7 +_,7 @@ +@@ -666,7 +964,7 @@ public class ServerGamePacketListenerImpl @Override public void handleSetCommandMinecart(final ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -516,7 +522,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -702,11 +_,11 @@ +@@ -702,11 +1000,11 @@ public class ServerGamePacketListenerImpl boolean includeData = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack itemStack = blockState.getCloneItemStack(level, pos, includeData); if (!itemStack.isEmpty()) { @@ -530,7 +536,7 @@ } } } -@@ -733,7 +_,7 @@ +@@ -733,7 +1031,7 @@ public class ServerGamePacketListenerImpl if (entity != null && this.player.isWithinEntityInteractionRange(entity, 3.0)) { ItemStack itemStack = entity.getPickResult(); if (itemStack != null && !itemStack.isEmpty()) { @@ -539,7 +545,7 @@ } if (packet.includeData() && this.player.canUseGameMasterBlocks() && entity instanceof Avatar avatar) { -@@ -742,22 +_,35 @@ +@@ -742,22 +1040,35 @@ public class ServerGamePacketListenerImpl } } @@ -580,7 +586,7 @@ } } -@@ -790,7 +_,7 @@ +@@ -790,7 +1101,7 @@ public class ServerGamePacketListenerImpl @Override public void handleSetGameRule(final ServerboundSetGameRulePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -589,7 +595,7 @@ LOGGER.warn("Player {} tried to set game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -808,7 +_,7 @@ +@@ -808,7 +1119,7 @@ public class ServerGamePacketListenerImpl private void setGameRuleValue(final GameRules gameRules, final GameRule rule, final String value) { rule.deserialize(value).result().ifPresent(parsedValue -> { @@ -598,7 +604,7 @@ this.broadcastGameRuleChangeToOperators(rule, (T)parsedValue); }); } -@@ -967,6 +_,13 @@ +@@ -967,6 +1278,13 @@ public class ServerGamePacketListenerImpl PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int selection = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu menu) { @@ -612,7 +618,7 @@ if (!menu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, menu); return; -@@ -979,6 +_,51 @@ +@@ -979,6 +1297,51 @@ public class ServerGamePacketListenerImpl @Override public void handleEditBook(final ServerboundEditBookPacket packet) { @@ -664,7 +670,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List contents = Lists.newArrayList(); -@@ -993,10 +_,14 @@ +@@ -993,10 +1356,14 @@ public class ServerGamePacketListenerImpl } private void updateBookContents(final List contents, final int slot) { @@ -680,7 +686,7 @@ } } -@@ -1009,7 +_,8 @@ +@@ -1009,7 +1376,8 @@ public class ServerGamePacketListenerImpl writtenBook.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, pages, true) ); @@ -690,7 +696,7 @@ } } -@@ -1057,10 +_,10 @@ +@@ -1057,10 +1425,10 @@ public class ServerGamePacketListenerImpl public void handleMovePlayer(final ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -703,7 +709,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -1077,7 +_,15 @@ +@@ -1077,7 +1445,15 @@ public class ServerGamePacketListenerImpl if (this.player.isPassenger()) { this.player.absSnapTo(this.player.getX(), this.player.getY(), this.player.getZ(), targetYRot, targetXRot); this.player.level().getChunkSource().move(this.player); @@ -719,7 +725,7 @@ double startX = this.player.getX(); double startY = this.player.getY(); double startZ = this.player.getZ(); -@@ -1086,6 +_,16 @@ +@@ -1086,6 +1462,16 @@ public class ServerGamePacketListenerImpl double zDist = targetZ - this.firstGoodZ; double expectedDist = this.player.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -736,7 +742,7 @@ if (this.player.isSleeping()) { if (movedDist > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), targetYRot, targetXRot); -@@ -1095,7 +_,13 @@ +@@ -1095,7 +1481,13 @@ public class ServerGamePacketListenerImpl if (level.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int deltaPackets = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -751,7 +757,7 @@ LOGGER.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.player.getPlainTextName(), -@@ -1103,30 +_,96 @@ +@@ -1103,30 +1495,96 @@ public class ServerGamePacketListenerImpl ); deltaPackets = 1; } @@ -857,7 +863,7 @@ double oyDist = yDist; xDist = targetX - this.player.getX(); yDist = targetY - this.player.getY(); -@@ -1136,21 +_,101 @@ +@@ -1136,21 +1594,101 @@ public class ServerGamePacketListenerImpl zDist = targetZ - this.player.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -879,12 +885,6 @@ + if (event.getLogWarning()) + // Paper end LOGGER.warn("{} moved wrongly!", this.player.getPlainTextName()); -- } -- -- if (this.player.noPhysics -- || this.player.isSleeping() -- || (!fail || !level.noCollision(this.player, oldAABB)) -- && !this.isEntityCollidingWithAnythingNew(level, this.player, oldAABB, targetX, targetY, targetZ)) { + } // Paper + } + @@ -896,7 +896,7 @@ + if (event.isAllowed()) { + allowMovement = true; + } -+ } + } + if (allowMovement) { + // Paper end - Add fail move event + // CraftBukkit start - fire PlayerMoveEvent @@ -938,7 +938,11 @@ + this.lastPosZ = to.getZ(); + this.lastYaw = to.getYaw(); + this.lastPitch = to.getPitch(); -+ + +- if (this.player.noPhysics +- || this.player.isSleeping() +- || (!fail || !level.noCollision(this.player, oldAABB)) +- && !this.isEntityCollidingWithAnythingNew(level, this.player, oldAABB, targetX, targetY, targetZ)) { + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); + this.cserver.getPluginManager().callEvent(event); @@ -968,7 +972,7 @@ this.player.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = oyDist >= -0.03125 -@@ -1185,7 +_,7 @@ +@@ -1185,7 +1723,7 @@ public class ServerGamePacketListenerImpl this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -977,7 +981,7 @@ this.player .doCheckFallDamage( this.player.getX() - startX, this.player.getY() - startY, this.player.getZ() - startZ, packet.isOnGround() -@@ -1223,6 +_,7 @@ +@@ -1223,6 +1761,7 @@ public class ServerGamePacketListenerImpl this.player.getXRot() ); } @@ -985,7 +989,7 @@ return true; } else { -@@ -1248,10 +_,77 @@ +@@ -1248,10 +1787,77 @@ public class ServerGamePacketListenerImpl } public void teleport(final double x, final double y, final double z, final float yRot, final float xRot) { @@ -1064,7 +1068,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1259,12 +_,20 @@ +@@ -1259,12 +1865,20 @@ public class ServerGamePacketListenerImpl this.player.teleportSetPosition(destination, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1085,7 +1089,7 @@ if (this.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1289,32 +_,95 @@ +@@ -1289,32 +1903,95 @@ public class ServerGamePacketListenerImpl case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack swap = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1183,7 +1187,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1332,9 +_,36 @@ +@@ -1332,9 +2009,36 @@ public class ServerGamePacketListenerImpl } } @@ -1220,7 +1224,7 @@ if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1343,6 +_,11 @@ +@@ -1343,6 +2047,11 @@ public class ServerGamePacketListenerImpl if (itemStack.isItemEnabled(level.enabledFeatures())) { BlockHitResult blockHit = packet.getHitResult(); Vec3 location = blockHit.getLocation(); @@ -1232,7 +1236,7 @@ BlockPos pos = blockHit.getBlockPos(); if (this.player.isWithinBlockInteractionRange(pos, 1.0)) { Vec3 distance = location.subtract(Vec3.atCenterOf(pos)); -@@ -1357,9 +_,13 @@ +@@ -1357,9 +2066,13 @@ public class ServerGamePacketListenerImpl } else if (pos.getY() < minY) { this.player.sendBuildLimitMessage(false, minY); } else { @@ -1248,7 +1252,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, level, itemStack, hand, blockHit); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, blockHit.getBlockPos(), itemStack); -@@ -1371,7 +_,7 @@ +@@ -1371,7 +2084,7 @@ public class ServerGamePacketListenerImpl && wasBlockPlacementAttempt(this.player, itemStack)) { this.player.sendBuildLimitMessage(true, maxY); } else if (interactionResult instanceof InteractionResult.Success success @@ -1257,7 +1261,7 @@ this.player.swing(hand, true); } -@@ -1385,6 +_,15 @@ +@@ -1385,6 +2098,15 @@ public class ServerGamePacketListenerImpl && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); } @@ -1273,7 +1277,7 @@ } else { this.player.sendBuildLimitMessage(true, maxY); } -@@ -1392,13 +_,8 @@ +@@ -1392,13 +2114,8 @@ public class ServerGamePacketListenerImpl this.send(new ClientboundBlockUpdatePacket(level, pos)); this.send(new ClientboundBlockUpdatePacket(level, pos.relative(direction))); } @@ -1289,7 +1293,7 @@ } } } -@@ -1408,6 +_,8 @@ +@@ -1408,6 +2125,8 @@ public class ServerGamePacketListenerImpl @Override public void handleUseItem(final ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1298,7 +1302,7 @@ if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1421,6 +_,44 @@ +@@ -1421,6 +2140,44 @@ public class ServerGamePacketListenerImpl this.player.absSnapRotationTo(targetYRot, targetXRot); } @@ -1343,7 +1347,7 @@ if (this.player.gameMode.useItem(this.player, level, itemStack, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1436,7 +_,7 @@ +@@ -1436,7 +2193,7 @@ public class ServerGamePacketListenerImpl for (ServerLevel level : this.server.getAllLevels()) { Entity entity = packet.getEntity(level); if (entity != null) { @@ -1352,7 +1356,7 @@ return; } } -@@ -1454,23 +_,42 @@ +@@ -1454,23 +2211,42 @@ public class ServerGamePacketListenerImpl @Override public void onDisconnect(final DisconnectionDetails details) { LOGGER.info("{} lost connection: {}", this.player.getPlainTextName(), details.reason().getString()); @@ -1397,7 +1401,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(packetSequenceNr, this.ackBlockChangesUpTo); -@@ -1480,20 +_,38 @@ +@@ -1480,20 +2256,38 @@ public class ServerGamePacketListenerImpl @Override public void handleSetCarriedItem(final ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1436,7 +1440,7 @@ Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1505,25 +_,45 @@ +@@ -1505,25 +2299,45 @@ public class ServerGamePacketListenerImpl return; } @@ -1490,7 +1494,7 @@ ParseResults parsed = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parsed)) { LOGGER.error( -@@ -1540,26 +_,55 @@ +@@ -1540,26 +2354,55 @@ public class ServerGamePacketListenerImpl Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1549,7 +1553,7 @@ } private void handleMessageDecodeFailure(final SignedMessageChain.DecodeException e) { -@@ -1623,14 +_,20 @@ +@@ -1623,14 +2466,20 @@ public class ServerGamePacketListenerImpl return commands.parse(command, this.player.createCommandSourceStack()); } @@ -1574,7 +1578,7 @@ } } -@@ -1642,7 +_,7 @@ +@@ -1642,7 +2491,7 @@ public class ServerGamePacketListenerImpl var10000 = Optional.of(result); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1583,7 +1587,7 @@ return Optional.empty(); } -@@ -1660,22 +_,81 @@ +@@ -1660,22 +2509,81 @@ public class ServerGamePacketListenerImpl return false; } @@ -1671,7 +1675,7 @@ } } -@@ -1686,7 +_,7 @@ +@@ -1686,7 +2594,7 @@ public class ServerGamePacketListenerImpl this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1680,7 +1684,7 @@ } } } -@@ -1694,7 +_,34 @@ +@@ -1694,7 +2602,34 @@ public class ServerGamePacketListenerImpl @Override public void handleAnimate(final ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1715,7 +1719,7 @@ this.player.swing(packet.getHand()); } -@@ -1702,6 +_,21 @@ +@@ -1702,6 +2637,21 @@ public class ServerGamePacketListenerImpl public void handlePlayerCommand(final ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.hasClientLoaded()) { @@ -1737,7 +1741,7 @@ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1746,6 +_,14 @@ +@@ -1746,6 +2696,14 @@ public class ServerGamePacketListenerImpl } public void sendPlayerChatMessage(final PlayerChatMessage message, final ChatType.Bound chatType) { @@ -1752,7 +1756,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1768,9 +_,11 @@ +@@ -1768,9 +2726,11 @@ public class ServerGamePacketListenerImpl } if (trackedCount > 4096) { @@ -1765,7 +1769,7 @@ } public void sendDisguisedChatMessage(final Component content, final ChatType.Bound chatType) { -@@ -1781,6 +_,17 @@ +@@ -1781,6 +2741,17 @@ public class ServerGamePacketListenerImpl return this.connection.getRemoteAddress(); } @@ -1783,7 +1787,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1796,20 +_,27 @@ +@@ -1796,20 +2767,27 @@ public class ServerGamePacketListenerImpl @Override public void handleAttack(final ServerboundAttackPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1813,7 +1817,7 @@ LOGGER.warn("Player {} tried to attack an invalid entity", this.player.getPlainTextName()); } else if (mainHandItem.isItemEnabled(level.enabledFeatures())) { if (!this.player.cannotAttackWithItem(mainHandItem, 5)) { -@@ -1819,25 +_,88 @@ +@@ -1819,25 +2797,88 @@ public class ServerGamePacketListenerImpl } } } @@ -1903,7 +1907,7 @@ if (this.player.interactOn(target, hand, location) instanceof InteractionResult.Success success) { ItemStack awardedForStack = success.wasItemInteraction() ? usedItemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(this.player, awardedForStack, target); -@@ -1848,6 +_,12 @@ +@@ -1848,6 +2889,12 @@ public class ServerGamePacketListenerImpl } } } @@ -1916,7 +1920,7 @@ } } -@@ -1859,7 +_,7 @@ +@@ -1859,7 +2906,7 @@ public class ServerGamePacketListenerImpl ServerLevel level = this.player.level(); Entity target = level.getEntityOrPart(packet.entityId()); if (target != null && level.getWorldBorder().isWithinBounds(target.blockPosition())) { @@ -1925,7 +1929,7 @@ if (target.isPickable()) { this.player.setCamera(target); } -@@ -1877,7 +_,7 @@ +@@ -1877,7 +2924,7 @@ public class ServerGamePacketListenerImpl case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1934,7 +1938,7 @@ this.resetPosition(); this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -1886,12 +_,12 @@ +@@ -1886,12 +2933,12 @@ public class ServerGamePacketListenerImpl return; } @@ -1950,7 +1954,7 @@ } } break; -@@ -1904,7 +_,7 @@ +@@ -1904,7 +2951,7 @@ public class ServerGamePacketListenerImpl } private void sendGameRuleValues() { @@ -1959,7 +1963,7 @@ LOGGER.warn("Player {} tried to request game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -1920,16 +_,27 @@ +@@ -1920,16 +2967,27 @@ public class ServerGamePacketListenerImpl @Override public void handleContainerClose(final ServerboundContainerClosePacket packet) { @@ -1989,7 +1993,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1945,7 +_,298 @@ +@@ -1945,7 +3003,298 @@ public class ServerGamePacketListenerImpl } else { boolean fullResyncNeeded = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2289,7 +2293,7 @@ for (Entry e : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(e.getIntKey(), e.getValue()); -@@ -1958,6 +_,8 @@ +@@ -1958,6 +3307,8 @@ public class ServerGamePacketListenerImpl } else { this.player.containerMenu.broadcastChanges(); } @@ -2298,7 +2302,7 @@ } } } -@@ -1965,6 +_,14 @@ +@@ -1965,6 +3316,14 @@ public class ServerGamePacketListenerImpl @Override public void handlePlaceRecipe(final ServerboundPlaceRecipePacket packet) { @@ -2313,7 +2317,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1981,9 +_,44 @@ +@@ -1981,9 +3340,44 @@ public class ServerGamePacketListenerImpl return; } @@ -2359,7 +2363,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, displayInfo.display().display())); } -@@ -1997,6 +_,7 @@ +@@ -1997,6 +3391,7 @@ public class ServerGamePacketListenerImpl @Override public void handleContainerButtonClick(final ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2367,7 +2371,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -2006,6 +_,7 @@ +@@ -2006,6 +3401,7 @@ public class ServerGamePacketListenerImpl if (clickAccepted) { this.player.containerMenu.broadcastChanges(); } @@ -2375,7 +2379,7 @@ } } } -@@ -2022,10 +_,48 @@ +@@ -2022,10 +3418,48 @@ public class ServerGamePacketListenerImpl boolean validSlot = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean validData = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2424,7 +2428,7 @@ } else if (drop && validData) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -2039,15 +_,38 @@ +@@ -2039,15 +3473,38 @@ public class ServerGamePacketListenerImpl @Override public void handleSignUpdate(final ServerboundSignUpdatePacket packet) { @@ -2464,7 +2468,7 @@ if (!(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) { return; } -@@ -2059,14 +_,32 @@ +@@ -2059,14 +3516,32 @@ public class ServerGamePacketListenerImpl @Override public void handlePlayerAbilities(final ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2498,7 +2502,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != wasHatShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2082,21 +_,21 @@ +@@ -2082,21 +3557,21 @@ public class ServerGamePacketListenerImpl packet.difficulty().getDisplayName() ); } else { @@ -2523,7 +2527,7 @@ } } -@@ -2116,7 +_,7 @@ +@@ -2116,7 +3591,7 @@ public class ServerGamePacketListenerImpl ProfilePublicKey.Data newProfileKey = newChatSession.profilePublicKey(); if (!Objects.equals(oldProfileKey, newProfileKey)) { if (oldProfileKey != null && newProfileKey.expiresAt().isBefore(oldProfileKey.expiresAt())) { @@ -2532,7 +2536,7 @@ } else { try { SignatureValidator profileKeySignatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2127,8 +_,8 @@ +@@ -2127,8 +3602,8 @@ public class ServerGamePacketListenerImpl this.resetPlayerChatState(newChatSession.validate(this.player.getGameProfile(), profileKeySignatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2543,7 +2547,7 @@ } } } -@@ -2139,11 +_,13 @@ +@@ -2139,11 +3614,13 @@ public class ServerGamePacketListenerImpl if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2558,7 +2562,7 @@ } } -@@ -2161,27 +_,32 @@ +@@ -2161,27 +3638,32 @@ public class ServerGamePacketListenerImpl private void resetPlayerChatState(final RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2592,7 +2596,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2213,12 +_,23 @@ +@@ -2213,12 +3695,23 @@ public class ServerGamePacketListenerImpl } public void tickClientLoadTimeout() { @@ -2618,7 +2622,7 @@ this.clientLoadedTimeoutTimer = 0; } -@@ -2230,4 +_,80 @@ +@@ -2230,4 +3723,80 @@ public class ServerGamePacketListenerImpl this.waitingForRespawn = false; this.clientLoadedTimeoutTimer = 60; } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch rename to paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 7bf327394d3b..cd1c9dc8702f 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c058e79eb 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -46,9 +_,16 @@ +@@ -46,9 +46,16 @@ import org.apache.commons.lang3.Validate; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -17,7 +25,7 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; private final MinecraftServer server; -@@ -56,10 +_,14 @@ +@@ -56,10 +63,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, private final ServerActivityMonitor serverActivityMonitor; public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; @@ -34,7 +42,7 @@ public ServerLoginPacketListenerImpl(final MinecraftServer minecraftserver, final Connection connection, final boolean transferred) { this.server = minecraftserver; -@@ -67,10 +_,19 @@ +@@ -67,10 +78,19 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, this.serverActivityMonitor = this.server.getServerActivityMonitor(); this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); this.transferred = transferred; @@ -54,7 +62,7 @@ if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { this.verifyLoginAndFinishConnectionSetup(Objects.requireNonNull(this.authenticatedProfile)); } -@@ -80,16 +_,39 @@ +@@ -80,16 +100,39 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, this.finishLoginAndWaitForClient(this.authenticatedProfile); } @@ -68,14 +76,14 @@ + this.disconnectAsync(Component.translatable("multiplayer.disconnect.slow_login")); // Paper } } -+ + + // CraftBukkit start + @Deprecated + public void disconnect(String reason) { + this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(reason))); // Paper - Fix hex colors not working in some kick messages + } + // CraftBukkit end - ++ @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); @@ -95,7 +103,7 @@ public void disconnect(final Component component) { try { LOGGER.info("Disconnecting {}: {}", this.getUserName(), component.getString()); -@@ -117,7 +_,14 @@ +@@ -117,7 +160,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void handleHello(final ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"); @@ -111,7 +119,7 @@ this.requestedUsername = packet.name(); GameProfile singleplayerProfile = this.server.getSingleplayerProfile(); if (singleplayerProfile != null && this.requestedUsername.equalsIgnoreCase(singleplayerProfile.name())) { -@@ -127,7 +_,30 @@ +@@ -127,7 +177,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -143,7 +151,7 @@ } } } -@@ -139,9 +_,9 @@ +@@ -139,9 +212,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, private void verifyLoginAndFinishConnectionSetup(final GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -155,7 +163,7 @@ } else { if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { this.connection -@@ -151,7 +_,7 @@ +@@ -151,7 +224,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, ); } @@ -164,7 +172,7 @@ if (waitForDisconnection) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -163,6 +_,7 @@ +@@ -163,6 +236,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, private void finishLoginAndWaitForClient(final GameProfile gameProfile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; this.connection.send(new ClientboundLoginFinishedPacket(gameProfile)); @@ -172,7 +180,7 @@ } @Override -@@ -186,7 +_,8 @@ +@@ -186,7 +260,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, throw new IllegalStateException("Protocol error", var7); } @@ -182,7 +190,7 @@ { Objects.requireNonNull(ServerLoginPacketListenerImpl.this); } -@@ -202,12 +_,18 @@ +@@ -202,12 +277,18 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, .hasJoinedServer(name, digest, this.getAddress()); if (result != null) { GameProfile profile = result.profile(); @@ -202,7 +210,7 @@ } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", name); -@@ -215,11 +_,16 @@ +@@ -215,11 +296,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, } catch (AuthenticationUnavailableException var4) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); @@ -221,14 +229,13 @@ } } -@@ -229,18 +_,123 @@ +@@ -229,18 +315,123 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, ? ((InetSocketAddress)remoteAddress).getAddress() : null; } - }; - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); - thread.start(); -- } + }); + // Paper end - Virtual authenticator threads + } @@ -281,7 +288,7 @@ + } + } + return gameprofile; // Paper - Add more fields to AsyncPlayerPreLoginEvent -+ } + } + // CraftBukkit end @Override @@ -349,14 +356,14 @@ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie cookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); -@@ -257,8 +_,31 @@ +@@ -257,9 +448,32 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void handleCookieResponse(final ServerboundCookieResponsePacket packet) { + if (this.paperLoginConnection.handleCookieResponse(packet)) return; // Paper this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -+ + + // Spigot start + protected GameProfile createOfflineProfile(String s) { + java.util.UUID uuid; @@ -378,6 +385,7 @@ + return new GameProfile(uuid, s, new com.mojang.authlib.properties.PropertyMap(props.build())); + } + // Spigot end - ++ public static enum State { HELLO, + KEY, diff --git a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch b/paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch rename to paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch index 7f726f2395ab..80855d43a359 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/network/config/PrepareSpawnTask.java b/net/minecraft/server/network/config/PrepareSpawnTask.java +index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2afb2e3943 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -37,10 +_,18 @@ +@@ -37,10 +37,18 @@ public class PrepareSpawnTask implements ConfigurationTask { private final LevelLoadListener loadListener; private PrepareSpawnTask.@Nullable State state; @@ -22,7 +30,7 @@ } @Override -@@ -50,16 +_,58 @@ +@@ -50,16 +58,58 @@ public class PrepareSpawnTask implements ConfigurationTask { .getPlayerList() .loadPlayerData(this.nameAndId) .map(tag -> TagValueInput.create(reporter, this.server.registryAccess(), tag)); @@ -86,7 +94,7 @@ Vec2 spawnAngle = loadedPosition.rotation().orElse(new Vec2(respawnData.yaw(), respawnData.pitch())); this.state = new PrepareSpawnTask.Preparing(spawnLevel, spawnPosition, spawnAngle); } -@@ -111,10 +_,11 @@ +@@ -111,10 +161,11 @@ public class PrepareSpawnTask implements ConfigurationTask { } private final class Preparing implements PrepareSpawnTask.State { @@ -101,7 +109,7 @@ private final ChunkLoadCounter chunkLoadCounter; private Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { -@@ -136,6 +_,54 @@ +@@ -136,6 +187,54 @@ public class PrepareSpawnTask implements ConfigurationTask { } else { Vec3 spawnPosition = this.spawnPosition.join(); if (this.chunkLoadFuture == null) { @@ -156,7 +164,7 @@ ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition)); this.chunkLoadCounter .track( -@@ -178,15 +_,48 @@ +@@ -178,15 +277,48 @@ public class PrepareSpawnTask implements ConfigurationTask { public ServerPlayer spawn(final Connection connection, final CommonListenerCookie cookie) { ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(this.spawnPosition)); this.spawnLevel.waitForEntities(spawnChunk, 3); diff --git a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch b/paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch rename to paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch index 8da762b0a07c..37e5b19413ea 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/players/CachedUserNameToIdResolver.java b/net/minecraft/server/players/CachedUserNameToIdResolver.java +index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f2872e7a5dbb 100644 --- a/net/minecraft/server/players/CachedUserNameToIdResolver.java +++ b/net/minecraft/server/players/CachedUserNameToIdResolver.java -@@ -46,6 +_,10 @@ +@@ -46,6 +46,10 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { private final Gson gson = new GsonBuilder().create(); private final File file; private final AtomicLong operationCount = new AtomicLong(); @@ -11,7 +19,7 @@ public CachedUserNameToIdResolver(final GameProfileRepository profileRepository, final File file) { this.profileRepository = profileRepository; -@@ -54,23 +_,27 @@ +@@ -54,23 +58,27 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { } private void safeAdd(final CachedUserNameToIdResolver.GameProfileInfo profileInfo) { @@ -41,7 +49,7 @@ } @Override -@@ -90,7 +_,7 @@ +@@ -90,7 +98,7 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { Date expirationDate = c.getTime(); CachedUserNameToIdResolver.GameProfileInfo profileInfo = new CachedUserNameToIdResolver.GameProfileInfo(profile, expirationDate); this.safeAdd(profileInfo); @@ -50,7 +58,7 @@ return profileInfo; } -@@ -98,9 +_,24 @@ +@@ -98,9 +106,24 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { return this.operationCount.incrementAndGet(); } @@ -75,7 +83,7 @@ CachedUserNameToIdResolver.GameProfileInfo profileInfo = this.profilesByName.get(userName); boolean needsSave = false; if (profileInfo != null && new Date().getTime() >= profileInfo.expirationDate.getTime()) { -@@ -114,8 +_,13 @@ +@@ -114,8 +137,13 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { if (profileInfo != null) { profileInfo.setLastAccess(this.getNextOperation()); result = Optional.of(profileInfo.nameAndId()); @@ -90,7 +98,7 @@ if (profile.isPresent()) { result = Optional.of(this.addInternal(profile.get()).nameAndId()); needsSave = false; -@@ -124,15 +_,17 @@ +@@ -124,15 +152,17 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { } } @@ -110,7 +118,7 @@ CachedUserNameToIdResolver.GameProfileInfo profileInfo = this.profilesByUUID.get(id); if (profileInfo == null) { return Optional.empty(); -@@ -140,6 +_,7 @@ +@@ -140,6 +170,7 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { profileInfo.setLastAccess(this.getNextOperation()); return Optional.of(profileInfo.nameAndId()); } @@ -118,7 +126,7 @@ } private static DateFormat createDateFormat() { -@@ -164,6 +_,11 @@ +@@ -164,6 +195,11 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { return (List)var9; } catch (FileNotFoundException var7) { @@ -130,7 +138,7 @@ } catch (JsonParseException | IOException var8) { LOGGER.warn("Failed to load profile cache {}", this.file, var8); } -@@ -173,23 +_,51 @@ +@@ -173,23 +209,51 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { @Override public void save() { @@ -167,7 +175,6 @@ - .stream() - .sorted(Comparator.comparing(CachedUserNameToIdResolver.GameProfileInfo::lastAccess).reversed()) - .limit(limit); -- } + // Paper start - Fix GameProfileCache concurrency + return this.listTopMRUProfiles(limit).stream(); + } @@ -183,7 +190,7 @@ + } finally { + this.stateLock.unlock(); + } -+ } + } + // Paper end - Fix GameProfileCache concurrency private static JsonElement writeGameProfile(final CachedUserNameToIdResolver.GameProfileInfo src, final DateFormat dateFormat) { diff --git a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch b/paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch rename to paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch index 02d4bec2ed83..510c98c704ba 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/players/OldUsersConverter.java b/net/minecraft/server/players/OldUsersConverter.java +index e6946327048187e4704feb91d24ab9d77590a501..82cef084ebdb4d42eb8ace1e6b0e595074928a87 100644 --- a/net/minecraft/server/players/OldUsersConverter.java +++ b/net/minecraft/server/players/OldUsersConverter.java -@@ -50,7 +_,8 @@ +@@ -50,7 +50,8 @@ public class OldUsersConverter { private static void lookupPlayers(final MinecraftServer server, final Collection names, final ProfileLookupCallback callback) { String[] filteredNames = names.stream().filter(s -> !StringUtil.isNullOrEmpty(s)).toArray(String[]::new); @@ -10,7 +18,7 @@ server.services().profileRepository().findProfilesByNames(filteredNames, callback); } else { for (String name : filteredNames) { -@@ -66,7 +_,7 @@ +@@ -66,7 +67,7 @@ public class OldUsersConverter { try { bans.load(); } catch (IOException var6) { @@ -19,7 +27,7 @@ } } -@@ -122,7 +_,7 @@ +@@ -122,7 +123,7 @@ public class OldUsersConverter { try { ipBans.load(); } catch (IOException var11) { @@ -28,7 +36,7 @@ } } -@@ -158,7 +_,7 @@ +@@ -158,7 +159,7 @@ public class OldUsersConverter { try { opsList.load(); } catch (IOException var6) { @@ -37,7 +45,7 @@ } } -@@ -203,7 +_,7 @@ +@@ -203,7 +204,7 @@ public class OldUsersConverter { try { whitelist.load(); } catch (IOException var6) { @@ -46,7 +54,7 @@ } } -@@ -317,6 +_,35 @@ +@@ -317,6 +318,35 @@ public class OldUsersConverter { private void movePlayerFile(final File directory, final String oldName, final String newName) { File oldFileName = new File(worldPlayerDirectory, oldName + ".dat"); File newFileName = new File(directory, newName + ".dat"); diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch rename to paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch index b6c7894d187b..1333afea7162 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04dc35b268 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -114,14 +_,16 @@ +@@ -114,14 +114,16 @@ public abstract class PlayerList { private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z", Locale.ROOT); private final MinecraftServer server; @@ -20,7 +28,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -129,12 +_,20 @@ +@@ -129,12 +131,20 @@ public abstract class PlayerList { private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -41,7 +49,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -144,23 +_,19 @@ +@@ -144,23 +154,19 @@ public abstract class PlayerList { this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -70,7 +78,7 @@ LevelData levelData = level.getLevelData(); ServerGamePacketListenerImpl playerConnection = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -177,8 +_,8 @@ +@@ -177,8 +183,8 @@ public abstract class PlayerList { levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -81,7 +89,7 @@ reducedDebugInfo, !immediateRespawn, doLimitedCrafting, -@@ -186,6 +_,7 @@ +@@ -186,6 +192,7 @@ public abstract class PlayerList { this.server.enforceSecureProfile() ) ); @@ -89,7 +97,7 @@ playerConnection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); playerConnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); playerConnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -205,24 +_,129 @@ +@@ -205,24 +212,129 @@ public abstract class PlayerList { component = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), oldName); } @@ -223,7 +231,7 @@ } public void updateEntireScoreboard(final ServerScoreboard scoreboard, final ServerPlayer player) { -@@ -244,6 +_,15 @@ +@@ -244,6 +356,15 @@ public abstract class PlayerList { } } @@ -239,7 +247,7 @@ public void addWorldborderListener(final ServerLevel level) { level.getWorldBorder().addListener(new BorderChangeListener() { { -@@ -252,27 +_,27 @@ +@@ -252,27 +373,27 @@ public abstract class PlayerList { @Override public void onSetSize(final WorldBorder border, final double newSize) { @@ -272,7 +280,7 @@ } @Override -@@ -296,64 +_,147 @@ +@@ -296,64 +417,147 @@ public abstract class PlayerList { } protected void save(final ServerPlayer player) { @@ -381,11 +389,6 @@ } - this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); -- } -- -- public @Nullable Component canPlayerLogin(final SocketAddress address, final NameAndId nameAndId) { -- if (this.bans.isBanned(nameAndId)) { -- UserBanListEntry ban = this.bans.get(nameAndId); + // CraftBukkit start + // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); + ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID())); @@ -402,8 +405,11 @@ + this.cserver.getScoreboardManager().removePlayer(player.getBukkitEntity()); + // CraftBukkit end + return playerQuitEvent.quitMessage(); // Paper - Adventure -+ } -+ + } + +- public @Nullable Component canPlayerLogin(final SocketAddress address, final NameAndId nameAndId) { +- if (this.bans.isBanned(nameAndId)) { +- UserBanListEntry ban = this.bans.get(nameAndId); + // Paper start - PlayerLoginEvent + public record LoginResult(@Nullable Component message, org.bukkit.event.player.PlayerLoginEvent.Result result) { + public static LoginResult ALLOW = new net.minecraft.server.players.PlayerList.LoginResult(null, org.bukkit.event.player.PlayerLoginEvent.Result.ALLOWED); @@ -436,7 +442,7 @@ } else if (this.ipBans.isBanned(address)) { IpBanListEntry ban = this.ipBans.get(address); MutableComponent reason = Component.translatable("multiplayer.disconnect.banned_ip.reason", ban.getReasonMessage()); -@@ -361,19 +_,18 @@ +@@ -361,19 +565,18 @@ public abstract class PlayerList { reason.append(Component.translatable("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ban.getExpires()))); } @@ -461,7 +467,7 @@ dupes.add(player); } } -@@ -384,23 +_,31 @@ +@@ -384,23 +587,31 @@ public abstract class PlayerList { } for (ServerPlayer playerx : dupes) { @@ -498,7 +504,7 @@ player.copyRespawnPosition(serverPlayer); } -@@ -408,17 +_,26 @@ +@@ -408,17 +619,26 @@ public abstract class PlayerList { player.addTag(tag); } @@ -526,7 +532,7 @@ player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); player.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); player.connection.send(new ClientboundSetExperiencePacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); -@@ -427,9 +_,15 @@ +@@ -427,9 +647,15 @@ public abstract class PlayerList { this.sendPlayerPermissionLevel(player); level.addRespawnedPlayer(player); this.players.add(player); @@ -542,7 +548,7 @@ ServerPlayer.RespawnConfig respawnConfig = player.getRespawnConfig(); if (!keepAllPlayerData && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -455,6 +_,29 @@ +@@ -455,6 +681,29 @@ public abstract class PlayerList { } } @@ -572,7 +578,7 @@ return player; } -@@ -463,23 +_,58 @@ +@@ -463,23 +712,58 @@ public abstract class PlayerList { } public void sendActiveEffects(final LivingEntity livingEntity, final ServerGamePacketListenerImpl connection) { @@ -634,7 +640,7 @@ public void broadcastAll(final Packet packet) { for (ServerPlayer player : this.players) { player.connection.send(packet); -@@ -565,6 +_,12 @@ +@@ -565,6 +849,12 @@ public abstract class PlayerList { } private void sendPlayerPermissionLevel(final ServerPlayer player, final LevelBasedPermissionSet permissions) { @@ -647,18 +653,16 @@ if (player.connection != null) { byte eventId = switch (permissions.level()) { case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; -@@ -576,9 +_,48 @@ +@@ -576,9 +866,48 @@ public abstract class PlayerList { player.connection.send(new ClientboundEntityEventPacket(player, eventId)); } + if (recalculatePermissions) { // Paper - Add sendOpLevel API + player.getBukkitEntity().recalculatePermissions(); // CraftBukkit this.server.getCommands().sendCommands(player); -- } -- + } // Paper - Add sendOpLevel API -+ } -+ + } + + // Paper start - whitelist verify event / login event + public LoginResult canBypassFullServerLogin(final NameAndId nameAndId, final LoginResult currentResult) { + final boolean shouldKick = this.players.size() >= this.getMaxPlayers() && !this.canBypassPlayerLimit(nameAndId); @@ -698,7 +702,7 @@ public boolean isWhiteListed(final NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -590,16 +_,7 @@ +@@ -590,16 +919,7 @@ public abstract class PlayerList { } public @Nullable ServerPlayer getPlayerByName(final String name) { @@ -716,7 +720,7 @@ } public void broadcast( -@@ -613,6 +_,11 @@ +@@ -613,6 +933,11 @@ public abstract class PlayerList { ) { for (int i = 0; i < this.players.size(); i++) { ServerPlayer player = this.players.get(i); @@ -728,7 +732,7 @@ if (player != except && player.level().dimension() == dimension) { double xd = x - player.getX(); double yd = y - player.getY(); -@@ -625,9 +_,11 @@ +@@ -625,9 +950,11 @@ public abstract class PlayerList { } public void saveAll() { @@ -740,7 +744,7 @@ } public UserWhiteList getWhiteList() { -@@ -652,12 +_,20 @@ +@@ -652,12 +979,20 @@ public abstract class PlayerList { public void sendLevelInfo(final ServerPlayer player, final ServerLevel level) { WorldBorder worldBorder = level.getWorldBorder(); player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); @@ -765,7 +769,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -666,8 +_,21 @@ +@@ -666,8 +1001,21 @@ public abstract class PlayerList { public void sendAllPlayerInfo(final ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -788,13 +792,12 @@ } public int getPlayerCount() { -@@ -711,9 +_,26 @@ +@@ -711,9 +1059,26 @@ public abstract class PlayerList { } public void removeAll() { - for (int i = 0; i < this.players.size(); i++) { - this.players.get(i).connection.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); -- } + // Paper start - Extract method to allow for restarting flag + this.removeAll(false); + } @@ -813,12 +816,12 @@ + final net.minecraft.world.scores.Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); + final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName); + if (team != null) scoreboard.removePlayerTeam(team); -+ } + } + // Paper end - Configurable player collision } public void broadcastSystemMessage(final Component message, final boolean overlay) { -@@ -736,20 +_,39 @@ +@@ -736,20 +1101,39 @@ public abstract class PlayerList { } public void broadcastChatMessage(final PlayerChatMessage message, final ServerPlayer sender, final ChatType.Bound chatType) { @@ -861,7 +864,7 @@ wasFullyFiltered |= filtered && message.isFullyFiltered(); } -@@ -762,13 +_,21 @@ +@@ -762,13 +1146,21 @@ public abstract class PlayerList { return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -886,7 +889,7 @@ private Path locateStatsFile(final GameProfile gameProfile) { Path statFolder = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR); -@@ -795,11 +_,11 @@ +@@ -795,11 +1187,11 @@ public abstract class PlayerList { public PlayerAdvancements getPlayerAdvancements(final ServerPlayer player) { UUID uuid = player.getUUID(); @@ -900,7 +903,7 @@ } result.setPlayer(player); -@@ -847,11 +_,34 @@ +@@ -847,11 +1239,34 @@ public abstract class PlayerList { } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch rename to paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch index 35ae01a2673f..c0e2489359fb 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/net/minecraft/server/rcon/thread/QueryThreadGs4.java +index 8ca6abbd9796de29a9962183cd2cb496d0f43d8c..71d3306bd8b08510471ed9168c27ebf3faee8cde 100644 --- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java +++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -105,13 +_,32 @@ +@@ -105,13 +105,32 @@ public class QueryThreadGs4 extends GenericThread { NetworkDataOutputStream dos = new NetworkDataOutputStream(1460); dos.write(0); dos.writeBytes(this.getIdentBytes(packet.getSocketAddress())); @@ -39,7 +47,7 @@ this.sendTo(dos.toByteArray(), packet); LOGGER.debug("Status [{}]", socketAddress); } -@@ -146,31 +_,76 @@ +@@ -146,31 +165,76 @@ public class QueryThreadGs4 extends GenericThread { this.rulesResponse.writeString("splitnum"); this.rulesResponse.write(128); this.rulesResponse.write(0); diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch b/paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch similarity index 74% rename from paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch rename to paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch index 65e879ba64fc..adeaa7991eb6 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch +++ b/paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/server/rcon/thread/RconClient.java b/net/minecraft/server/rcon/thread/RconClient.java +index ccc9714c9c5f0281f46052f8a5d13f37d238f2c2..4151d3a705539a881c304a906fef40d90ba001fe 100644 --- a/net/minecraft/server/rcon/thread/RconClient.java +++ b/net/minecraft/server/rcon/thread/RconClient.java -@@ -23,11 +_,14 @@ +@@ -23,11 +23,14 @@ public class RconClient extends GenericThread { private final Socket client; private final byte[] buf = new byte[1460]; private final String rconPassword; @@ -17,7 +25,7 @@ this.client = socket; try { -@@ -37,6 +_,7 @@ +@@ -37,6 +40,7 @@ public class RconClient extends GenericThread { } this.rconPassword = rconPassword; @@ -25,7 +33,7 @@ } @Override -@@ -67,7 +_,7 @@ +@@ -67,7 +71,7 @@ public class RconClient extends GenericThread { String command = PktUtils.stringFromByteArray(this.buf, offset, read); try { diff --git a/paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch b/paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch index 8de07f4f8ce7..73a321a9f4ef 100644 --- a/paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java +index dff969b9f0d320616f93bd7dca1b5660b5f316bd..cd9b408afdabb632ceba265c8de6035e1276024f 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java -@@ -204,8 +_,8 @@ +@@ -204,8 +204,8 @@ public class SimpleBitStorage implements BitStorage { private final long mask; private final int size; private final int valuesPerLong; @@ -11,7 +19,7 @@ private final int divideShift; public SimpleBitStorage(final int bits, final int size, final int[] values) { -@@ -248,8 +_,8 @@ +@@ -248,8 +248,8 @@ public class SimpleBitStorage implements BitStorage { this.mask = (1L << bits) - 1L; this.valuesPerLong = (char)(64 / bits); int row = 3 * (this.valuesPerLong - 1); @@ -22,7 +30,7 @@ this.divideShift = MAGIC[row + 2]; int requiredLength = (size + this.valuesPerLong - 1) / this.valuesPerLong; if (data != null) { -@@ -264,15 +_,11 @@ +@@ -264,15 +264,11 @@ public class SimpleBitStorage implements BitStorage { } private int cellIndex(final int bitIndex) { @@ -40,7 +48,7 @@ int cellIndex = this.cellIndex(index); long cellValue = this.data[cellIndex]; int bitIndex = (index - cellIndex * this.valuesPerLong) * this.bits; -@@ -282,9 +_,7 @@ +@@ -282,9 +278,7 @@ public class SimpleBitStorage implements BitStorage { } @Override @@ -51,7 +59,7 @@ int cellIndex = this.cellIndex(index); long cellValue = this.data[cellIndex]; int bitIndex = (index - cellIndex * this.valuesPerLong) * this.bits; -@@ -292,8 +_,7 @@ +@@ -292,8 +286,7 @@ public class SimpleBitStorage implements BitStorage { } @Override diff --git a/paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch b/paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch index de6cbf1fea52..174627de1a2a 100644 --- a/paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java +index 6e2786e9f0812ce0dfa9ce8dd59f5a5cf1141bf2..1ceb7e4a3abd4d9de5133d182d3267d2164918f6 100644 --- a/net/minecraft/util/ZeroBitStorage.java +++ b/net/minecraft/util/ZeroBitStorage.java -@@ -13,21 +_,21 @@ +@@ -13,21 +13,21 @@ public class ZeroBitStorage implements BitStorage { } @Override diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch b/paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch similarity index 56% rename from paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch rename to paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch index 6573728534eb..6573f0223478 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch +++ b/paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java +index f03f3c50990083492628cb28ae30a794f9110479..63ba05d7e0411bb6c9fde0e7c4dafa540eb1890d 100644 --- a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java +++ b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java -@@ -423,7 +_,7 @@ +@@ -423,7 +423,7 @@ public class ItemStackTheFlatteningFix extends DataFix { if (DAMAGE_IDS.contains(id.get().getSecond())) { Typed tag = input.getOrCreateTyped(tagF); Dynamic tagRest = tag.get(DSL.remainderFinder()); diff --git a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch b/paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch rename to paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch index f5ed75b9f4a5..ee2984f15225 100644 --- a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/InteractionResult.java b/net/minecraft/world/InteractionResult.java +index 0b28d3cf89a1d354715dd5be9e4edd7c1f54321c..0e1476109ad6c096aad11c896f77da88ac514378 100644 --- a/net/minecraft/world/InteractionResult.java +++ b/net/minecraft/world/InteractionResult.java -@@ -30,18 +_,34 @@ +@@ -30,18 +30,34 @@ public sealed interface InteractionResult public record Pass() implements InteractionResult { } diff --git a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch b/paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch rename to paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch index 9cacb279dc3b..1cbd4b534168 100644 --- a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/RandomizableContainer.java b/net/minecraft/world/RandomizableContainer.java +index bbc29d65f7e8cc6a193e67e2e9efce32664f5d21..9ab6a44c2847278d2ab30e936807f0e2bb9e56a8 100644 --- a/net/minecraft/world/RandomizableContainer.java +++ b/net/minecraft/world/RandomizableContainer.java -@@ -26,7 +_,7 @@ +@@ -26,7 +26,7 @@ public interface RandomizableContainer extends Container { void setLootTable(final @Nullable ResourceKey lootTable); @@ -9,7 +17,7 @@ this.setLootTable(lootTable); this.setLootTableSeed(seed); } -@@ -50,8 +_,9 @@ +@@ -50,8 +50,9 @@ public interface RandomizableContainer extends Container { default boolean tryLoadLootTable(final ValueInput base) { ResourceKey lootTable = base.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setLootTable(lootTable); @@ -20,7 +28,7 @@ } default boolean trySaveLootTable(final ValueOutput base) { -@@ -60,26 +_,42 @@ +@@ -60,26 +61,42 @@ public interface RandomizableContainer extends Container { return false; } else { base.store("LootTable", LootTable.KEY_CODEC, lootTable); @@ -65,7 +73,7 @@ LootParams.Builder params = new LootParams.Builder((ServerLevel)level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(worldPosition)); if (player != null) { params.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -88,4 +_,16 @@ +@@ -88,4 +105,16 @@ public interface RandomizableContainer extends Container { lootTable.fill(this, params.create(LootContextParamSets.CHEST), this.getLootTableSeed()); } } diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch b/paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch rename to paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch index a037d0743c48..e0cbc6fc72ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/effect/MobEffectInstance.java b/net/minecraft/world/effect/MobEffectInstance.java +index 4d1680e008848bc1db56db139c5138597e17a63b..24b870d1caade4d6bbf0c1bbb0e61a39e8f00d82 100644 --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -227,6 +_,7 @@ +@@ -227,6 +227,7 @@ public class MobEffectInstance implements Comparable { } else { int tickCount = this.isInfiniteDuration() ? target.tickCount : this.duration; if (this.effect.value().shouldApplyEffectTickThisTick(tickCount, this.amplifier) @@ -8,7 +16,7 @@ && !this.effect.value().applyEffectTick(serverLevel, target, this.amplifier)) { return false; } else { -@@ -262,13 +_,16 @@ +@@ -262,13 +263,16 @@ public class MobEffectInstance implements Comparable { } private boolean downgradeToHiddenEffect() { @@ -30,7 +38,7 @@ } public void onEffectStarted(final LivingEntity mob) { -@@ -425,7 +_,7 @@ +@@ -425,7 +429,7 @@ public class MobEffectInstance implements Comparable { .apply(i, MobEffectInstance.Details::create) ) ); @@ -39,7 +47,7 @@ subCodec -> StreamCodec.composite( ByteBufCodecs.VAR_INT, MobEffectInstance.Details::amplifier, -@@ -437,7 +_,7 @@ +@@ -437,7 +441,7 @@ public class MobEffectInstance implements Comparable { MobEffectInstance.Details::showParticles, ByteBufCodecs.BOOL, MobEffectInstance.Details::showIcon, diff --git a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch rename to paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch index 711b4be6fc30..ebc3962a15d8 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/effect/WeavingMobEffect.java b/net/minecraft/world/effect/WeavingMobEffect.java +index 411746c83970e7c05e239c08e3f74338fd9ce07c..ba774a4c307b7c94c8fa6183f263084260903dd8 100644 --- a/net/minecraft/world/effect/WeavingMobEffect.java +++ b/net/minecraft/world/effect/WeavingMobEffect.java -@@ -27,11 +_,11 @@ +@@ -27,11 +27,11 @@ class WeavingMobEffect extends MobEffect { @Override public void onMobRemoved(final ServerLevel level, final LivingEntity mob, final int amplifier, final Entity.RemovalReason reason) { if (reason == Entity.RemovalReason.KILLED && (mob instanceof Player || level.getGameRules().get(GameRules.MOB_GRIEFING))) { @@ -14,7 +22,7 @@ Set positionsToTransform = Sets.newHashSet(); int cobwebCount = this.maxCobwebs.applyAsInt(random); -@@ -48,6 +_,7 @@ +@@ -48,6 +48,7 @@ class WeavingMobEffect extends MobEffect { } for (BlockPos blockPosx : positionsToTransform) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch index cfc2d384c698..6ff9c4c59def 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8354b6889 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -168,6 +_,105 @@ +@@ -168,6 +168,105 @@ public abstract class Entity SlotProvider, DebugValueSource, TypedInstance> { @@ -106,7 +114,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -243,7 +_,7 @@ +@@ -243,7 +342,7 @@ public abstract class Entity public double yOld; public double zOld; public boolean noPhysics; @@ -115,7 +123,7 @@ public int tickCount; private int remainingFireTicks; private final EntityFluidInteraction fluidInteraction = new EntityFluidInteraction(Set.of(FluidTags.WATER, FluidTags.LAVA)); -@@ -278,7 +_,7 @@ +@@ -278,7 +377,7 @@ public abstract class Entity protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -124,7 +132,7 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -292,6 +_,7 @@ +@@ -292,6 +391,7 @@ public abstract class Entity public boolean hasVisualFire; private Vec3 lastKnownSpeed = Vec3.ZERO; private @Nullable Vec3 lastKnownPosition; @@ -132,7 +140,7 @@ private @Nullable BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; private final ArrayDeque movementThisTick = new ArrayDeque<>(100); -@@ -299,6 +_,40 @@ +@@ -299,6 +399,40 @@ public abstract class Entity private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -173,7 +181,7 @@ public Entity(final EntityType type, final Level level) { this.type = type; -@@ -320,6 +_,7 @@ +@@ -320,6 +454,7 @@ public abstract class Entity this.entityData = entityDataBuilder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -181,7 +189,7 @@ } public boolean isColliding(final BlockPos pos, final BlockState state) { -@@ -332,6 +_,12 @@ +@@ -332,6 +467,12 @@ public abstract class Entity return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -194,7 +202,7 @@ public boolean isSpectator() { return false; } -@@ -389,7 +_,7 @@ +@@ -389,7 +530,7 @@ public abstract class Entity } public boolean addTag(final String tag) { @@ -203,7 +211,7 @@ } public boolean removeTag(final String tag) { -@@ -397,12 +_,18 @@ +@@ -397,12 +538,18 @@ public abstract class Entity } public void kill(final ServerLevel level) { @@ -224,7 +232,7 @@ } protected abstract void defineSynchedData(SynchedEntityData.Builder entityData); -@@ -411,6 +_,48 @@ +@@ -411,6 +558,48 @@ public abstract class Entity return this.entityData; } @@ -273,7 +281,7 @@ @Override public boolean equals(final Object obj) { return obj instanceof Entity && ((Entity)obj).id == this.id; -@@ -422,7 +_,13 @@ +@@ -422,7 +611,13 @@ public abstract class Entity } public void remove(final Entity.RemovalReason reason) { @@ -288,7 +296,7 @@ } public void onClientRemoval() { -@@ -432,6 +_,15 @@ +@@ -432,6 +627,15 @@ public abstract class Entity } public void setPose(final Pose pose) { @@ -304,7 +312,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -454,7 +_,33 @@ +@@ -454,7 +658,33 @@ public abstract class Entity return Mth.lengthSquared(dx, dz) < Mth.square(distanceXZ) && Mth.square(dy) < Mth.square(distanceY); } @@ -339,7 +347,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -464,8 +_,8 @@ +@@ -464,8 +694,8 @@ public abstract class Entity } public void setPos(final double x, final double y, final double z) { @@ -350,7 +358,7 @@ } protected final AABB makeBoundingBox() { -@@ -499,12 +_,28 @@ +@@ -499,12 +729,28 @@ public abstract class Entity } public void tick() { @@ -379,7 +387,7 @@ this.computeSpeed(); this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -515,7 +_,7 @@ +@@ -515,7 +761,7 @@ public abstract class Entity this.boardingCooldown--; } @@ -388,7 +396,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -543,6 +_,10 @@ +@@ -543,6 +789,10 @@ public abstract class Entity if (this.isInLava()) { this.fallDistance *= 0.5; @@ -399,7 +407,7 @@ } this.checkBelowWorld(); -@@ -568,11 +_,16 @@ +@@ -568,11 +818,16 @@ public abstract class Entity } public void setSharedFlagOnFire(final boolean value) { @@ -418,7 +426,7 @@ this.onBelowWorld(); } } -@@ -600,15 +_,41 @@ +@@ -600,15 +855,41 @@ public abstract class Entity } public void lavaIgnite() { @@ -462,7 +470,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -623,6 +_,20 @@ +@@ -623,6 +904,20 @@ public abstract class Entity } public final void igniteForSeconds(final float numberOfSeconds) { @@ -483,7 +491,7 @@ this.igniteForTicks(Mth.floor(numberOfSeconds * 20.0F)); } -@@ -647,7 +_,7 @@ +@@ -647,7 +942,7 @@ public abstract class Entity } protected void onBelowWorld() { @@ -492,7 +500,7 @@ } public boolean isFree(final double xa, final double ya, final double za) { -@@ -703,7 +_,28 @@ +@@ -703,7 +998,28 @@ public abstract class Entity return this.onGround; } @@ -521,7 +529,7 @@ if (this.noPhysics) { this.setPos(this.getX() + delta.x, this.getY() + delta.y, this.getZ() + delta.z); this.horizontalCollision = false; -@@ -786,6 +_,27 @@ +@@ -786,6 +1102,27 @@ public abstract class Entity onBlock.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -549,7 +557,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission emission = this.getMovementEmission(); -@@ -799,6 +_,13 @@ +@@ -799,6 +1136,13 @@ public abstract class Entity profiler.pop(); } } @@ -563,7 +571,7 @@ } private void applyMovementEmissionAndPlaySound( -@@ -994,7 +_,7 @@ +@@ -994,7 +1338,7 @@ public abstract class Entity } protected BlockPos getOnPos(final float offset) { @@ -572,7 +580,7 @@ BlockPos getOnPos = this.mainSupportingBlockPos.get(); if (!(offset > 1.0E-5F)) { return getOnPos; -@@ -1263,7 +_,7 @@ +@@ -1263,7 +1607,7 @@ public abstract class Entity if (insideBlock) { try { boolean isPrecise = movedFar || deflatedBoundingBoxAtTarget.intersects(blockIntersection); @@ -581,7 +589,7 @@ state.entityInside(this.level(), blockIntersection, this, effectCollector, isPrecise); this.onInsideBlock(state); } catch (Throwable var20) { -@@ -1277,7 +_,7 @@ +@@ -1277,7 +1621,7 @@ public abstract class Entity } if (insideFluid) { @@ -590,7 +598,7 @@ state.getFluidState().entityInside(this.level(), blockIntersection, this, effectCollector); } -@@ -1690,6 +_,7 @@ +@@ -1690,6 +2034,7 @@ public abstract class Entity this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -598,7 +606,7 @@ } public void absSnapTo(final double x, final double y, final double z) { -@@ -1699,6 +_,7 @@ +@@ -1699,6 +2044,7 @@ public abstract class Entity this.yo = y; this.zo = cz; this.setPos(cx, y, cz); @@ -606,7 +614,7 @@ } public void snapTo(final Vec3 pos) { -@@ -1723,6 +_,7 @@ +@@ -1723,6 +2069,7 @@ public abstract class Entity this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -614,7 +622,7 @@ } public final void setOldPosAndRot() { -@@ -1789,6 +_,7 @@ +@@ -1789,6 +2136,7 @@ public abstract class Entity public void push(final Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -622,7 +630,7 @@ double xa = entity.getX() - this.getX(); double za = entity.getZ() - this.getZ(); double dd = Mth.absMax(xa, za); -@@ -1824,8 +_,24 @@ +@@ -1824,8 +2172,24 @@ public abstract class Entity } public void push(final double xa, final double ya, final double za) { @@ -648,7 +656,7 @@ this.needsSync = true; } } -@@ -1932,8 +_,20 @@ +@@ -1932,9 +2296,21 @@ public abstract class Entity } public boolean isPushable() { @@ -660,16 +668,17 @@ + // Paper end - Climbing should not bypass cramming gamerule return false; } -+ + + // CraftBukkit start - collidable API + public boolean canCollideWithBukkit(Entity entity) { + return this.isPushable(); + } + // CraftBukkit end - ++ public void awardKillScore(final Entity victim, final DamageSource killingBlow) { if (victim instanceof ServerPlayer) { -@@ -1960,15 +_,23 @@ + CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer)victim, this, killingBlow); +@@ -1960,15 +2336,23 @@ public abstract class Entity } public boolean saveAsPassenger(final ValueOutput output) { @@ -697,7 +706,7 @@ return true; } } -@@ -1979,14 +_,34 @@ +@@ -1979,14 +2363,34 @@ public abstract class Entity } public void saveWithoutId(final ValueOutput output) { @@ -732,7 +741,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1994,7 +_,29 @@ +@@ -1994,7 +2398,29 @@ public abstract class Entity output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -762,17 +771,16 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -2017,9 +_,14 @@ +@@ -2017,9 +2443,14 @@ public abstract class Entity output.putInt("TicksFrozen", this.getTicksFrozen()); } - if (this.hasVisualFire) { - output.putBoolean("HasVisualFire", this.hasVisualFire); -- } + // Paper start - improve visual fire API + if (this.visualFire.equals(net.kyori.adventure.util.TriState.TRUE)) { + output.putBoolean("HasVisualFire", true); -+ } + } + if (this.visualFire != net.kyori.adventure.util.TriState.NOT_SET) { + output.putString("Paper.FireOverride", visualFire.name()); + } @@ -780,7 +788,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -2029,13 +_,13 @@ +@@ -2029,13 +2460,13 @@ public abstract class Entity output.store("data", CustomData.CODEC, this.customData); } @@ -796,7 +804,7 @@ passengersList.discardLast(); } } -@@ -2044,6 +_,34 @@ +@@ -2044,6 +2475,34 @@ public abstract class Entity output.discard("Passengers"); } } @@ -831,7 +839,7 @@ } catch (Throwable var7) { CrashReport report = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory category = report.addCategory("Entity being saved"); -@@ -2089,7 +_,20 @@ +@@ -2089,7 +2548,20 @@ public abstract class Entity this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -853,7 +861,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2100,6 +_,59 @@ +@@ -2100,6 +2572,59 @@ public abstract class Entity } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -913,7 +921,7 @@ } catch (Throwable var7) { CrashReport report = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory category = report.addCategory("Entity being loaded"); -@@ -2113,7 +_,13 @@ +@@ -2113,7 +2638,13 @@ public abstract class Entity } public final @Nullable String getEncodeId() { @@ -928,7 +936,7 @@ return null; } else { ResourceKey> typeId = this.typeHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Unregistered entity")); -@@ -2123,6 +_,12 @@ +@@ -2123,6 +2654,12 @@ public abstract class Entity protected abstract void readAdditionalSaveData(ValueInput input); @@ -941,7 +949,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemLike resource) { -@@ -2134,11 +_,59 @@ +@@ -2134,11 +2671,59 @@ public abstract class Entity } public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemStack itemStack, final Vec3 offset) { @@ -1002,7 +1010,7 @@ level.addFreshEntity(entity); return entity; } -@@ -2183,6 +_,15 @@ +@@ -2183,6 +2768,15 @@ public abstract class Entity for (Leashable mob : mobsToLeash) { if (mob.canHaveALeashAttachedTo(this)) { @@ -1018,7 +1026,7 @@ mob.setLeashedTo(this, true); anyLeashed = true; } -@@ -2197,7 +_,7 @@ +@@ -2197,7 +2791,7 @@ public abstract class Entity } ItemStack heldItem = player.getItemInHand(hand); @@ -1027,7 +1035,7 @@ heldItem.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob target -@@ -2210,11 +_,13 @@ +@@ -2210,11 +2804,13 @@ public abstract class Entity if (this.isAlive() && this instanceof Leashable leashablex) { if (leashablex.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1045,7 +1053,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2231,9 +_,22 @@ +@@ -2231,9 +2827,22 @@ public abstract class Entity if (leashablex.canHaveALeashAttachedTo(player)) { if (leashablex.isLeashed()) { @@ -1069,7 +1077,7 @@ leashablex.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemStack.shrink(1); -@@ -2247,7 +_,13 @@ +@@ -2247,7 +2856,13 @@ public abstract class Entity } public boolean shearOffAllLeashConnections(final @Nullable Player player) { @@ -1084,7 +1092,7 @@ if (dropped && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2256,15 +_,39 @@ +@@ -2256,15 +2871,39 @@ public abstract class Entity } public boolean dropAllLeashConnections(final @Nullable Player player) { @@ -1128,7 +1136,7 @@ } if (dropped) { -@@ -2288,7 +_,9 @@ +@@ -2288,7 +2927,9 @@ public abstract class Entity this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1138,7 +1146,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemStack, target); } -@@ -2356,11 +_,11 @@ +@@ -2356,11 +2997,11 @@ public abstract class Entity } public boolean startRiding(final Entity entityToRide, final boolean force, final boolean sendEventAndTriggers) { @@ -1152,7 +1160,7 @@ return false; } else { for (Entity vehicleEntity = entityToRide; vehicleEntity.vehicle != null; vehicleEntity = vehicleEntity.vehicle) { -@@ -2370,6 +_,27 @@ +@@ -2370,6 +3011,27 @@ public abstract class Entity } if (force || this.canRide(entityToRide) && entityToRide.canAddPassenger(this)) { @@ -1180,7 +1188,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2402,10 +_,16 @@ +@@ -2402,10 +3064,16 @@ public abstract class Entity } public void removeVehicle() { @@ -1198,7 +1206,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, oldVehicle.position); -@@ -2414,7 +_,13 @@ +@@ -2414,7 +3082,13 @@ public abstract class Entity } public void stopRiding() { @@ -1213,7 +1221,7 @@ } protected void addPassenger(final Entity passenger) { -@@ -2436,10 +_,44 @@ +@@ -2436,10 +3110,44 @@ public abstract class Entity } } @@ -1259,7 +1267,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2448,6 +_,7 @@ +@@ -2448,6 +3156,7 @@ public abstract class Entity passenger.boardingCooldown = 60; } @@ -1267,7 +1275,7 @@ } protected boolean canAddPassenger(final Entity passenger) { -@@ -2630,7 +_,7 @@ +@@ -2630,7 +3339,7 @@ public abstract class Entity } public boolean isCrouching() { @@ -1276,7 +1284,7 @@ } public boolean isSprinting() { -@@ -2646,7 +_,7 @@ +@@ -2646,7 +3355,7 @@ public abstract class Entity } public boolean isVisuallySwimming() { @@ -1285,7 +1293,7 @@ } public boolean isVisuallyCrawling() { -@@ -2654,6 +_,13 @@ +@@ -2654,6 +3363,13 @@ public abstract class Entity } public void setSwimming(final boolean swimming) { @@ -1299,7 +1307,7 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2691,6 +_,7 @@ +@@ -2691,6 +3407,7 @@ public abstract class Entity } public @Nullable PlayerTeam getTeam() { @@ -1307,7 +1315,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2707,7 +_,11 @@ +@@ -2707,7 +3424,11 @@ public abstract class Entity } public void setInvisible(final boolean invisible) { @@ -1320,7 +1328,7 @@ } public boolean getSharedFlag(@Entity.Flags final int flag) { -@@ -2724,7 +_,7 @@ +@@ -2724,7 +3445,7 @@ public abstract class Entity } public int getMaxAirSupply() { @@ -1329,7 +1337,7 @@ } public int getAirSupply() { -@@ -2732,10 +_,24 @@ +@@ -2732,10 +3453,24 @@ public abstract class Entity } public void setAirSupply(final int supply) { @@ -1355,7 +1363,7 @@ this.setTicksFrozen(0); } -@@ -2762,11 +_,42 @@ +@@ -2762,11 +3497,42 @@ public abstract class Entity public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1366,9 +1374,6 @@ + // CraftBukkit end if (this.remainingFireTicks == 0) { - this.igniteForSeconds(8.0F); -- } -- -- this.hurtServer(level, this.damageSources().lightningBolt(), 5.0F); + // CraftBukkit start - Call a combust event when lightning strikes + org.bukkit.event.entity.EntityCombustByEntityEvent entityCombustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F); + pluginManager.callEvent(entityCombustEvent); @@ -1380,8 +1385,9 @@ + // Paper end - fix EntityCombustEvent cancellation + } + // CraftBukkit end -+ } -+ + } + +- this.hurtServer(level, this.damageSources().lightningBolt(), 5.0F); + // CraftBukkit start + final DamageSource damageSource = this.damageSources().lightningBolt().eventEntityDamager(lightningBolt); + if (thisBukkitEntity instanceof org.bukkit.entity.Hanging) { @@ -1402,7 +1408,7 @@ } public void onAboveBubbleColumn(final boolean dragDown, final BlockPos pos) { -@@ -2916,26 +_,30 @@ +@@ -2916,26 +3682,30 @@ public abstract class Entity return this.removalReason != null ? String.format( Locale.ROOT, @@ -1436,7 +1442,7 @@ ); } -@@ -2959,6 +_,13 @@ +@@ -2959,6 +3729,13 @@ public abstract class Entity } public void restoreFrom(final Entity oldEntity) { @@ -1450,7 +1456,7 @@ try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput entityData = TagValueOutput.createWithContext(reporter, oldEntity.registryAccess()); oldEntity.saveWithoutId(entityData); -@@ -2969,8 +_,66 @@ +@@ -2969,8 +3746,66 @@ public abstract class Entity this.portalProcess = oldEntity.portalProcess; } @@ -1518,7 +1524,7 @@ ServerLevel newLevel = transition.newLevel(); boolean otherDimension = newLevel.dimension() != serverLevel.dimension(); if (!transition.asPassenger()) { -@@ -3019,10 +_,15 @@ +@@ -3019,10 +3854,15 @@ public abstract class Entity profiler.pop(); return null; } else { @@ -1535,7 +1541,7 @@ for (Entity newPassenger : newPassengers) { newPassenger.startRiding(newEntity, true, false); -@@ -3109,9 +_,17 @@ +@@ -3109,9 +3949,17 @@ public abstract class Entity } protected void removeAfterChangingDimensions() { @@ -1556,7 +1562,7 @@ } if (this instanceof WaypointTransmitter waypoint && this.level instanceof ServerLevel serverLevel) { -@@ -3128,6 +_,7 @@ +@@ -3128,6 +3976,7 @@ public abstract class Entity } public boolean canTeleport(final Level from, final Level to) { @@ -1564,7 +1570,7 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { for (Entity passenger : this.getPassengers()) { if (passenger instanceof ServerPlayer player && !player.seenCredits) { -@@ -3246,7 +_,7 @@ +@@ -3246,7 +4095,7 @@ public abstract class Entity } } @@ -1573,7 +1579,7 @@ final ServerLevel level, final double x, final double y, -@@ -3256,14 +_,30 @@ +@@ -3256,14 +4105,30 @@ public abstract class Entity final float newXRot, final boolean resetCamera ) { @@ -1606,7 +1612,7 @@ } public void teleportTo(final double x, final double y, final double z) { -@@ -3374,7 +_,26 @@ +@@ -3374,7 +4239,26 @@ public abstract class Entity } public final void setBoundingBox(final AABB bb) { @@ -1634,7 +1640,7 @@ } public final float getEyeHeight(final Pose pose) { -@@ -3398,6 +_,12 @@ +@@ -3398,6 +4282,12 @@ public abstract class Entity } public void stopSeenByPlayer(final ServerPlayer player) { @@ -1647,7 +1653,7 @@ } public float rotate(final Rotation rotation) { -@@ -3456,21 +_,32 @@ +@@ -3456,21 +4346,32 @@ public abstract class Entity } private Stream getIndirectPassengersStream() { @@ -1681,7 +1687,7 @@ } public int countPlayerPassengers() { -@@ -3478,6 +_,7 @@ +@@ -3478,6 +4379,7 @@ public abstract class Entity } public boolean hasExactlyOnePlayerPassenger() { @@ -1689,7 +1695,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3558,9 +_,38 @@ +@@ -3558,9 +4460,38 @@ public abstract class Entity return 0; } @@ -1729,7 +1735,7 @@ this.position(), this.getRotationVector(), level, -@@ -3658,7 +_,9 @@ +@@ -3658,7 +4589,9 @@ public abstract class Entity public void setDeltaMovement(final Vec3 deltaMovement) { if (deltaMovement.isFinite()) { @@ -1739,7 +1745,7 @@ } } -@@ -3729,8 +_,34 @@ +@@ -3729,8 +4662,34 @@ public abstract class Entity } public final void setPosRaw(final double x, final double y, final double z) { @@ -1774,11 +1780,10 @@ int fx = Mth.floor(x); int fy = Mth.floor(y); int fz = Mth.floor(z); -@@ -3752,7 +_,18 @@ +@@ -3752,7 +4711,18 @@ public abstract class Entity serverLevel.getWaypointManager().updatePlayer(player); } } -- } + // Paper start - Fix MC-44654 + if (this.getType().updateInterval() == Integer.MAX_VALUE) { + this.needsSync = true; @@ -1789,12 +1794,12 @@ + // hanging has its own special logic + if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (forceBoundingBoxUpdate || this.position.x != x || this.position.y != y || this.position.z != z)) { + this.setBoundingBox(this.makeBoundingBox()); -+ } + } + // Paper end - Block invalid positions and bounding box } public void checkDespawn() { -@@ -3804,6 +_,12 @@ +@@ -3804,6 +4774,12 @@ public abstract class Entity return this.getTicksFrozen() > 0; } @@ -1807,7 +1812,7 @@ public float getYRot() { return this.yRot; } -@@ -3854,7 +_,9 @@ +@@ -3854,7 +4830,9 @@ public abstract class Entity } @Override @@ -1818,7 +1823,7 @@ if (this.removalReason == null) { this.removalReason = reason; } -@@ -3866,12 +_,28 @@ +@@ -3866,12 +4844,28 @@ public abstract class Entity this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(reason); this.onRemoval(reason); @@ -1847,7 +1852,7 @@ @Override public void setLevelCallback(final EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4093,4 +_,14 @@ +@@ -4093,4 +5087,14 @@ public abstract class Entity return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch index c63e98f57f82..edaf16a29ab2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,14 +1,23 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ExperienceOrb.java b/net/minecraft/world/entity/ExperienceOrb.java +index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d2b3e0ccf 100644 --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -43,13 +_,57 @@ +@@ -43,13 +43,57 @@ public class ExperienceOrb extends Entity { public int count = 1; private @Nullable Player followingPlayer; private final InterpolationHandler interpolation = new InterpolationHandler(this); +- + // Paper start + public java.util.@Nullable UUID sourceEntityId; + public java.util.@Nullable UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; - ++ + private void loadPaperNBT(ValueInput input) { + input.read("Paper.ExpData", net.minecraft.nbt.CompoundTag.CODEC).ifPresent(expData -> { + this.sourceEntityId = expData.read("source", net.minecraft.core.UUIDUtil.CODEC).orElse(null); @@ -59,7 +68,7 @@ this.setPos(pos); if (!level.isClientSide()) { this.setYRot(this.random.nextFloat() * 360.0F); -@@ -146,12 +_,13 @@ +@@ -146,12 +190,13 @@ public class ExperienceOrb extends Entity { this.age++; if (this.age >= 6000) { @@ -74,7 +83,7 @@ if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); if (nearestPlayer != null && !nearestPlayer.isSpectator() && !nearestPlayer.isDeadOrDying()) { -@@ -161,7 +_,24 @@ +@@ -161,7 +206,24 @@ public class ExperienceOrb extends Entity { } } @@ -100,7 +109,7 @@ Vec3 delta = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -191,18 +_,24 @@ +@@ -191,18 +253,24 @@ public class ExperienceOrb extends Entity { } public static void awardWithDirection(final ServerLevel level, final Vec3 pos, final Vec3 roughDirection, int amount) { @@ -127,7 +136,7 @@ List orbs = level.getEntities(EntityTypeTest.forClass(ExperienceOrb.class), box, orbx -> canMerge(orbx, id, value)); if (!orbs.isEmpty()) { ExperienceOrb orb = orbs.get(0); -@@ -219,13 +_,18 @@ +@@ -219,13 +287,18 @@ public class ExperienceOrb extends Entity { } private static boolean canMerge(final ExperienceOrb orb, final int id, final int value) { @@ -148,7 +157,7 @@ } private void setUnderwaterMovement() { -@@ -250,7 +_,7 @@ +@@ -250,7 +323,7 @@ public class ExperienceOrb extends Entity { this.markHurt(); this.health = (int)(this.health - damage); if (this.health <= 0) { @@ -157,7 +166,7 @@ } return true; -@@ -261,32 +_,34 @@ +@@ -261,32 +334,34 @@ public class ExperienceOrb extends Entity { protected void addAdditionalSaveData(final ValueOutput output) { output.putShort("Health", (short)this.health); output.putShort("Age", (short)this.age); @@ -198,7 +207,7 @@ } } } -@@ -298,9 +_,19 @@ +@@ -298,9 +373,19 @@ public class ExperienceOrb extends Entity { ItemStack itemStack = selected.get().itemStack(); int toRepairFromXpAmount = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemStack, amount); int repair = Math.min(toRepairFromXpAmount, itemStack.getDamageValue()); @@ -219,7 +228,7 @@ if (remaining > 0) { return this.repairPlayerItems(player, remaining); } -@@ -346,6 +_,24 @@ +@@ -346,6 +431,24 @@ public class ExperienceOrb extends Entity { } public static int getExperienceValue(final int maxValue) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch index 1666a8003cf8..eb7fd4935f55 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/InsideBlockEffectType.java b/net/minecraft/world/entity/InsideBlockEffectType.java +index 56c7c5025db50d78f3c532b3d821028a8d904298..d2e967831d08af16cb08741fad89e2e0e532744a 100644 --- a/net/minecraft/world/entity/InsideBlockEffectType.java +++ b/net/minecraft/world/entity/InsideBlockEffectType.java -@@ -6,22 +_,35 @@ +@@ -6,22 +6,35 @@ import net.minecraft.world.level.block.BaseFireBlock; public enum InsideBlockEffectType { FREEZE(entity -> { entity.setIsInPowderSnow(true); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch index e6413834b5a7..6f69f0d771cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9bc749f28b 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -140,6 +_,17 @@ +@@ -140,6 +140,17 @@ import org.jetbrains.annotations.Contract; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -18,7 +26,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -269,11 +_,25 @@ +@@ -269,11 +280,25 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); public @Nullable Vec3 currentImpulseImpactPos; public @Nullable Entity currentExplosionCause; @@ -45,7 +53,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -365,7 +_,13 @@ +@@ -365,7 +390,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin double scale = Math.min(0.2F + power / 15.0, 2.5); int particles = (int)(150.0 * scale); @@ -59,7 +67,7 @@ } } -@@ -550,7 +_,7 @@ +@@ -550,7 +581,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -68,7 +76,7 @@ } } -@@ -652,7 +_,7 @@ +@@ -652,7 +683,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public boolean shouldDiscardFriction() { @@ -77,7 +85,7 @@ } public void setDiscardFriction(final boolean discardFriction) { -@@ -664,10 +_,15 @@ +@@ -664,10 +695,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void onEquipItem(final EquipmentSlot slot, final ItemStack oldStack, final ItemStack stack) { @@ -94,7 +102,7 @@ this.level() .playSeededSound( null, -@@ -694,12 +_,12 @@ +@@ -694,12 +730,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } @Override @@ -109,7 +117,7 @@ this.brain.clearMemories(); } -@@ -716,11 +_,17 @@ +@@ -716,11 +752,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin effect.onMobRemoved(level, this, reason); } @@ -127,7 +135,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -755,7 +_,12 @@ +@@ -755,7 +797,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -141,7 +149,7 @@ if (itemStack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -764,6 +_,31 @@ +@@ -764,6 +811,31 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } else { ItemEntity entity = this.createItemStackToDrop(itemStack, randomly, thrownFromHand); if (entity != null) { @@ -173,7 +181,7 @@ this.level().addFreshEntity(entity); } -@@ -773,7 +_,22 @@ +@@ -773,7 +845,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Override protected void readAdditionalSaveData(final ValueInput input) { @@ -197,7 +205,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -786,6 +_,11 @@ +@@ -786,6 +873,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.effectsDirty = true; } @@ -209,7 +217,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -793,6 +_,7 @@ +@@ -793,6 +885,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin input.getString("Team").ifPresent(teamName -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam team = scoreboard.getPlayerTeam(teamName); @@ -217,7 +225,7 @@ boolean success = team != null && scoreboard.addPlayerToTeam(this.getStringUUID(), team); if (!success) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", teamName); -@@ -800,11 +_,13 @@ +@@ -800,11 +893,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(sleepingPos -> { @@ -231,7 +239,7 @@ }, this::clearSleepingPos); input.read("Brain", Brain.Packed.CODEC).ifPresent(packedBrain -> this.brain = this.makeBrain(packedBrain)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -823,15 +_,44 @@ +@@ -823,15 +918,44 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.updateDirtyEffects(); } @@ -276,7 +284,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(effect)); } else if (effect.getDuration() % 600 == 0) { -@@ -840,6 +_,18 @@ +@@ -840,6 +964,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } catch (ConcurrentModificationException var6) { } @@ -295,7 +303,7 @@ } else { for (MobEffectInstance effect : this.activeEffects.values()) { effect.tickClient(); -@@ -950,15 +_,33 @@ +@@ -950,15 +1086,33 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public boolean removeAllEffects() { @@ -333,7 +341,7 @@ } } -@@ -984,23 +_,71 @@ +@@ -984,23 +1138,71 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public final boolean addEffect(final MobEffectInstance newEffect) { @@ -407,7 +415,7 @@ } newEffect.onEffectStarted(this); -@@ -1035,11 +_,35 @@ +@@ -1035,11 +1237,35 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public final @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect) { @@ -444,7 +452,7 @@ if (effectInstance != null) { this.onEffectsRemoved(List.of(effectInstance)); return true; -@@ -1130,17 +_,62 @@ +@@ -1130,17 +1356,62 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void heal(final float heal) { @@ -509,7 +517,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1152,7 +_,7 @@ +@@ -1152,7 +1423,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public boolean hurtServer(final ServerLevel level, final DamageSource source, float damage) { if (this.isInvulnerableTo(level, source)) { return false; @@ -518,7 +526,7 @@ return false; } else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1168,35 +_,58 @@ +@@ -1168,35 +1439,58 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin ItemStack itemInUse = this.getUseItem(); float originalDamage = damage; @@ -585,7 +593,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1211,7 +_,7 @@ +@@ -1211,7 +1505,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin level.broadcastDamageEvent(this, source); } @@ -594,7 +602,7 @@ this.markHurt(); } -@@ -1226,8 +_,16 @@ +@@ -1226,8 +1520,16 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin xd = source.getSourcePosition().x() - this.getX(); zd = source.getSourcePosition().z() - this.getZ(); } @@ -612,7 +620,7 @@ if (!blocked) { this.indicateDamage(xd, zd); } -@@ -1236,19 +_,19 @@ +@@ -1236,19 +1538,19 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(source)) { @@ -637,7 +645,7 @@ if (success) { this.lastDamageSource = source; this.lastDamageStamp = this.level().getGameTime(); -@@ -1274,6 +_,12 @@ +@@ -1274,6 +1576,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public float applyItemBlocking(final ServerLevel level, final DamageSource source, final float damage) { @@ -650,7 +658,7 @@ if (damage <= 0.0F) { return 0.0F; } else { -@@ -1298,10 +_,12 @@ +@@ -1298,10 +1606,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } float damageBlocked = blocksAttacks.resolveBlockedDamage(source, damage, angle); @@ -664,7 +672,7 @@ return damageBlocked; } -@@ -1312,6 +_,59 @@ +@@ -1312,6 +1622,59 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -724,7 +732,7 @@ public void playSecondaryHurtSound(final DamageSource source) { if (source.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1343,12 +_,24 @@ +@@ -1343,12 +1706,24 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -750,7 +758,7 @@ } private boolean checkTotemDeathProtection(final DamageSource killingDamage) { -@@ -1358,18 +_,39 @@ +@@ -1358,18 +1733,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin ItemStack protectionItem = null; DeathProtection protection = null; @@ -764,11 +772,14 @@ if (protection != null) { + usedHand = hand; protectionItem = itemStack.copy(); +- itemStack.shrink(1); + // itemStack.shrink(1); -+ break; -+ } -+ } -+ + break; + } + } + +- if (protectionItem != null) { +- if (this instanceof ServerPlayer player) { + final org.bukkit.inventory.EquipmentSlot handSlot = (usedHand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(usedHand) : null; + final EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot); + event.setCancelled(protectionItem == null); @@ -778,13 +789,7 @@ + protection = null; + } else { + if (!itemStack.isEmpty() && protectionItem != null) { // Paper - only reduce item if actual totem was found - itemStack.shrink(1); -- break; -- } -- } -- -- if (protectionItem != null) { -- if (this instanceof ServerPlayer player) { ++ itemStack.shrink(1); + } + // Paper start - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled + // restore the previous behavior in that case by defaulting to vanilla's totem of undying effect @@ -797,7 +802,7 @@ player.awardStat(Stats.ITEM_USED.get(protectionItem.getItem())); CriteriaTriggers.USED_TOTEM.trigger(player, protectionItem); protectionItem.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); -@@ -1420,6 +_,7 @@ +@@ -1420,6 +1816,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin if (!this.isRemoved() && !this.dead) { Entity sourceEntity = source.getEntity(); LivingEntity killer = this.getKillCredit(); @@ -805,7 +810,7 @@ if (killer != null) { killer.awardKillScore(this, source); } -@@ -1430,68 +_,147 @@ +@@ -1430,68 +1827,147 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { @@ -951,7 +956,6 @@ || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().get(GameRules.MOB_DROPS) )) { - ExperienceOrb.award(level, this.position(), this.getExperienceReward(level, killer)); -- } + return this.getExperienceReward(level, killer); // CraftBukkit + } + return 0; // CraftBukkit @@ -962,12 +966,12 @@ + if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time + ExperienceOrb.awardWithDirection(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, this.expToDrop, this instanceof ServerPlayer ? org.bukkit.entity.ExperienceOrb.SpawnReason.PLAYER_DEATH : org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, entity, this); // Paper + this.expToDrop = 0; -+ } + } + // CraftBukkit end } protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { -@@ -1603,9 +_,14 @@ +@@ -1603,9 +2079,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void knockback(double power, double xd, double zd) { @@ -984,7 +988,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (xd * xd + zd * zd < 1.0E-5F) { -@@ -1614,11 +_,22 @@ +@@ -1614,11 +2095,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } Vec3 deltaVector = new Vec3(xd, 0.0, zd).normalize().scale(power); @@ -1008,7 +1012,7 @@ } } -@@ -1709,7 +_,7 @@ +@@ -1709,7 +2201,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Override public boolean isAlive() { @@ -1017,7 +1021,7 @@ } public boolean isLookingAtMe( -@@ -1764,10 +_,15 @@ +@@ -1764,10 +2256,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin boolean damaged = super.causeFallDamage(effectiveFallDistance, damageModifier, damageSource); int dmg = this.calculateFallDamage(effectiveFallDistance, damageModifier); if (dmg > 0) { @@ -1034,7 +1038,7 @@ return true; } else { return damaged; -@@ -1865,7 +_,7 @@ +@@ -1865,7 +2362,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected float getDamageAfterArmorAbsorb(final DamageSource damageSource, float damage) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1043,7 +1047,7 @@ damage = CombatRules.getDamageAfterAbsorb( this, damage, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1878,7 +_,8 @@ +@@ -1878,7 +2375,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damage; } else { @@ -1053,7 +1057,7 @@ int absorbValue = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int absorb = 25 - absorbValue; float v = damage * absorb; -@@ -1915,24 +_,181 @@ +@@ -1915,24 +2413,181 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -1245,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1960,7 +_,17 @@ +@@ -1960,7 +2615,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public final void setArrowCount(final int count) { @@ -1264,7 +1268,7 @@ } public final int getStingerCount() { -@@ -2010,7 +_,7 @@ +@@ -2010,7 +2675,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Override public void handleDamageEvent(final DamageSource source) { this.walkAnimation.setSpeed(1.5F); @@ -1273,7 +1277,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(source); -@@ -2139,7 +_,7 @@ +@@ -2139,7 +2804,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Override protected void onBelowWorld() { @@ -1282,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2246,7 +_,13 @@ +@@ -2246,7 +2911,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void setItemSlot(final EquipmentSlot slot, final ItemStack itemStack) { @@ -1297,7 +1301,7 @@ } public float getArmorCoverPercentage() { -@@ -2339,14 +_,27 @@ +@@ -2339,14 +3010,27 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1325,7 +1329,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(angle) * 0.2, 0.0, Mth.cos(angle) * 0.2)); } -@@ -2533,8 +_,10 @@ +@@ -2533,8 +3217,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void stopFallFlying() { @@ -1336,7 +1340,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 movement) { -@@ -2678,7 +_,7 @@ +@@ -2678,7 +3364,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public void causeExtraKnockback(final Entity target, final float knockback, final Vec3 oldMovement) { if (knockback > 0.0F && target instanceof LivingEntity livingTarget) { @@ -1345,7 +1349,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2754,37 +_,15 @@ +@@ -2754,37 +3440,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin profiler.pop(); profiler.push("rangeChecks"); @@ -1356,15 +1360,19 @@ - while (this.getYRot() - this.yRotO >= 180.0F) { - this.yRotO += 360.0F; - } -- ++ // Paper start - stop large pitch and yaw changes from crashing the server ++ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; + - while (this.yBodyRot - this.yBodyRotO < -180.0F) { - this.yBodyRotO -= 360.0F; - } -- ++ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; + - while (this.yBodyRot - this.yBodyRotO >= 180.0F) { - this.yBodyRotO += 360.0F; - } -- ++ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; + - while (this.getXRot() - this.xRotO < -180.0F) { - this.xRotO -= 360.0F; - } @@ -1380,19 +1388,12 @@ - while (this.yHeadRot - this.yHeadRotO >= 180.0F) { - this.yHeadRotO += 360.0F; - } -+ // Paper start - stop large pitch and yaw changes from crashing the server -+ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; -+ -+ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; -+ -+ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; -+ + this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; + // Paper end - stop large pitch and yaw changes from crashing the server profiler.pop(); if (this.isFallFlying()) { -@@ -2865,6 +_,11 @@ +@@ -2865,6 +3529,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void onAttack() { @@ -1404,7 +1405,7 @@ } public void detectEquipmentUpdates() { -@@ -2879,16 +_,39 @@ +@@ -2879,16 +3548,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin private @Nullable Map collectEquipmentChanges() { Map changedItems = null; @@ -1444,7 +1445,7 @@ AttributeMap attributes = this.getAttributes(); if (!previous.isEmpty()) { this.stopLocationBasedEffects(previous, slot, attributes); -@@ -2913,6 +_,8 @@ +@@ -2913,6 +3605,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } } @@ -1453,7 +1454,7 @@ } return changedItems; -@@ -2944,7 +_,7 @@ +@@ -2944,7 +3638,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin itemsToSend.add(Pair.of(slot, newItemToStore)); this.lastEquipmentItems.put(slot, newItemToStore); }); @@ -1462,7 +1463,7 @@ } protected void tickHeadTurn(final float yBodyRotT) { -@@ -3030,8 +_,10 @@ +@@ -3030,8 +3724,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin if (!inWaterAndHasFluidHeight || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || inWaterAndHasFluidHeight && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1473,7 +1474,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -3072,7 +_,7 @@ +@@ -3072,7 +3768,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin profiler.pop(); if (this.level() instanceof ServerLevel serverLevel) { profiler.push("freezing"); @@ -1482,7 +1483,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -3093,6 +_,20 @@ +@@ -3093,6 +3789,20 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.pushEntities(); profiler.pop(); @@ -1503,7 +1504,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3115,6 +_,7 @@ +@@ -3115,6 +3825,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1511,7 +1512,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3151,10 +_,25 @@ +@@ -3151,10 +3862,25 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } protected void pushEntities() { @@ -1538,7 +1539,7 @@ if (maxCramming > 0 && pushableEntities.size() > maxCramming - 1 && this.random.nextInt(4) == 0) { int count = 0; -@@ -3170,7 +_,16 @@ +@@ -3170,7 +3896,16 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -1555,7 +1556,7 @@ this.doPush(entityx); } } -@@ -3179,16 +_,32 @@ +@@ -3179,16 +3914,32 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void checkAutoSpinAttack(final AABB old, final AABB current) { AABB minmax = old.minmax(current); List entities = this.level().getEntities(this, minmax); @@ -1589,7 +1590,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3211,10 +_,10 @@ +@@ -3211,10 +3962,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } @Override @@ -1603,7 +1604,7 @@ this.dismountVehicle(oldVehicle); } } -@@ -3241,7 +_,7 @@ +@@ -3241,7 +3992,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void onItemPickup(final ItemEntity entity) { @@ -1612,7 +1613,7 @@ if (thrower instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)thrower, entity.getItem(), this); } -@@ -3253,7 +_,7 @@ +@@ -3253,7 +4004,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1621,7 +1622,7 @@ } } -@@ -3269,7 +_,8 @@ +@@ -3269,7 +4020,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } else { Vec3 from = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 to = new Vec3(target.getX(), eyeHeight, target.getZ()); @@ -1631,7 +1632,7 @@ && this.level().clip(new ClipContext(from, to, blockCollidingContext, fluidCollidingContext, this)).getType() == HitResult.Type.MISS; } } -@@ -3290,13 +_,27 @@ +@@ -3290,14 +4042,28 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Override public boolean isPickable() { @@ -1643,10 +1644,9 @@ @Override public boolean isPushable() { - return this.isAlive() && !this.isSpectator() && !this.onClimbable(); -- } + return this.isCollidable(this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule); -+ } -+ + } + + @Override + public boolean isCollidable(boolean ignoreClimbing) { + return this.isAlive() && !this.isSpectator() && (ignoreClimbing || !this.onClimbable()) && this.collides; // CraftBukkit @@ -1659,10 +1659,11 @@ + return this.isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); + } + // CraftBukkit end - ++ @Override public float getYHeadRot() { -@@ -3327,7 +_,7 @@ + return this.yHeadRot; +@@ -3327,7 +4093,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public final void setAbsorptionAmount(final float absorptionAmount) { @@ -1671,7 +1672,7 @@ } protected void internalSetAbsorptionAmount(final float absorptionAmount) { -@@ -3354,6 +_,15 @@ +@@ -3354,6 +4120,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1687,7 +1688,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3401,7 +_,12 @@ +@@ -3401,7 +4176,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void updateUsingItem(final ItemStack useItem) { useItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1701,7 +1702,7 @@ this.completeUsingItem(); } } -@@ -3427,10 +_,19 @@ +@@ -3427,10 +4207,19 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void startUsingItem(final InteractionHand hand) { @@ -1723,7 +1724,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3457,7 +_,10 @@ +@@ -3457,7 +4246,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1735,7 +1736,7 @@ } } } -@@ -3500,9 +_,41 @@ +@@ -3500,9 +4292,41 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1778,7 +1779,7 @@ } this.stopUsingItem(); -@@ -3534,6 +_,7 @@ +@@ -3534,6 +4358,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin ItemStack itemInUsedHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInUsedHand, this.useItem)) { this.useItem = itemInUsedHand; @@ -1786,7 +1787,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3554,7 +_,10 @@ +@@ -3554,7 +4379,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } this.useItem = ItemStack.EMPTY; @@ -1798,7 +1799,7 @@ } public boolean isBlocking() { -@@ -3577,6 +_,60 @@ +@@ -3577,6 +4405,60 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -1859,7 +1860,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3595,6 +_,12 @@ +@@ -3595,6 +4477,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public boolean randomTeleport(final double xx, final double yy, final double zz, final boolean showParticles) { @@ -1872,7 +1873,7 @@ double xo = this.getX(); double yo = this.getY(); double zo = this.getZ(); -@@ -3617,16 +_,39 @@ +@@ -3617,16 +4505,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } if (landed) { @@ -1915,7 +1916,7 @@ } else { if (showParticles) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3636,7 +_,7 @@ +@@ -3636,7 +4547,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch index fa3e3bce9f23..d266713e7b4f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java +index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c45d39fc2 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -92,6 +_,14 @@ +@@ -92,6 +92,14 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.ticks.ContainerSingleItem; import org.jspecify.annotations.Nullable; @@ -15,7 +23,7 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUser, Leashable { private static final EntityDataAccessor DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE); private static final int MOB_FLAG_NO_AI = 1; -@@ -127,6 +_,7 @@ +@@ -127,6 +135,7 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; @@ -23,7 +31,7 @@ public GoalSelector targetSelector; private @Nullable LivingEntity target; private final Sensing sensing; -@@ -139,6 +_,8 @@ +@@ -139,6 +148,8 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -32,7 +40,7 @@ protected Mob(final EntityType type, final Level level) { super(type, level); -@@ -244,7 +_,44 @@ +@@ -244,7 +255,44 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs } public void setTarget(final @Nullable LivingEntity target) { @@ -78,7 +86,7 @@ } @Override -@@ -383,13 +_,27 @@ +@@ -383,13 +431,27 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -108,7 +116,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,6 +_,13 @@ +@@ -401,6 +463,13 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -122,7 +130,7 @@ } @Override -@@ -465,6 +_,11 @@ +@@ -465,6 +534,11 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs for (ItemEntity entity : this.level() .getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(pickupReach.getX(), pickupReach.getY(), pickupReach.getZ()))) { if (!entity.isRemoved() && !entity.getItem().isEmpty() && !entity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, entity.getItem())) { @@ -134,7 +142,7 @@ this.pickUpItem(serverLevel, entity); } } -@@ -515,18 +_,24 @@ +@@ -515,18 +589,24 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { ItemStack itemStack = entity.getItem(); @@ -161,7 +169,7 @@ EquipmentSlot slot = this.getEquipmentSlotForItem(itemStack); if (!this.isEquippableInSlot(itemStack, slot)) { return ItemStack.EMPTY; -@@ -539,10 +_,18 @@ +@@ -539,10 +619,18 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs canReplace = current.isEmpty(); } @@ -181,7 +189,7 @@ } ItemStack toEquip = slot.limit(itemStack); -@@ -651,25 +_,38 @@ +@@ -651,25 +739,38 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs return this.isPassenger() || this.isLeashed(); } @@ -233,7 +241,7 @@ this.noActionTime = 0; } } -@@ -681,6 +_,15 @@ +@@ -681,6 +782,15 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs @Override protected final void serverAiStep() { this.noActionTime++; @@ -249,7 +257,7 @@ ProfilerFiller profiler = Profiler.get(); profiler.push("sensing"); this.sensing.tick(); -@@ -859,14 +_,69 @@ +@@ -859,14 +969,69 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs public boolean stillValid(final Player player) { return player.getVehicle() == Mob.this || player.isWithinEntityInteractionRange(Mob.this, 4.0); } @@ -319,7 +327,7 @@ ItemStack itemStack = this.getItemBySlot(slot); float dropChance = this.dropChances.byEquipment(slot); if (dropChance != 0.0F) { -@@ -886,7 +_,13 @@ +@@ -886,7 +1051,13 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs } this.spawnAtLocation(level, itemStack); @@ -333,7 +341,7 @@ } } } -@@ -910,7 +_,9 @@ +@@ -910,7 +1081,9 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs slotsPreventedFromDropping.add(slot); } else if (this.dropChances.isPreserved(slot)) { this.setItemSlot(slot, ItemStack.EMPTY); @@ -343,7 +351,7 @@ } } } -@@ -1210,6 +_,22 @@ +@@ -1210,6 +1383,22 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs final EntitySpawnReason spawnReason, final ConversionParams.AfterConversion afterConversion ) { @@ -366,7 +374,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1218,13 +_,23 @@ +@@ -1218,13 +1407,23 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs return null; } else { params.type().convert(this, newMob, params); @@ -393,7 +401,7 @@ } return newMob; -@@ -1235,7 +_,17 @@ +@@ -1235,7 +1434,17 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs public @Nullable T convertTo( final EntityType entityType, final ConversionParams params, final ConversionParams.AfterConversion afterConversion ) { @@ -412,7 +420,7 @@ } @Override -@@ -1276,7 +_,17 @@ +@@ -1276,7 +1485,17 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs public boolean startRiding(final Entity entity, final boolean force, final boolean sendEventAndTriggers) { boolean result = super.startRiding(entity, force, sendEventAndTriggers); if (result && this.isLeashed()) { @@ -431,7 +439,7 @@ } return result; -@@ -1439,7 +_,7 @@ +@@ -1439,7 +1658,7 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs Set availableGoals = this.goalSelector.getAvailableGoals(); List goalInfo = new ArrayList<>(availableGoals.size()); availableGoals.forEach( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch index e298b1df0110..0be7554a7a7f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/TamableAnimal.java b/net/minecraft/world/entity/TamableAnimal.java +index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd350f1c5b 100644 --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -80,7 +_,7 @@ +@@ -80,7 +80,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { } this.orderedToSit = input.getBooleanOr("Sitting", false); @@ -9,7 +17,7 @@ } @Override -@@ -136,7 +_,7 @@ +@@ -136,7 +136,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { protected void feed(final Player player, final InteractionHand hand, final ItemStack itemStack, final float healingFactor, final float defaultHeal) { FoodProperties foodProperties = itemStack.get(DataComponents.FOOD); this.usePlayerItem(player, hand, itemStack); @@ -18,7 +26,7 @@ this.playEatingSound(); } -@@ -145,6 +_,13 @@ +@@ -145,6 +145,13 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { } public void setInSittingPose(final boolean value) { @@ -32,7 +40,7 @@ byte current = this.entityData.get(DATA_FLAGS_ID); if (value) { this.entityData.set(DATA_FLAGS_ID, (byte)(current | 1)); -@@ -225,7 +_,12 @@ +@@ -225,7 +232,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof ServerPlayer serverPlayer) { @@ -46,7 +54,7 @@ } super.die(source); -@@ -268,7 +_,14 @@ +@@ -268,7 +280,14 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { if (!this.canTeleportTo(new BlockPos(x, y, z))) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch similarity index 65% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch index e4e2c1f5d828..7b0a53382daa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +index 3e5c97286971feba437a4736acdf715361d70700..3325e7d4827067a65b176c5ba01aa491abd222a5 100644 --- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -74,6 +_,7 @@ +@@ -74,6 +74,7 @@ public class AcquirePoi { return false; } else { nextScheduledStart.setValue(timestamp + 20L + random.nextInt(20)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch similarity index 74% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch index d6f0def83860..9345c31c1dfb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java +index e807ef4a68dfca790fdede2d01d42d0510901852..d09583a108727f84a680f60ce511f8575b9a6be8 100644 --- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java +++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java -@@ -39,7 +_,14 @@ +@@ -39,7 +39,14 @@ public class AssignProfessionFromJobSite { .findFirst() ) .ifPresent(profession -> { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch similarity index 59% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch index c293d55736e8..9e720a86fd1c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/SleepInBed.java b/net/minecraft/world/entity/ai/behavior/SleepInBed.java +index 1af1fedbf75741c0d4b2ead49fa7837f1d47ebdb..112572f5a6813abd3cf3bd26e2b087b7edb48f41 100644 --- a/net/minecraft/world/entity/ai/behavior/SleepInBed.java +++ b/net/minecraft/world/entity/ai/behavior/SleepInBed.java -@@ -55,7 +_,8 @@ +@@ -55,7 +55,8 @@ public class SleepInBed extends Behavior { } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch index 8dcd2a659c5e..ba2086b95c21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/StartAttacking.java b/net/minecraft/world/entity/ai/behavior/StartAttacking.java +index 4a4d2e87d788ca9deecb27c82791e8fdca24ea33..cd78c8f06b40931aecf08445f8637f2b854aa989 100644 --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -29,6 +_,17 @@ +@@ -29,6 +29,17 @@ public class StartAttacking { if (!body.canAttack(targetEntity)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch index 92fca8fa6ab9..6ae47f4c5b7c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java b/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java +index 1dde3a2dd288b038107814900305d37434392a3f..f21e21a6a70b1f7409d350d157c457b06b17a00e 100644 --- a/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java +++ b/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java -@@ -40,6 +_,30 @@ +@@ -40,6 +40,30 @@ public class StopAttackingIfTargetInvalid { && !stopAttackingWhen.test(level, target)) { return true; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch similarity index 62% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch index d5c3556c7c9a..b888099087ef 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java +index 31e5087fcacd1b646e62f8ef0928352f226685f6..683f438676d16bce8b9d7f33aad600a02ed54aa1 100644 --- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java +++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -@@ -327,7 +_,10 @@ +@@ -327,7 +327,10 @@ public class TransportItemsBetweenContainers extends Behavior { } else { boolean isValidTarget = this.isWantedBlock(body, transportItemTarget.state) && !this.isPositionAlreadyVisited(visitedPositions, unreachablePositions, transportItemTarget, level) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch similarity index 69% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch index 5ad8af6c0131..13961b96ad46 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java +index cbd5d1aabbe2a2741094fb80bb6de28d1fbfa122..37cf6c4cef5a8885fddd9f637cac024892b498a3 100644 --- a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java +++ b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -@@ -111,11 +_,17 @@ +@@ -111,11 +111,17 @@ public class VillagerMakeLove extends Behavior { if (child == null) { return Optional.empty(); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch similarity index 71% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch index 6a67fd5bf5a9..4a7750de5378 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/goal/Goal.java b/net/minecraft/world/entity/ai/goal/Goal.java +index aafe6895709831d64733586122de1e777862c005..5746eefd9e8fa851e74ccf6b5d889a9f8e6fc1e0 100644 --- a/net/minecraft/world/entity/ai/goal/Goal.java +++ b/net/minecraft/world/entity/ai/goal/Goal.java -@@ -46,6 +_,17 @@ +@@ -46,6 +46,17 @@ public abstract class Goal { return this.flags; } @@ -18,7 +26,7 @@ protected int adjustedTickDelay(final int ticks) { return this.requiresUpdateEveryTick() ? ticks : reducedTickDelay(ticks); } -@@ -62,7 +_,19 @@ +@@ -62,7 +73,19 @@ public abstract class Goal { return (ServerLevel)level; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 624465630772..49d7c53ee089 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +index 8cc8b775bd8d111148cfc04f384ad65a1ffb4dac..ca91cadd8d52c09a735e6447664bed4753f3cdd3 100644 --- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -@@ -101,6 +_,11 @@ +@@ -101,6 +101,11 @@ public class RemoveBlockGoal extends MoveToBlockGoal { } if (this.ticksSinceReachedGoal > 60) { @@ -12,7 +20,7 @@ level.removeBlock(eatPos, false); if (!level.isClientSide()) { for (int i = 0; i < 20; i++) { -@@ -119,13 +_,16 @@ +@@ -119,13 +124,16 @@ public class RemoveBlockGoal extends MoveToBlockGoal { } private @Nullable BlockPos getPosWithBlock(final BlockPos pos, final BlockGetter level) { @@ -31,7 +39,7 @@ return neighborPos; } } -@@ -136,7 +_,7 @@ +@@ -136,7 +144,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal { @Override protected boolean isValidTarget(final LevelReader level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch similarity index 55% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch index 0c6f02b444d1..1171fc28657c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java +index 093bad31b64fa6b104bdfcc71b7b7f5956f5e198..a9fc45b2f2cc280fc84e07e1481172c78a3cd340 100644 --- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -@@ -62,7 +_,7 @@ +@@ -62,7 +62,7 @@ public abstract class TargetGoal extends Goal { } } @@ -9,7 +17,7 @@ return true; } } -@@ -82,7 +_,7 @@ +@@ -82,7 +82,7 @@ public abstract class TargetGoal extends Goal { @Override public void stop() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch similarity index 63% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch index 690e75c20979..198521e863a8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +index 1af5ff0e83d76d10b7e369acc4d97d12d845c385..2070a7b0a9c65c291f3bcbebfa9e30ed74b164cd 100644 --- a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -@@ -42,7 +_,7 @@ +@@ -42,7 +42,7 @@ public class GroundPathNavigation extends PathNavigation { } @Override @@ -9,7 +17,7 @@ LevelChunk chunk = this.level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); if (chunk == null) { return null; -@@ -51,7 +_,7 @@ +@@ -51,7 +51,7 @@ public class GroundPathNavigation extends PathNavigation { pos = this.findSurfacePosition(chunk, pos, reachRange); } @@ -18,7 +26,7 @@ } } -@@ -91,7 +_,7 @@ +@@ -91,7 +91,7 @@ public class GroundPathNavigation extends PathNavigation { @Override public Path createPath(final Entity target, final int reachRange) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index eabd006e9a8a..a4cf16aa17ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java +index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d2975d0d0b65 100644 --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -122,7 +_,12 @@ +@@ -122,7 +122,12 @@ public abstract class PathNavigation { } public @Nullable Path createPath(final BlockPos pos, final int reachRange) { @@ -14,7 +22,7 @@ } public @Nullable Path createPath(final BlockPos pos, final int reachRange, final int maxPathLength) { -@@ -130,7 +_,7 @@ +@@ -130,7 +135,7 @@ public abstract class PathNavigation { } public @Nullable Path createPath(final Entity target, final int reachRange) { @@ -23,7 +31,7 @@ } protected @Nullable Path createPath(final Set targets, final int radiusOffset, final boolean above, final int reachRange) { -@@ -140,6 +_,16 @@ +@@ -140,6 +145,16 @@ public abstract class PathNavigation { protected @Nullable Path createPath( final Set targets, final int radiusOffset, final boolean above, final int reachRange, final float maxPathLength ) { @@ -40,7 +48,7 @@ if (targets.isEmpty()) { return null; } else if (this.mob.getY() < this.level.getMinY()) { -@@ -149,6 +_,23 @@ +@@ -149,6 +164,23 @@ public abstract class PathNavigation { } else if (this.path != null && !this.path.isDone() && targets.contains(this.targetPos)) { return this.path; } else { @@ -64,7 +72,7 @@ ProfilerFiller profiler = Profiler.get(); profiler.push("pathfind"); BlockPos fromPos = above ? this.mob.blockPosition().above() : this.mob.blockPosition(); -@@ -168,6 +_,11 @@ +@@ -168,6 +200,11 @@ public abstract class PathNavigation { } } @@ -76,7 +84,7 @@ public boolean moveTo(final double x, final double y, final double z, final double speedModifier) { return this.moveTo(this.createPath(x, y, z, 1), speedModifier); } -@@ -177,8 +_,23 @@ +@@ -177,8 +214,23 @@ public abstract class PathNavigation { } public boolean moveTo(final Entity target, final double speedModifier) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch similarity index 64% rename from paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index c4ded0a08a6a..60fbb39d56ef 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ai/village/VillageSiege.java b/net/minecraft/world/entity/ai/village/VillageSiege.java +index e3aa405f3b5434576c40e7877b6ba0fb6527ec50..cfe8961610c3972e8dca68cf67281a20e6c4bc4e 100644 --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -102,11 +_,12 @@ +@@ -102,11 +102,12 @@ public class VillageSiege implements CustomSpawner { zombie.finalizeSpawn(level, level.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); } catch (Exception var5) { LOGGER.warn("Failed to create zombie for village siege at {}", spawnPos, var5); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch index 78d43b3d6a2a..8fc4947e29da 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java +index 08ee116f06c6e9710a552a9d610437a00c5c3c09..c2831ffb9a4765a628f8f005dc1218405301e926 100644 --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -84,7 +_,7 @@ +@@ -84,7 +84,7 @@ public class Bat extends AmbientCreature { } @Override @@ -9,7 +17,7 @@ return false; } -@@ -138,13 +_,13 @@ +@@ -138,13 +138,13 @@ public class Bat extends AmbientCreature { this.yHeadRot = this.random.nextInt(360); } @@ -25,7 +33,7 @@ this.setResting(false); if (!isSilent) { level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, pos, 0); -@@ -175,7 +_,7 @@ +@@ -175,7 +175,7 @@ public class Bat extends AmbientCreature { float rotDiff = Mth.wrapDegrees(yRotD - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + rotDiff); @@ -34,7 +42,7 @@ this.setResting(true); } } -@@ -200,7 +_,7 @@ +@@ -200,7 +200,7 @@ public class Bat extends AmbientCreature { if (this.isInvulnerableTo(level, source)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index 77e4f5dc38d0..cbdcab177874 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java +index 17edee3208fd482036be9e7c07a4f7edd23e44a8..03ec05a860781f85e58055d6f58893963781bd97 100644 --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -145,10 +_,12 @@ +@@ -145,10 +145,12 @@ public class Armadillo extends Animal { ArmadilloAi.updateActivity(this); profiler.pop(); if (this.isAlive() && --this.scuteTime <= 0 && this.shouldDropLoot(level)) { @@ -13,7 +21,7 @@ this.scuteTime = this.pickNextScuteDropTime(); } -@@ -285,8 +_,11 @@ +@@ -285,8 +287,11 @@ public class Armadillo extends Animal { } @Override @@ -27,7 +35,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (source.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -297,6 +_,7 @@ +@@ -297,6 +302,7 @@ public class Armadillo extends Animal { this.rollOut(); } } @@ -35,7 +43,7 @@ } @Override -@@ -315,7 +_,9 @@ +@@ -315,7 +321,9 @@ public class Armadillo extends Animal { return false; } else { if (this.level() instanceof ServerLevel level) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch index 9764afc7614d..277ac815882d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/bee/Bee.java b/net/minecraft/world/entity/animal/bee/Bee.java +index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82ab531aa4b 100644 --- a/net/minecraft/world/entity/animal/bee/Bee.java +++ b/net/minecraft/world/entity/animal/bee/Bee.java -@@ -150,10 +_,26 @@ +@@ -150,10 +150,26 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { private Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +36,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.FIRE_IN_NEIGHBOR, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -200,9 +_,18 @@ +@@ -200,9 +216,18 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { @Override protected void addAdditionalSaveData(final ValueOutput output) { @@ -47,7 +55,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -240,7 +_,7 @@ +@@ -240,7 +265,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { } if (poisonTime > 0) { @@ -56,7 +64,7 @@ } } -@@ -483,7 +_,11 @@ +@@ -483,7 +508,11 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { if (this.hivePos == null) { return null; } else { @@ -69,7 +77,7 @@ } } -@@ -515,7 +_,8 @@ +@@ -515,7 +544,8 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { return this.getFlag(FLAG_ROLL); } @@ -79,7 +87,7 @@ this.setFlag(FLAG_ROLL, rolling); } -@@ -576,7 +_,7 @@ +@@ -576,7 +606,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { if (effect != null) { this.usePlayerItem(player, hand, heldItem); if (!this.level().isClientSide()) { @@ -88,7 +96,7 @@ } return InteractionResult.SUCCESS; -@@ -644,8 +_,9 @@ +@@ -644,8 +674,9 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { if (this.isInvulnerableTo(level, source)) { return false; } else { @@ -99,7 +107,7 @@ } } -@@ -1007,7 +_,7 @@ +@@ -1007,7 +1038,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { } } @@ -108,7 +116,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, belowPos, 15); Bee.this.level().setBlockAndUpdate(belowPos, growState); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1032,7 +_,7 @@ +@@ -1032,7 +1063,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { @Override protected void alertOther(final Mob other, final LivingEntity hurtByMob) { if (other instanceof Bee && this.mob.hasLineOfSight(hurtByMob)) { @@ -117,7 +125,7 @@ } } } -@@ -1198,7 +_,7 @@ +@@ -1198,7 +1229,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch index 1514f5e2c95c..2b40899874ad 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java +index 64e09cdbfabc7cf7c627bca7e0b4e7a162329f30..1aa18543428578ff773a32c24f33b843b10e8e27 100644 --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -419,12 +_,12 @@ +@@ -419,12 +419,12 @@ public class Camel extends AbstractHorse { } else { boolean couldHeal = this.getHealth() < this.getMaxHealth(); if (couldHeal) { @@ -15,7 +23,7 @@ } boolean couldAgeUp = this.canAgeUp(); -@@ -482,9 +_,13 @@ +@@ -482,9 +482,13 @@ public class Camel extends AbstractHorse { } @Override @@ -31,7 +39,7 @@ } @Override -@@ -581,7 +_,7 @@ +@@ -581,7 +585,7 @@ public class Camel extends AbstractHorse { } public void sitDown() { @@ -40,7 +48,7 @@ this.makeSound(this.getSitDownSound()); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -590,7 +_,7 @@ +@@ -590,7 +594,7 @@ public class Camel extends AbstractHorse { } public void standUp() { @@ -49,7 +57,7 @@ this.makeSound(this.getStandUpSound()); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -607,6 +_,7 @@ +@@ -607,6 +611,7 @@ public class Camel extends AbstractHorse { } public void standUpInstantly() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch index c227d33d1bac..a01af29d62d9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java +index 72854d67bd96eafaa0530df646aad89e476d37c3..e7beaf8f5a1c6c393e158f15da422217976850f0 100644 --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -213,8 +_,16 @@ +@@ -213,8 +213,16 @@ public class Goat extends Animal { public InteractionResult mobInteract(final Player player, final InteractionHand hand) { ItemStack heldItem = player.getItemInHand(hand); if (heldItem.is(Items.BUCKET) && !this.isBaby()) { @@ -18,7 +26,7 @@ player.setItemInHand(hand, bucketOrMilkBucket); return InteractionResult.SUCCESS; } else { -@@ -328,8 +_,7 @@ +@@ -328,8 +336,7 @@ public class Goat extends Animal { double deltaY = Mth.randomBetween(this.random, 0.3F, 0.7F); double deltaZ = Mth.randomBetween(this.random, -0.2F, 0.2F); ItemEntity itemEntity = new ItemEntity(this.level(), bodyPosition.x(), bodyPosition.y(), bodyPosition.z(), item, deltaX, deltaY, deltaZ); @@ -28,7 +36,7 @@ } } } -@@ -352,4 +_,15 @@ +@@ -352,4 +359,15 @@ public class Goat extends Animal { ) { return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch similarity index 69% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index d5100bd9db08..bb463f36c2ca 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/parrot/Parrot.java b/net/minecraft/world/entity/animal/parrot/Parrot.java +index e1c653b2a4f77f0a5f4e35104439b71b59a7877d..11d599a8b3af8422de4b4c4043674c96d04cae13 100644 --- a/net/minecraft/world/entity/animal/parrot/Parrot.java +++ b/net/minecraft/world/entity/animal/parrot/Parrot.java -@@ -270,7 +_,7 @@ +@@ -270,7 +270,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { } if (!this.level().isClientSide()) { @@ -9,7 +17,7 @@ this.tame(player); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -291,7 +_,7 @@ +@@ -291,7 +291,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { } } else { this.usePlayerItem(player, hand, itemStack); @@ -18,7 +26,7 @@ if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -384,8 +_,8 @@ +@@ -384,8 +384,8 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { } @Override @@ -29,7 +37,7 @@ } @Override -@@ -400,8 +_,13 @@ +@@ -400,8 +400,13 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { if (this.isInvulnerableTo(level, source)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index 601db61365af..7b2883451e4a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/animal/wolf/Wolf.java b/net/minecraft/world/entity/animal/wolf/Wolf.java +index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce754ecfe3 100644 --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -396,16 +_,18 @@ +@@ -396,16 +396,18 @@ public class Wolf extends TamableAnimal implements NeutralMob { if (this.isInvulnerableTo(level, source)) { return false; } else { @@ -22,7 +30,7 @@ ItemStack armorBefore = this.getBodyArmorItem(); int damageBefore = armorBefore.getDamageValue(); int maxDamage = armorBefore.getMaxDamage(); -@@ -417,6 +_,7 @@ +@@ -417,6 +419,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { ); } } @@ -30,7 +38,7 @@ } private boolean canArmorAbsorb(final DamageSource source) { -@@ -427,7 +_,7 @@ +@@ -427,7 +430,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -39,7 +47,7 @@ } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -477,7 +_,7 @@ +@@ -477,7 +480,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -48,7 +56,7 @@ return InteractionResult.SUCCESS.withoutItem(); } -@@ -486,6 +_,25 @@ +@@ -486,6 +489,25 @@ public class Wolf extends TamableAnimal implements NeutralMob { DyeColor color = itemStack.get(DataComponents.DYE); if (color != null && color != this.getCollarColor()) { @@ -74,7 +82,7 @@ this.setCollarColor(color); itemStack.consume(1, player); return InteractionResult.SUCCESS; -@@ -500,7 +_,7 @@ +@@ -500,7 +522,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { } private void tryToTame(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch index 7900660e9112..2971a2fbcd49 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +index 921744784f95f46f13ad776502b3ec451ffff2e2..b45208810c5e1623fc8d0f77a2b42d448fc8912b 100644 --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java -@@ -26,6 +_,7 @@ +@@ -26,6 +26,7 @@ public class EndCrystal extends Entity { private static final EntityDataAccessor DATA_SHOW_BOTTOM = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.BOOLEAN); private static final boolean DEFAULT_SHOW_BOTTOM = true; public int time; @@ -8,17 +16,15 @@ public EndCrystal(final EntityType type, final Level level) { super(type, level); -@@ -57,21 +_,37 @@ +@@ -57,21 +58,37 @@ public class EndCrystal extends Entity { if (this.level() instanceof ServerLevel) { BlockPos pos = this.blockPosition(); if (((ServerLevel)this.level()).getDragonFight() != null && this.level().getBlockState(pos).isAir()) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), pos, this).isCancelled()) { // Paper this.level().setBlockAndUpdate(pos, BaseFireBlock.getState(this.level(), pos)); -- } -- } + } // Paper -+ } -+ } + } + } + + // Paper start - Fix invulnerable end crystals + if (this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) { @@ -48,7 +54,7 @@ } @Override -@@ -92,10 +_,24 @@ +@@ -92,10 +109,24 @@ public class EndCrystal extends Entity { return false; } else { if (!this.isRemoved()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 8a895d311c68..5fa2ba4c0202 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java +index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c264b25fee 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -88,9 +_,16 @@ +@@ -88,9 +88,16 @@ public class ArmorStand extends LivingEntity { private boolean invisible = false; public long lastHit; public int disabledSlots = 0; @@ -17,7 +25,7 @@ } public ArmorStand(final Level level, final double x, final double y, final double z) { -@@ -102,6 +_,13 @@ +@@ -102,6 +109,13 @@ public class ArmorStand extends LivingEntity { return createLivingAttributes().add(Attributes.STEP_HEIGHT, 0.0); } @@ -31,7 +39,7 @@ @Override public void refreshDimensions() { double oldX = this.getX(); -@@ -137,6 +_,14 @@ +@@ -137,6 +151,14 @@ public class ArmorStand extends LivingEntity { return slot != EquipmentSlot.BODY && slot != EquipmentSlot.SADDLE && !this.isDisabled(slot); } @@ -46,7 +54,7 @@ @Override protected void addAdditionalSaveData(final ValueOutput output) { super.addAdditionalSaveData(output); -@@ -150,6 +_,7 @@ +@@ -150,6 +172,7 @@ public class ArmorStand extends LivingEntity { } output.store("Pose", ArmorStand.ArmorStandPose.CODEC, this.getArmorStandPose()); @@ -54,7 +62,7 @@ } @Override -@@ -163,10 +_,16 @@ +@@ -163,10 +186,16 @@ public class ArmorStand extends LivingEntity { this.setMarker(input.getBooleanOr("Marker", false)); this.noPhysics = !this.hasPhysics(); input.read("Pose", ArmorStand.ArmorStandPose.CODEC).ifPresent(this::setArmorStandPose); @@ -72,7 +80,7 @@ return false; } -@@ -176,6 +_,7 @@ +@@ -176,6 +205,7 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { @@ -80,7 +88,7 @@ for (Entity entity : this.level().getEntities(this, this.getBoundingBox(), RIDABLE_MINECARTS)) { if (this.distanceToSqr(entity) <= 0.2) { entity.push(this); -@@ -248,7 +_,25 @@ +@@ -248,7 +278,25 @@ public class ArmorStand extends LivingEntity { return false; } else if (itemStack.isEmpty() && (this.disabledSlots & 1 << slot.getFilterBit(16)) != 0) { return false; @@ -107,7 +115,7 @@ this.setItemSlot(slot, playerItemStack.copyWithCount(1)); return true; } else if (playerItemStack.isEmpty() || playerItemStack.getCount() <= 1) { -@@ -270,15 +_,32 @@ +@@ -270,15 +318,32 @@ public class ArmorStand extends LivingEntity { } else if (!level.getGameRules().get(GameRules.MOB_GRIEFING) && source.getEntity() instanceof Mob) { return false; } else if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { @@ -144,7 +152,7 @@ if (this.isOnFire()) { this.causeDamage(level, source, 0.15F); } else { -@@ -287,9 +_,19 @@ +@@ -287,9 +352,19 @@ public class ArmorStand extends LivingEntity { return false; } else if (source.is(DamageTypeTags.BURNS_ARMOR_STANDS) && this.getHealth() > 0.5F) { @@ -164,7 +172,7 @@ boolean allowIncrementalBreaking = source.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean shouldKill = source.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); if (!allowIncrementalBreaking && !shouldKill) { -@@ -299,7 +_,7 @@ +@@ -299,7 +374,7 @@ public class ArmorStand extends LivingEntity { } else if (source.isCreativePlayer()) { this.playBrokenSound(); this.showBreakingParticles(); @@ -173,7 +181,7 @@ return true; } else { long time = level.getGameTime(); -@@ -308,9 +_,9 @@ +@@ -308,9 +383,9 @@ public class ArmorStand extends LivingEntity { this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); this.lastHit = time; } else { @@ -185,7 +193,7 @@ } return true; -@@ -362,31 +_,42 @@ +@@ -362,31 +437,42 @@ public class ArmorStand extends LivingEntity { float health = this.getHealth(); health -= dmg; if (health <= 0.5F) { @@ -222,8 +230,6 @@ + ItemStack itemStack = this.equipment.get(slot); // Paper - move equipment removal past event call if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { - Block.popResource(this.level(), this.blockPosition().above(), itemStack); -- } -- } + this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly} + } + } @@ -232,14 +238,14 @@ + if (!event.isCancelled()) { + for (EquipmentSlot slot : EquipmentSlot.VALUES) { + this.equipment.set(slot, ItemStack.EMPTY); -+ } -+ } + } + } + return event; + // Paper end - move equipment removal past event call } private void playBrokenSound() { -@@ -434,9 +_,40 @@ +@@ -434,9 +520,40 @@ public class ArmorStand extends LivingEntity { return this.isSmall(); } @@ -281,7 +287,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -683,4 +_,13 @@ +@@ -683,4 +800,13 @@ public class ArmorStand extends LivingEntity { .apply(i, ArmorStand.ArmorStandPose::new) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch index b6722f3451a3..751ef0d5028b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java +index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf30010aa7975 100644 --- a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java +++ b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java -@@ -21,7 +_,7 @@ +@@ -21,7 +21,7 @@ import org.slf4j.Logger; public abstract class BlockAttachedEntity extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); @@ -9,7 +17,7 @@ protected BlockPos pos; protected BlockAttachedEntity(final EntityType type, final Level level) { -@@ -39,10 +_,26 @@ +@@ -39,10 +39,26 @@ public abstract class BlockAttachedEntity extends Entity { public void tick() { if (this.level() instanceof ServerLevel level) { this.checkBelowWorld(); @@ -38,7 +46,7 @@ this.dropItem(level, null); } } -@@ -75,6 +_,21 @@ +@@ -75,6 +91,21 @@ public abstract class BlockAttachedEntity extends Entity { return false; } else { if (!this.isRemoved()) { @@ -60,22 +68,10 @@ this.kill(level); this.markHurt(); this.dropItem(level, source.getEntity()); -@@ -93,18 +_,36 @@ +@@ -93,19 +124,37 @@ public abstract class BlockAttachedEntity extends Entity { @Override public void move(final MoverType moverType, final Vec3 delta) { if (this.level() instanceof ServerLevel level && !this.isRemoved() && delta.lengthSqr() > 0.0) { -- this.kill(level); -- this.dropItem(level, null); -- } -- } -- -- @Override -- public void push(final double xa, final double ya, final double za) { -- if (this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { -- this.kill(level); -- this.dropItem(level, null); -- } -- } + // CraftBukkit start - fire break events + // TODO - Does this need its own cause? Seems to only be triggered by pistons + org.bukkit.event.hanging.HangingBreakEvent event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.PHYSICS); @@ -85,19 +81,21 @@ + return; + } + // CraftBukkit end -+ this.kill(level); -+ this.dropItem(level, null); -+ } -+ } -+ -+ @Override + this.kill(level); + this.dropItem(level, null); + } + } + + @Override +- public void push(final double xa, final double ya, final double za) { +- if (this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { + public void push(final double xa, final double ya, final double za, @Nullable final Entity pushingEntity) { // Paper - override correct overload + if (false && this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { // CraftBukkit - not needed -+ this.kill(level); -+ this.dropItem(level, null); -+ } -+ } -+ + this.kill(level); + this.dropItem(level, null); + } + } + + // CraftBukkit start - selectively save tile position + @Override + protected void addAdditionalSaveData(final net.minecraft.world.level.storage.ValueOutput output, final boolean includeAll) { @@ -106,6 +104,7 @@ + } + } + // CraftBukkit end - ++ @Override protected void addAdditionalSaveData(final ValueOutput output) { + output.store("block_pos", BlockPos.CODEC, this.getPos()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 4af212abab10..d852d4aba617 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java +index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2e9040928 100644 --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -54,6 +_,7 @@ +@@ -54,6 +54,7 @@ public class ItemFrame extends HangingEntity { private static final boolean DEFAULT_FIXED = false; public float dropChance = 1.0F; public boolean fixed = false; @@ -8,7 +16,7 @@ public ItemFrame(final EntityType type, final Level level) { super(type, level); -@@ -111,6 +_,11 @@ +@@ -111,6 +112,11 @@ public class ItemFrame extends HangingEntity { } private AABB createBoundingBox(final BlockPos blockPos, final Direction direction, final boolean hasFramedMap) { @@ -20,7 +28,7 @@ float shiftToBlockWall = 0.46875F; Vec3 position = Vec3.atCenterOf(blockPos).relative(direction, -0.46875); float width = hasFramedMap ? 1.0F : 0.75F; -@@ -142,9 +_,9 @@ +@@ -142,9 +148,9 @@ public class ItemFrame extends HangingEntity { } @Override @@ -32,7 +40,7 @@ } } -@@ -173,6 +_,18 @@ +@@ -173,6 +179,18 @@ public class ItemFrame extends HangingEntity { if (this.isInvulnerableToBase(source)) { return false; } else if (this.shouldDamageDropItem(source)) { @@ -51,7 +59,7 @@ this.dropItem(level, source.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -256,6 +_,13 @@ +@@ -256,6 +274,13 @@ public class ItemFrame extends HangingEntity { return this.getEntityData().get(DATA_ITEM); } @@ -65,7 +73,7 @@ public @Nullable MapId getFramedMapId(final ItemStack itemStack) { return itemStack.get(DataComponents.MAP_ID); } -@@ -269,13 +_,19 @@ +@@ -269,13 +294,19 @@ public class ItemFrame extends HangingEntity { } public void setItem(ItemStack itemStack, final boolean updateNeighbours) { @@ -86,7 +94,7 @@ this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -302,6 +_,7 @@ +@@ -302,6 +333,7 @@ public class ItemFrame extends HangingEntity { } private void onItemChanged(final ItemStack item) { @@ -94,7 +102,7 @@ this.recalculateBoundingBox(); } -@@ -366,7 +_,13 @@ +@@ -366,7 +398,13 @@ public class ItemFrame extends HangingEntity { if (data != null && data.isTrackedCountOverLimit(256)) { return InteractionResult.FAIL; } else { @@ -109,7 +117,7 @@ this.gameEvent(GameEvent.BLOCK_CHANGE, player); itemStack.consume(1, player); return InteractionResult.SUCCESS; -@@ -375,6 +_,13 @@ +@@ -375,6 +413,13 @@ public class ItemFrame extends HangingEntity { return InteractionResult.PASS; } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch similarity index 69% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch index de163b618697..7e695a0914c3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java +index 2ae0015d6c00640a72864091235b71ad0d4aaac3..a4999a82fa5ed58b88cc11b42524d2513a3ed37a 100644 --- a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java +++ b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -@@ -85,7 +_,7 @@ +@@ -85,7 +85,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { boolean attachedMob = false; for (Leashable leashable : Leashable.leashableLeashedTo(player)) { @@ -9,7 +17,7 @@ leashable.setLeashedTo(this, true); attachedMob = true; } -@@ -94,7 +_,7 @@ +@@ -94,7 +94,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { boolean anyDropped = false; if (!attachedMob && !player.isSecondaryUseActive()) { for (Leashable mob : Leashable.leashableLeashedTo(this)) { @@ -18,7 +26,7 @@ mob.setLeashedTo(player, true); anyDropped = true; } -@@ -114,7 +_,7 @@ +@@ -114,7 +114,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { @Override public void notifyLeasheeRemoved(final Leashable entity) { if (Leashable.leashableLeashedTo(this).isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch index 0ef8416a98e3..ddf2da2b9f19 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java +index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860e0cde916 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -51,6 +_,9 @@ +@@ -51,6 +51,9 @@ public class ItemEntity extends Entity implements TraceableEntity { public @Nullable EntityReference thrower; public @Nullable UUID target; public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; @@ -10,7 +18,7 @@ public ItemEntity(final EntityType type, final Level level) { super(type, level); -@@ -80,6 +_,14 @@ +@@ -80,6 +83,14 @@ public class ItemEntity extends Entity implements TraceableEntity { this.setDeltaMovement(deltaX, deltaY, deltaZ); } @@ -25,7 +33,7 @@ @Override public boolean dampensVibrations() { return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); -@@ -116,7 +_,7 @@ +@@ -116,7 +127,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @Override public void tick() { if (this.getItem().isEmpty()) { @@ -34,7 +42,7 @@ } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -144,13 +_,17 @@ +@@ -144,13 +155,17 @@ public class ItemEntity extends Entity implements TraceableEntity { } } @@ -54,7 +62,7 @@ friction = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -183,8 +_,14 @@ +@@ -183,8 +198,14 @@ public class ItemEntity extends Entity implements TraceableEntity { } } @@ -71,7 +79,7 @@ } } } -@@ -209,9 +_,18 @@ +@@ -209,9 +230,18 @@ public class ItemEntity extends Entity implements TraceableEntity { private void mergeWithNeighbours() { if (this.isMergable()) { @@ -91,7 +99,7 @@ this.tryToMerge(entity); if (this.isRemoved()) { break; -@@ -223,7 +_,7 @@ +@@ -223,7 +253,7 @@ public class ItemEntity extends Entity implements TraceableEntity { private boolean isMergable() { ItemStack item = this.getItem(); @@ -100,7 +108,7 @@ } private void tryToMerge(final ItemEntity other) { -@@ -256,11 +_,16 @@ +@@ -256,11 +286,16 @@ public class ItemEntity extends Entity implements TraceableEntity { } private static void merge(final ItemEntity toItem, final ItemStack toStack, final ItemEntity fromItem, final ItemStack fromStack) { @@ -118,7 +126,7 @@ } } -@@ -288,12 +_,17 @@ +@@ -288,12 +323,17 @@ public class ItemEntity extends Entity implements TraceableEntity { } else if (!this.getItem().canBeHurtBy(source)) { return false; } else { @@ -137,7 +145,7 @@ } return true; -@@ -315,6 +_,11 @@ +@@ -315,6 +355,11 @@ public class ItemEntity extends Entity implements TraceableEntity { if (!this.getItem().isEmpty()) { output.store("Item", ItemStack.CODEC, this.getItem()); } @@ -149,7 +157,7 @@ } @Override -@@ -325,8 +_,17 @@ +@@ -325,8 +370,17 @@ public class ItemEntity extends Entity implements TraceableEntity { this.target = input.read("Owner", UUIDUtil.CODEC).orElse(null); this.thrower = EntityReference.read(input, "Thrower"); this.setItem(input.read("Item", ItemStack.CODEC).orElse(ItemStack.EMPTY)); @@ -168,7 +176,7 @@ } } -@@ -336,10 +_,73 @@ +@@ -336,10 +390,73 @@ public class ItemEntity extends Entity implements TraceableEntity { ItemStack itemStack = this.getItem(); Item item = itemStack.getItem(); int orgCount = itemStack.getCount(); @@ -243,7 +251,7 @@ itemStack.setCount(orgCount); } -@@ -376,6 +_,7 @@ +@@ -376,6 +493,7 @@ public class ItemEntity extends Entity implements TraceableEntity { public void setItem(final ItemStack itemStack) { this.getEntityData().set(DATA_ITEM, itemStack); @@ -251,7 +259,7 @@ } public void setTarget(final @Nullable UUID target) { -@@ -420,7 +_,7 @@ +@@ -420,7 +538,7 @@ public class ItemEntity extends Entity implements TraceableEntity { public void makeFakeItem() { this.setNeverPickUp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch index 2e6fd539b7c9..8fdbcfb6c9a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java +index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1fb7406200 100644 --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -119,9 +_,20 @@ +@@ -119,9 +119,20 @@ public class EnderMan extends Monster implements NeutralMob { .add(Attributes.STEP_HEIGHT, 1.0); } @@ -23,7 +31,7 @@ AttributeInstance movementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED); if (target == null) { this.targetChangeTime = 0; -@@ -135,6 +_,7 @@ +@@ -135,6 +146,7 @@ public class EnderMan extends Monster implements NeutralMob { movementSpeed.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -31,7 +39,7 @@ } @Override -@@ -207,6 +_,15 @@ +@@ -207,6 +219,15 @@ public class EnderMan extends Monster implements NeutralMob { } private boolean isBeingStaredBy(final Player player) { @@ -47,7 +55,7 @@ return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, this.getEyeY()); } -@@ -244,7 +_,7 @@ +@@ -244,7 +265,7 @@ public class EnderMan extends Monster implements NeutralMob { protected void customServerAiStep(final ServerLevel level) { if (level.isBrightOutside() && this.tickCount >= this.targetChangeTime + 600) { float br = this.getLightLevelDependentMagicValue(); @@ -56,7 +64,7 @@ this.setTarget(null); this.teleport(); } -@@ -354,21 +_,25 @@ +@@ -354,21 +375,25 @@ public class EnderMan extends Monster implements NeutralMob { return false; } else { AbstractThrownPotion thrownPotion = source.getDirectEntity() instanceof AbstractThrownPotion potion ? potion : null; @@ -83,7 +91,7 @@ return hurtWithCleanWater; } -@@ -393,6 +_,16 @@ +@@ -393,6 +418,16 @@ public class EnderMan extends Monster implements NeutralMob { this.entityData.set(DATA_STARED_AT, true); } @@ -100,7 +108,7 @@ @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -@@ -451,16 +_,19 @@ +@@ -451,16 +486,19 @@ public class EnderMan extends Monster implements NeutralMob { int yt = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int zt = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); BlockPos pos = new BlockPos(xt, yt, zt); @@ -121,7 +129,7 @@ } } } -@@ -552,7 +_,7 @@ +@@ -552,7 +590,7 @@ public class EnderMan extends Monster implements NeutralMob { } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player)this.target)) { @@ -130,7 +138,7 @@ this.enderman.teleport(); } -@@ -591,15 +_,18 @@ +@@ -591,15 +629,18 @@ public class EnderMan extends Monster implements NeutralMob { int yt = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0); int zt = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0); BlockPos pos = new BlockPos(xt, yt, zt); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch similarity index 61% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch index e88d19baa7eb..96925ee4467d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/Endermite.java b/net/minecraft/world/entity/monster/Endermite.java +index d2b57a3b3bf0ab25e3ec78b32549df0389fe35dc..cc4e015e355f0c76a52cb64a82cced57700032af 100644 --- a/net/minecraft/world/entity/monster/Endermite.java +++ b/net/minecraft/world/entity/monster/Endermite.java -@@ -123,7 +_,7 @@ +@@ -123,7 +123,7 @@ public class Endermite extends Monster { } if (this.life >= 2400) { @@ -9,7 +17,7 @@ } } } -@@ -136,7 +_,7 @@ +@@ -136,7 +136,7 @@ public class Endermite extends Monster { } else if (EntitySpawnReason.isSpawner(spawnReason)) { return true; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch similarity index 58% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch index 2e282f76bf20..e9e873aa11e5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/Monster.java b/net/minecraft/world/entity/monster/Monster.java +index 515d4e90f3beeedd1b4d7e4180d0fb7cf73612c5..4ac86e516641142a7c3bd414dc3450e912a1c2b0 100644 --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -88,7 +_,7 @@ +@@ -88,7 +88,7 @@ public abstract class Monster extends PathfinderMob implements Enemy { return false; } else { DimensionType dimensionType = level.dimensionType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch index 26878838bcfa..dc356a6985ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java +index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99c62033d2 100644 --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -50,6 +_,10 @@ +@@ -50,6 +50,10 @@ public class Phantom extends Mob implements Enemy { private Vec3 moveTargetPoint = Vec3.ZERO; public @Nullable BlockPos anchorPoint; private Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; @@ -11,7 +19,7 @@ public Phantom(final EntityType type, final Level level) { super(type, level); -@@ -137,6 +_,13 @@ +@@ -137,6 +141,13 @@ public class Phantom extends Mob implements Enemy { } } @@ -25,7 +33,7 @@ @Override protected void checkFallDamage(final double ya, final boolean onGround, final BlockState onState, final BlockPos pos) { } -@@ -165,6 +_,10 @@ +@@ -165,6 +176,10 @@ public class Phantom extends Mob implements Enemy { super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -36,7 +44,7 @@ } @Override -@@ -172,6 +_,10 @@ +@@ -172,6 +187,10 @@ public class Phantom extends Mob implements Enemy { super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -47,7 +55,7 @@ } @Override -@@ -240,8 +_,10 @@ +@@ -240,8 +259,10 @@ public class Phantom extends Mob implements Enemy { for (Player player : players) { if (Phantom.this.canAttack(level, player, TargetingConditions.DEFAULT)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch index 0bf09e3dd85b..ee46ac476dae 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/Silverfish.java b/net/minecraft/world/entity/monster/Silverfish.java +index 626f3bb5fd7f85f3a15ce4ab424cf9bc7873cc19..ba4ba5dfb1e51e2f45b0b81012ed6be27362c55c 100644 --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -117,7 +_,7 @@ +@@ -117,7 +117,7 @@ public class Silverfish extends Monster { } else if (EntitySpawnReason.isSpawner(spawnReason)) { return true; } else { @@ -9,7 +17,7 @@ return nearestPlayer == null; } } -@@ -168,9 +_,14 @@ +@@ -168,9 +168,14 @@ public class Silverfish extends Monster { BlockPos pos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockState = level.getBlockState(pos); if (InfestedBlock.isCompatibleHostBlock(blockState)) { @@ -25,7 +33,7 @@ } } } -@@ -210,6 +_,12 @@ +@@ -210,6 +215,12 @@ public class Silverfish extends Monster { BlockState blockState = level.getBlockState(testPos); Block block = blockState.getBlock(); if (block instanceof InfestedBlock) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index cc9ead32c126..811cac983289 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java +index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6354c0a64 100644 --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -96,6 +_,12 @@ +@@ -96,6 +96,12 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento List.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR), PiglinAi::getActivities ); @@ -13,7 +21,7 @@ public Piglin(final EntityType type, final Level level) { super(type, level); -@@ -108,6 +_,10 @@ +@@ -108,6 +114,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento output.putBoolean("IsBaby", this.isBaby()); output.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(output); @@ -24,7 +32,7 @@ } @Override -@@ -116,6 +_,10 @@ +@@ -116,6 +126,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento this.setBaby(input.getBooleanOr("IsBaby", false)); this.setCannotHunt(input.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(input); @@ -35,7 +43,7 @@ } @VisibleForDebug -@@ -282,7 +_,9 @@ +@@ -282,7 +296,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @Override protected void finishConversion(final ServerLevel level) { PiglinAi.cancelAdmiring(level, this); @@ -45,7 +53,7 @@ super.finishConversion(level); } -@@ -359,7 +_,7 @@ +@@ -359,7 +375,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento } protected void holdInOffHand(final ItemStack itemStack) { @@ -54,7 +62,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, itemStack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -384,8 +_,8 @@ +@@ -384,8 +400,8 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); @@ -65,7 +73,7 @@ return newItemWanted && !currentItemWanted || (newItemWanted || !currentItemWanted) && super.canReplaceCurrentItem(newItemStack, currentItemStack, slot); } -@@ -393,7 +_,7 @@ +@@ -393,7 +409,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @Override protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch similarity index 62% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch index 0ddacc7eb85a..321ca3a40e95 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java +index 3106820022b6435bf9c02bcdf0ec0cb5fdfd2253..27f0e22f015aad556bff6dac404b6ed2df04e486 100644 --- a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java +++ b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java -@@ -95,7 +_,7 @@ +@@ -95,7 +95,7 @@ public class WitherSkeleton extends AbstractSkeleton { return false; } else { if (target instanceof LivingEntity) { @@ -9,7 +17,7 @@ } return true; -@@ -111,6 +_,6 @@ +@@ -111,6 +111,6 @@ public class WitherSkeleton extends AbstractSkeleton { @Override public boolean canBeAffected(final MobEffectInstance newEffect) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index ec8291af250e..7c2f58037ffc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/monster/zombie/Zombie.java b/net/minecraft/world/entity/monster/zombie/Zombie.java +index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e9656233ce89 100644 --- a/net/minecraft/world/entity/monster/zombie/Zombie.java +++ b/net/minecraft/world/entity/monster/zombie/Zombie.java -@@ -71,8 +_,10 @@ +@@ -71,8 +71,10 @@ import org.jspecify.annotations.Nullable; public class Zombie extends Monster { private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); @@ -13,7 +21,7 @@ ); private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( -@@ -96,13 +_,15 @@ +@@ -96,13 +98,15 @@ public class Zombie extends Monster { private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; private static final int DEFAULT_IN_WATER_TIME = 0; @@ -30,7 +38,7 @@ } public Zombie(final Level level) { -@@ -111,7 +_,7 @@ +@@ -111,7 +115,7 @@ public class Zombie extends Monster { @Override protected void registerGoals() { @@ -39,7 +47,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -124,7 +_,7 @@ +@@ -124,7 +128,7 @@ public class Zombie extends Monster { this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -48,7 +56,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -178,11 +_,16 @@ +@@ -178,11 +182,16 @@ public class Zombie extends Monster { @Override protected int getBaseExperienceReward(final ServerLevel level) { @@ -66,7 +74,7 @@ } @Override -@@ -233,6 +_,13 @@ +@@ -233,6 +242,13 @@ public class Zombie extends Monster { super.tick(); } @@ -80,7 +88,7 @@ public void startUnderWaterConversion(final int time) { this.conversionTime = time; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -246,17 +_,28 @@ +@@ -246,17 +262,28 @@ public class Zombie extends Monster { } protected void convertToZombieType(final ServerLevel level, final EntityType zombieType) { @@ -113,7 +121,7 @@ ZombieVillager zombieVillager = villager.convertTo( EntityType.ZOMBIE_VILLAGER, ConversionParams.single(villager, true, true), -@@ -268,17 +_,24 @@ +@@ -268,18 +295,25 @@ public class Zombie extends Monster { zombie.setGossips(villager.getGossips().copy()); zombie.setTradeOffers(villager.getOffers().copy()); zombie.setVillagerXp(villager.getVillagerXp()); @@ -133,19 +141,19 @@ public boolean isSunSensitive() { - return true; -- } + return this.shouldBurnInDay; // Paper - Add more Zombie API -+ } -+ + } + + // Paper start - Add more Zombie API + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; + } + // Paper end - Add more Zombie API - ++ @Override public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { -@@ -311,15 +_,15 @@ + if (!super.hurtServer(level, source, damage)) { +@@ -311,15 +345,15 @@ public class Zombie extends Monster { if (SpawnPlacements.isSpawnPositionOk(type, level, spawnPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, spawnPos, level.getRandom())) { reinforcement.setPos(xt, yt, zt); @@ -164,7 +172,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double existingAmount = modifier != null ? modifier.amount() : 0.0; -@@ -344,7 +_,12 @@ +@@ -344,7 +378,12 @@ public class Zombie extends Monster { if (result) { float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < difficulty * 0.3F) { @@ -178,7 +186,7 @@ } } -@@ -406,6 +_,7 @@ +@@ -406,6 +445,7 @@ public class Zombie extends Monster { output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -186,7 +194,7 @@ } @Override -@@ -420,13 +_,15 @@ +@@ -420,13 +460,15 @@ public class Zombie extends Monster { } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -204,7 +212,7 @@ return perished; } -@@ -461,7 +_,7 @@ +@@ -461,7 +503,7 @@ public class Zombie extends Monster { groupData = super.finalizeSpawn(level, difficulty, spawnReason, groupData); float difficultyModifier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -213,7 +221,7 @@ } if (groupData == null) { -@@ -488,7 +_,7 @@ +@@ -488,7 +530,7 @@ public class Zombie extends Monster { chicken.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken.setChickenJockey(true); this.startRiding(chicken, false, false); @@ -222,7 +230,7 @@ } } } -@@ -514,7 +_,7 @@ +@@ -514,7 +556,7 @@ public class Zombie extends Monster { protected void onOffspringSpawnedFromEgg(final Player spawner, final Mob offspring) { if (this.level() instanceof ServerLevel serverLevel) { float difficultyModifier = serverLevel.getCurrentDifficultyAt(offspring.blockPosition()).getSpecialMultiplier(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch index 1c205cd062e8..cd7584096ac4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java +index 949f1bd6c1712fa80d94c28ba1a16a0ed5793d93..b107f47d289aa32a37365163667270a98df19162 100644 --- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java +++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java -@@ -37,30 +_,38 @@ +@@ -37,30 +37,38 @@ public class WanderingTraderSpawner implements CustomSpawner { public WanderingTraderSpawner(final SavedDataStorage savedDataStorage) { this.savedDataStorage = savedDataStorage; @@ -47,7 +55,7 @@ } } -@@ -90,13 +_,13 @@ +@@ -90,13 +98,13 @@ public class WanderingTraderSpawner implements CustomSpawner { return false; } @@ -63,7 +71,7 @@ trader.setWanderTarget(referencePos); trader.setHomeTo(referencePos, 16); return true; -@@ -110,7 +_,7 @@ +@@ -110,7 +118,7 @@ public class WanderingTraderSpawner implements CustomSpawner { private void tryToSpawnLlamaFor(final ServerLevel level, final WanderingTrader trader, final int radius) { BlockPos spawnPosition = this.findSpawnPositionNear(level, trader.blockPosition(), radius); if (spawnPosition != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch index d32965b732e3..539139be1e0b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java +index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5b5318309 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -150,7 +_,7 @@ +@@ -150,7 +150,7 @@ public abstract class Player extends Avatar implements ContainerUser { private static final int DEFAULT_SCORE = 0; public static final float CREATIVE_ENTITY_INTERACTION_RANGE_MODIFIER_VALUE = 2.0F; private final Inventory inventory; @@ -9,7 +17,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -172,6 +_,18 @@ +@@ -172,6 +172,18 @@ public abstract class Player extends Avatar implements ContainerUser { private Optional lastDeathLocation = Optional.empty(); public @Nullable FishingHook fishing; public float hurtDir; @@ -28,7 +36,7 @@ public Player(final Level level, final GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -238,6 +_,13 @@ +@@ -238,6 +250,13 @@ public abstract class Player extends Avatar implements ContainerUser { if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +50,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -267,7 +_,7 @@ +@@ -267,7 +286,7 @@ public abstract class Player extends Avatar implements ContainerUser { ItemStack mainHandItemStack = this.getMainHandItem(); if (!ItemStack.matches(this.lastItemInMainHand, mainHandItemStack)) { if (!ItemStack.isSameItem(this.lastItemInMainHand, mainHandItemStack)) { @@ -51,7 +59,7 @@ } this.lastItemInMainHand = mainHandItemStack.copy(); -@@ -318,7 +_,7 @@ +@@ -318,7 +337,7 @@ public abstract class Player extends Avatar implements ContainerUser { } private void turtleHelmetTick() { @@ -60,7 +68,7 @@ } private boolean isEquipped(final Item item) { -@@ -419,6 +_,18 @@ +@@ -419,6 +438,18 @@ public abstract class Player extends Avatar implements ContainerUser { } } @@ -79,7 +87,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -430,8 +_,14 @@ +@@ -430,8 +461,14 @@ public abstract class Player extends Avatar implements ContainerUser { public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -96,7 +104,7 @@ super.rideTick(); } } -@@ -684,10 +_,10 @@ +@@ -684,10 +721,10 @@ public abstract class Player extends Avatar implements ContainerUser { if (this.isDeadOrDying()) { return false; } else { @@ -109,7 +117,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -699,7 +_,14 @@ +@@ -699,7 +736,14 @@ public abstract class Player extends Avatar implements ContainerUser { } } @@ -125,7 +133,7 @@ } } } -@@ -711,7 +_,7 @@ +@@ -711,7 +755,7 @@ public abstract class Player extends Avatar implements ContainerUser { BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = attacker.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -134,7 +142,7 @@ } } -@@ -721,9 +_,29 @@ +@@ -721,9 +765,29 @@ public abstract class Player extends Avatar implements ContainerUser { } public boolean canHarmPlayer(final Player target) { @@ -167,7 +175,7 @@ } @Override -@@ -737,7 +_,12 @@ +@@ -737,7 +801,12 @@ public abstract class Player extends Avatar implements ContainerUser { } @Override @@ -181,7 +189,7 @@ if (!this.isInvulnerableTo(level, source)) { dmg = this.getDamageAfterArmorAbsorb(source, dmg); dmg = this.getDamageAfterMagicAbsorb(source, dmg); -@@ -749,7 +_,7 @@ +@@ -749,7 +818,7 @@ public abstract class Player extends Avatar implements ContainerUser { } if (var8 != 0.0F) { @@ -190,7 +198,7 @@ this.getCombatTracker().recordDamage(source, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -759,6 +_,7 @@ +@@ -759,6 +828,7 @@ public abstract class Player extends Avatar implements ContainerUser { this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -198,7 +206,7 @@ } public boolean isTextFilteringEnabled() { -@@ -852,14 +_,16 @@ +@@ -852,14 +922,16 @@ public abstract class Player extends Avatar implements ContainerUser { } @Override @@ -218,7 +226,7 @@ } @Override -@@ -938,15 +_,25 @@ +@@ -938,15 +1010,25 @@ public abstract class Player extends Avatar implements ContainerUser { } public void attack(final Entity entity) { @@ -248,7 +256,7 @@ if (baseDamage > 0.0F || magicBoost > 0.0F) { boolean fullStrengthAttack = attackStrengthScale > 0.9F; boolean knockbackAttack; -@@ -959,7 +_,9 @@ +@@ -959,7 +1041,9 @@ public abstract class Player extends Avatar implements ContainerUser { baseDamage += attackingItemStack.getItem().getAttackDamageBonus(entity, baseDamage, damageSource); boolean criticalAttack = fullStrengthAttack && this.canCriticalAttack(entity); @@ -258,7 +266,7 @@ baseDamage *= 1.5F; } -@@ -982,7 +_,7 @@ +@@ -982,7 +1066,7 @@ public abstract class Player extends Avatar implements ContainerUser { this.setLastHurtMob(entity); this.itemAttackInteraction(entity, attackingItemStack, damageSource, true); this.damageStatsAndHearts(entity, oldLivingEntityHealth); @@ -267,7 +275,7 @@ } else { this.playServerSideSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); } -@@ -994,7 +_,7 @@ +@@ -994,7 +1078,7 @@ public abstract class Player extends Avatar implements ContainerUser { } private void playServerSideSound(final SoundEvent sound) { @@ -276,7 +284,7 @@ } private DamageSource createAttackSource(final ItemStack attackingItemStack) { -@@ -1005,11 +_,12 @@ +@@ -1005,11 +1089,12 @@ public abstract class Player extends Avatar implements ContainerUser { return !entity.isAttackable() || entity.skipAttackInteraction(this); } @@ -291,7 +299,7 @@ return true; } else { return false; -@@ -1109,19 +_,40 @@ +@@ -1109,19 +1194,40 @@ public abstract class Player extends Avatar implements ContainerUser { public void causeExtraKnockback(final Entity entity, final float knockbackAmount, final Vec3 oldMovement) { if (knockbackAmount > 0.0F) { if (entity instanceof LivingEntity livingTarget) { @@ -334,7 +342,7 @@ } } -@@ -1142,8 +_,11 @@ +@@ -1142,8 +1248,11 @@ public abstract class Player extends Avatar implements ContainerUser { && !(nearby instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(nearby) < 9.0) { float enchantedDamage = this.getEnchantedDamage(nearby, var12, damageSource) * attackStrengthScale; @@ -348,7 +356,7 @@ EnchantmentHelper.doPostAttackEffects(serverLevel, nearby, damageSource); } } -@@ -1176,7 +_,16 @@ +@@ -1176,7 +1285,16 @@ public abstract class Player extends Avatar implements ContainerUser { public boolean stabAttack( final EquipmentSlot slot, final Entity target, float baseDamage, final boolean dealsDamage, final boolean dealsKnockback, final boolean dismounts ) { @@ -366,7 +374,7 @@ return false; } else { ItemStack weaponItem = this.getItemBySlot(slot); -@@ -1187,7 +_,8 @@ +@@ -1187,7 +1305,8 @@ public abstract class Player extends Avatar implements ContainerUser { baseDamage *= this.baseDamageScaleFactor(); } @@ -376,7 +384,7 @@ return true; } else { float totalDamage = dealsDamage ? baseDamage + magicBoost : 0.0F; -@@ -1215,7 +_,7 @@ +@@ -1215,7 +1334,7 @@ public abstract class Player extends Avatar implements ContainerUser { this.setLastHurtMob(target); this.itemAttackInteraction(target, weaponItem, damageSource, wasHurt); this.damageStatsAndHearts(target, oldLivingEntityHealth); @@ -385,7 +393,7 @@ return true; } } -@@ -1226,8 +_,8 @@ +@@ -1226,8 +1345,8 @@ public abstract class Player extends Avatar implements ContainerUser { } @Override @@ -396,7 +404,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1295,6 +_,12 @@ +@@ -1295,6 +1414,12 @@ public abstract class Player extends Avatar implements ContainerUser { } public Either startSleepInBed(final BlockPos pos) { @@ -409,7 +417,7 @@ this.startSleeping(pos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1411,7 +_,7 @@ +@@ -1411,7 +1536,7 @@ public abstract class Player extends Avatar implements ContainerUser { @Override public boolean causeFallDamage(final double fallDistance, final float damageModifier, final DamageSource damageSource) { @@ -418,7 +426,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1432,7 +_,15 @@ +@@ -1432,7 +1557,15 @@ public abstract class Player extends Avatar implements ContainerUser { } public void startFallFlying() { @@ -434,7 +442,7 @@ } @Override -@@ -1530,7 +_,7 @@ +@@ -1530,7 +1663,7 @@ public abstract class Player extends Avatar implements ContainerUser { if (amount > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float vol = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -443,7 +451,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1538,15 +_,35 @@ +@@ -1538,15 +1671,35 @@ public abstract class Player extends Avatar implements ContainerUser { public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -481,14 +489,13 @@ } } } -@@ -1807,10 +_,39 @@ +@@ -1807,10 +1960,39 @@ public abstract class Player extends Avatar implements ContainerUser { } @Override - public void onAttack() { - this.resetOnlyAttackStrengthTicker(); - super.onAttack(); -- } + // Paper start + public void onAttack(@Nullable Entity entity) { + if (entity != null) { @@ -520,12 +527,12 @@ + + this.lastItemInMainHand = mainHandItem.copy(); + } -+ } + } + // Paper end - Force update attributes. public void resetOnlyAttackStrengthTicker() { this.attackStrengthTicker = 0; -@@ -1843,17 +_,32 @@ +@@ -1843,17 +2025,32 @@ public abstract class Player extends Avatar implements ContainerUser { return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -560,7 +567,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack itemStack = this.inventory.getItem(i); -@@ -1862,6 +_,7 @@ +@@ -1862,6 +2059,7 @@ public abstract class Player extends Avatar implements ContainerUser { } } @@ -568,7 +575,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -2025,5 +_,6 @@ +@@ -2025,5 +2223,6 @@ public abstract class Player extends Avatar implements ContainerUser { public static final Player.BedSleepingProblem OBSTRUCTED = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.obstructed")); public static final Player.BedSleepingProblem OTHER_PROBLEM = new Player.BedSleepingProblem(null); public static final Player.BedSleepingProblem NOT_SAFE = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.not_safe")); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch index ffa721197df7..ce6f6b2df7b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java +index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f219d82e191 100644 --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -44,6 +_,7 @@ +@@ -44,6 +44,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { private boolean leftOwnerChecked; public boolean hasBeenShot = false; private @Nullable Entity lastDeflectedBy; @@ -8,7 +16,7 @@ protected Projectile(final EntityType type, final Level level) { super(type, level); -@@ -83,6 +_,7 @@ +@@ -83,6 +84,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { @Override protected void readAdditionalSaveData(final ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); @@ -16,7 +24,7 @@ this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } -@@ -155,7 +_,14 @@ +@@ -155,7 +157,14 @@ public abstract class Projectile extends Entity implements TraceableEntity { float zd = Mth.cos(yRot * Mth.DEG_TO_RAD) * Mth.cos(xRot * Mth.DEG_TO_RAD); this.shoot(xd, yd, zd, pow, uncertainty); Vec3 sourceMovement = source.getKnownMovement(); @@ -31,7 +39,7 @@ } @Override -@@ -181,7 +_,20 @@ +@@ -181,7 +190,20 @@ public abstract class Projectile extends Entity implements TraceableEntity { final float pow, final float uncertainty ) { @@ -53,7 +61,7 @@ creator.create(serverLevel, source, itemStack), serverLevel, itemStack, -@@ -215,7 +_,22 @@ +@@ -215,7 +237,22 @@ public abstract class Projectile extends Entity implements TraceableEntity { final float pow, final float uncertainty ) { @@ -77,7 +85,7 @@ } public static T spawnProjectile(final T projectile, final ServerLevel serverLevel, final ItemStack itemStack) { -@@ -225,11 +_,46 @@ +@@ -225,12 +262,47 @@ public abstract class Projectile extends Entity implements TraceableEntity { public static T spawnProjectile( final T projectile, final ServerLevel serverLevel, final ItemStack itemStack, final Consumer shootFunction ) { @@ -85,7 +93,6 @@ - serverLevel.addFreshEntity(projectile); - projectile.applyOnProjectileSpawned(serverLevel, itemStack); - return projectile; -- } + // Paper start - delayed projectile spawning + return spawnProjectileDelayed(projectile, serverLevel, itemStack, shootFunction).spawn(); + } @@ -94,8 +101,8 @@ + // Paper end - delayed projectile spawning + adapter.accept(projectile); + return new Delayed<>(projectile, serverLevel, itemStack); // Paper - delayed projectile spawning -+ } -+ + } + + // Paper start - delayed projectile spawning + public record Delayed( + T projectile, @@ -126,10 +133,11 @@ + } + } + // Paper end - delayed projectile spawning - ++ public void applyOnProjectileSpawned(final ServerLevel serverLevel, final ItemStack pickupItemStack) { EnchantmentHelper.onProjectileSpawned(serverLevel, pickupItemStack, this, item -> {}); -@@ -241,6 +_,17 @@ + if (this instanceof AbstractArrow arrow) { +@@ -241,6 +313,17 @@ public abstract class Projectile extends Entity implements TraceableEntity { } } @@ -147,7 +155,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(final HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -313,15 +_,35 @@ +@@ -313,15 +396,35 @@ public abstract class Projectile extends Entity implements TraceableEntity { } protected void onHitBlock(final BlockHitResult hitResult) { @@ -183,7 +191,7 @@ return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(entity); } } -@@ -334,13 +_,7 @@ +@@ -334,13 +437,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { } protected static float lerpRotation(float rotO, final float rot) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch index 0258d237ed0b..6f85aeca7f8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java +index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9ef5e0dbb4 100644 --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -63,6 +_,12 @@ +@@ -63,6 +63,12 @@ import net.minecraft.world.phys.Vec3; import org.jspecify.annotations.Nullable; public class Raid { @@ -13,7 +21,7 @@ public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityType.RAVAGER); public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( i -> i.group( -@@ -78,6 +_,8 @@ +@@ -78,6 +84,8 @@ public class Raid { Raid.RaidStatus.CODEC.fieldOf("status").forGetter(r -> r.status), BlockPos.CODEC.fieldOf("center").forGetter(r -> r.center), UUIDUtil.CODEC_SET.fieldOf("heroes_of_the_village").forGetter(r -> r.heroesOfTheVillage) @@ -22,7 +30,7 @@ ) .apply(i, Raid::new) ); -@@ -131,6 +_,7 @@ +@@ -131,6 +139,7 @@ public class Raid { this.center = center; this.numGroups = this.getNumGroups(difficulty); this.status = Raid.RaidStatus.ONGOING; @@ -30,7 +38,7 @@ } private Raid( -@@ -146,6 +_,7 @@ +@@ -146,6 +155,7 @@ public class Raid { final Raid.RaidStatus status, final BlockPos center, final Set heroesOfTheVillage @@ -38,7 +46,7 @@ ) { this.started = started; this.active = active; -@@ -159,6 +_,7 @@ +@@ -159,6 +169,7 @@ public class Raid { this.numGroups = numGroups; this.status = status; this.heroesOfTheVillage.addAll(heroesOfTheVillage); @@ -46,7 +54,7 @@ } public boolean isOver() { -@@ -185,6 +_,12 @@ +@@ -185,6 +196,12 @@ public class Raid { return this.status == Raid.RaidStatus.LOSS; } @@ -59,7 +67,7 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -271,6 +_,7 @@ +@@ -271,6 +288,7 @@ public class Raid { boolean oldActive = this.active; this.active = level.hasChunkAt(this.center); if (level.getDifficulty() == Difficulty.PEACEFUL) { @@ -67,7 +75,7 @@ this.stop(); return; } -@@ -290,13 +_,16 @@ +@@ -290,13 +308,16 @@ public class Raid { if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; @@ -84,7 +92,7 @@ this.stop(); return; } -@@ -385,6 +_,7 @@ +@@ -385,6 +406,7 @@ public class Raid { } if (attempt > 5) { @@ -92,7 +100,7 @@ this.stop(); break; } -@@ -396,6 +_,7 @@ +@@ -396,6 +418,7 @@ public class Raid { } else { this.status = Raid.RaidStatus.VICTORY; @@ -100,7 +108,7 @@ for (UUID heroUUID : this.heroesOfTheVillage) { Entity entity = level.getEntity(heroUUID); if (entity instanceof LivingEntity hero && !entity.isSpectator()) { -@@ -403,9 +_,11 @@ +@@ -403,9 +426,11 @@ public class Raid { if (hero instanceof ServerPlayer playerHero) { playerHero.awardStat(Stats.RAID_WIN); CriteriaTriggers.RAID_WIN.trigger(playerHero); @@ -112,7 +120,7 @@ } } -@@ -413,6 +_,7 @@ +@@ -413,6 +438,7 @@ public class Raid { } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { @@ -120,7 +128,7 @@ this.stop(); return; } -@@ -568,6 +_,7 @@ +@@ -568,6 +594,7 @@ public class Raid { this.groupsSpawned++; this.updateBossbar(); this.setDirty(level); @@ -128,7 +136,7 @@ } public void joinRaid(final ServerLevel level, final int groupNumber, final Raider raider, final @Nullable BlockPos pos, final boolean exists) { -@@ -582,7 +_,7 @@ +@@ -582,7 +609,7 @@ public class Raid { raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); raider.applyRaidBuffs(level, groupNumber, false); raider.setOnGround(true); @@ -137,16 +145,16 @@ } } } -@@ -809,6 +_,12 @@ - public void addHeroOfTheVillage(final Entity killer) { +@@ -810,6 +837,12 @@ public class Raid { this.heroesOfTheVillage.add(killer.getUUID()); } -+ + + // CraftBukkit start - a method to get all raiders + public java.util.Collection getRaiders() { + return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); + } + // CraftBukkit end - ++ private static enum RaidStatus implements StringRepresentable { ONGOING("ongoing"), + VICTORY("victory"), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch index 64840baa8750..a4957216ce8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/raid/Raids.java b/net/minecraft/world/entity/raid/Raids.java +index e5f7c6ada9102345b2e86bc24797686dd325b3fd..d5d3c86327d8feefb9fa2a3330bcb4dbdc629342 100644 --- a/net/minecraft/world/entity/raid/Raids.java +++ b/net/minecraft/world/entity/raid/Raids.java -@@ -52,6 +_,7 @@ +@@ -52,6 +52,7 @@ public class Raids extends SavedData { private Raids(final List raids, final int nextId, final int tick) { for (Raids.RaidWithId raid : raids) { this.raidMap.put(raid.id, raid.raid); @@ -8,7 +16,7 @@ } this.nextId = nextId; -@@ -130,11 +_,23 @@ +@@ -130,11 +131,23 @@ public class Raids extends SavedData { } Raid raid = this.getOrCreateRaid(level, raidCenterPos); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch index 46cf3ef454f7..028542407c1f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/vehicle/VehicleEntity.java b/net/minecraft/world/entity/vehicle/VehicleEntity.java +index 45788af36374c01d846721d2530fe544671a8801..0e0fdc3cc76d6f0798daf0ccf4bcb6a3785c7216 100644 --- a/net/minecraft/world/entity/vehicle/VehicleEntity.java +++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java -@@ -32,12 +_,22 @@ +@@ -32,12 +32,22 @@ public abstract class VehicleEntity extends Entity { } @Override @@ -24,7 +32,7 @@ this.setHurtDir(-this.getHurtDir()); this.setHurtTime(10); this.markHurt(); -@@ -46,9 +_,23 @@ +@@ -46,9 +56,23 @@ public abstract class VehicleEntity extends Entity { boolean creativePlayer = source.getEntity() instanceof Player player && player.getAbilities().instabuild; if ((creativePlayer || !(this.getDamage() > 40.0F)) && !this.shouldSourceDestroy(source)) { if (creativePlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index bbf4cca13b12..b3458d661b41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java +index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b6504b1b9 100644 --- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java -@@ -482,6 +_,12 @@ +@@ -482,6 +482,12 @@ public class NewMinecartBehavior extends MinecartBehavior { @Override public double getMaxSpeed(final ServerLevel level) { @@ -13,7 +21,7 @@ return level.getGameRules().get(GameRules.MAX_MINECART_SPEED).intValue() * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } -@@ -497,7 +_,8 @@ +@@ -497,7 +503,8 @@ public class NewMinecartBehavior extends MinecartBehavior { @Override public double getSlowdownFactor() { @@ -23,7 +31,7 @@ } @Override -@@ -521,6 +_,13 @@ +@@ -521,6 +528,13 @@ public class NewMinecartBehavior extends MinecartBehavior { && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -37,7 +45,7 @@ boolean pickedUp = entity.startRiding(this.minecart); if (pickedUp) { return true; -@@ -544,6 +_,17 @@ +@@ -544,6 +558,17 @@ public class NewMinecartBehavior extends MinecartBehavior { || entity instanceof AbstractMinecart || this.minecart.isVehicle() || entity.isPassenger()) { @@ -55,7 +63,7 @@ entity.push(this.minecart); pushed = true; } -@@ -552,6 +_,15 @@ +@@ -552,6 +577,15 @@ public class NewMinecartBehavior extends MinecartBehavior { } else { for (Entity entityx : this.level().getEntities(this.minecart, hitbox)) { if (!this.minecart.hasPassenger(entityx) && entityx.isPushable() && entityx instanceof AbstractMinecart) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch rename to paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch index 891b315c2eb6..7e050a70bd9c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java +index f150b4c73870546cd639199d150416a263c87ae5..630677ccc0276882169265e1f7aa63ed0fdd86a3 100644 --- a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java -@@ -375,8 +_,22 @@ +@@ -375,8 +375,22 @@ public class OldMinecartBehavior extends MinecartBehavior { && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -23,7 +31,7 @@ entity.push(this.minecart); } } -@@ -384,6 +_,12 @@ +@@ -384,6 +398,12 @@ public class OldMinecartBehavior extends MinecartBehavior { } else { for (Entity entityx : this.level().getEntities(this.minecart, hitbox)) { if (!this.minecart.hasPassenger(entityx) && entityx.isPushable() && entityx instanceof AbstractMinecart) { @@ -36,7 +44,7 @@ entityx.push(this.minecart); } } -@@ -406,11 +_,18 @@ +@@ -406,11 +426,18 @@ public class OldMinecartBehavior extends MinecartBehavior { @Override public double getMaxSpeed(final ServerLevel level) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index aa16cc30a100..90c5470eb49f 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java +index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8dbaa198e17 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -65,6 +_,35 @@ +@@ -65,6 +65,35 @@ public abstract class AbstractContainerMenu { private final List containerListeners = Lists.newArrayList(); private @Nullable ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; @@ -36,12 +44,10 @@ protected AbstractContainerMenu(final @Nullable MenuType menuType, final int containerId) { this.menuType = menuType; -@@ -176,8 +_,43 @@ +@@ -176,8 +205,43 @@ public abstract class AbstractContainerMenu { if (this.synchronizer != null) { this.synchronizer.sendInitialData(this, itemsToSend, carried.copy(), this.remoteDataSlots.toIntArray()); -- } -- } + this.synchronizer.sendOffHandSlotChange(); // Paper - Sync offhand slot in menus; update player's offhand since the offhand slot is not added to the slots for menus but can be changed by swapping from a menu slot + } + } @@ -66,8 +72,8 @@ + + if (this.synchronizer != null) { + this.synchronizer.sendSlotChange(this, slotsIndex, item.copy()); -+ } -+ } + } + } + // Paper end + + // CraftBukkit start - from synchronizeCarriedToRemote @@ -82,7 +88,7 @@ public void removeSlotListener(final ContainerListener listener) { this.containerListeners.remove(listener); -@@ -243,7 +_,7 @@ +@@ -243,7 +307,7 @@ public abstract class AbstractContainerMenu { this.lastSlots.set(i, newItem); for (ContainerListener containerListener : this.containerListeners) { @@ -91,7 +97,7 @@ } } } -@@ -351,6 +_,7 @@ +@@ -351,6 +415,7 @@ public abstract class AbstractContainerMenu { this.resetQuickCraft(); } } else if (this.quickcraftStatus == QUICKCRAFT_HEADER_CONTINUE) { @@ -99,7 +105,7 @@ Slot slot = this.slots.get(slotIndex); ItemStack carriedItemStack = this.getCarried(); if (canItemQuickReplace(slot, carriedItemStack, true) -@@ -375,6 +_,7 @@ +@@ -375,6 +440,7 @@ public abstract class AbstractContainerMenu { } int remaining = this.getCarried().getCount(); @@ -107,21 +113,18 @@ for (Slot slot : this.quickcraftSlots) { ItemStack carriedItemStack = this.getCarried(); -@@ -387,12 +_,42 @@ +@@ -387,12 +453,42 @@ public abstract class AbstractContainerMenu { int maxSize = Math.min(source.getMaxStackSize(), slot.getMaxStackSize(source)); int newCount = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots.size(), this.quickcraftType, source) + carry, maxSize); remaining -= newCount - carry; - slot.setByPlayer(source.copyWithCount(newCount)); -- } -- } -- -- source.setCount(remaining); -- this.setCarried(source); + // slot.setByPlayer(source.copyWithCount(newCount)); + draggedSlots.put(slot.index, source.copyWithCount(newCount)); // CraftBukkit - Put in map instead of setting -+ } -+ } -+ + } + } + +- source.setCount(remaining); +- this.setCarried(source); + // CraftBukkit start - InventoryDragEvent + org.bukkit.inventory.InventoryView view = this.getBukkitView(); + org.bukkit.inventory.ItemStack newCarried = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(source); @@ -156,7 +159,7 @@ } this.resetQuickCraft(); -@@ -406,8 +_,11 @@ +@@ -406,8 +502,11 @@ public abstract class AbstractContainerMenu { if (slotIndex == -999) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { @@ -169,7 +172,7 @@ } else { player.drop(this.getCarried().split(1), true); } -@@ -469,8 +_,18 @@ +@@ -469,8 +568,18 @@ public abstract class AbstractContainerMenu { } slotx.setChanged(); @@ -188,7 +191,7 @@ ItemStack source = inventory.getItem(buttonNum); Slot target = this.slots.get(slotIndex); ItemStack targetItemStack = target.getItem(); -@@ -530,7 +_,11 @@ +@@ -530,7 +639,11 @@ public abstract class AbstractContainerMenu { } itemStack = slotx.safeTake(amount, Integer.MAX_VALUE, player); @@ -201,7 +204,7 @@ player.handleCreativeModeItemDrop(itemStack); } } -@@ -595,14 +_,15 @@ +@@ -595,14 +708,15 @@ public abstract class AbstractContainerMenu { if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -219,7 +222,7 @@ boolean serverPlayerHasDisconnected = player instanceof ServerPlayer serverPlayer && serverPlayer.hasDisconnected(); if (playerRemovedNotChangingDimension || serverPlayerHasDisconnected) { player.drop(carried, false); -@@ -642,6 +_,14 @@ +@@ -642,6 +756,14 @@ public abstract class AbstractContainerMenu { public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(final ItemStack itemStack, final int startSlot, final int endSlot, final boolean backwards) { @@ -234,7 +237,7 @@ boolean anythingChanged = false; int destSlot = startSlot; if (backwards) { -@@ -652,18 +_,27 @@ +@@ -652,18 +774,27 @@ public abstract class AbstractContainerMenu { while (!itemStack.isEmpty() && (backwards ? destSlot >= startSlot : destSlot < endSlot)) { Slot slot = this.slots.get(destSlot); ItemStack target = slot.getItem(); @@ -262,7 +265,7 @@ anythingChanged = true; } } -@@ -686,10 +_,21 @@ +@@ -686,10 +817,21 @@ public abstract class AbstractContainerMenu { while (backwards ? destSlot >= startSlot : destSlot < endSlot) { Slot slotx = this.slots.get(destSlot); ItemStack targetx = slotx.getItem(); @@ -284,7 +287,7 @@ anythingChanged = true; break; } -@@ -773,6 +_,11 @@ +@@ -773,6 +915,11 @@ public abstract class AbstractContainerMenu { } public ItemStack getCarried() { @@ -296,7 +299,7 @@ return this.carried; } -@@ -826,4 +_,15 @@ +@@ -826,4 +973,15 @@ public abstract class AbstractContainerMenu { this.stateId = this.stateId + 1 & 32767; return this.stateId; } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch index 06b1bf622dd2..efff8ab3d176 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/BeaconMenu.java b/net/minecraft/world/inventory/BeaconMenu.java +index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23aeb12435 100644 --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -23,24 +_,14 @@ +@@ -23,24 +23,14 @@ public class BeaconMenu extends AbstractContainerMenu { private static final int USE_ROW_SLOT_START = 28; private static final int USE_ROW_SLOT_END = 37; private static final int NO_EFFECT = 0; @@ -30,7 +38,7 @@ public BeaconMenu(final int containerId, final Container inventory) { this(containerId, inventory, new SimpleContainerData(3), ContainerLevelAccess.NULL); -@@ -48,6 +_,25 @@ +@@ -48,6 +38,25 @@ public class BeaconMenu extends AbstractContainerMenu { public BeaconMenu(final int containerId, final Container inventory, final ContainerData beaconData, final ContainerLevelAccess access) { super(MenuType.BEACON, containerId); @@ -56,7 +64,7 @@ checkContainerDataCount(beaconData, 3); this.beaconData = beaconData; this.access = access; -@@ -70,6 +_,7 @@ +@@ -70,6 +79,7 @@ public class BeaconMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { @@ -64,7 +72,7 @@ return stillValid(this.access, player, Blocks.BEACON); } -@@ -143,13 +_,30 @@ +@@ -143,13 +153,30 @@ public class BeaconMenu extends AbstractContainerMenu { public @Nullable Holder getSecondaryEffect() { return decodeEffect(this.beaconData.get(2)); } @@ -98,7 +106,7 @@ } } -@@ -172,4 +_,17 @@ +@@ -172,4 +199,17 @@ public class BeaconMenu extends AbstractContainerMenu { return 1; } } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch index 6a8a2dbc42a4..7f1cc555db5d 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/CartographyTableMenu.java b/net/minecraft/world/inventory/CartographyTableMenu.java +index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5b43c8a8b 100644 --- a/net/minecraft/world/inventory/CartographyTableMenu.java +++ b/net/minecraft/world/inventory/CartographyTableMenu.java -@@ -16,6 +_,21 @@ +@@ -16,6 +16,21 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; public class CartographyTableMenu extends AbstractContainerMenu { @@ -22,7 +30,7 @@ public static final int MAP_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; public static final int RESULT_SLOT = 2; -@@ -25,28 +_,8 @@ +@@ -25,28 +40,8 @@ public class CartographyTableMenu extends AbstractContainerMenu { private static final int USE_ROW_SLOT_END = 39; private final ContainerLevelAccess access; private long lastSoundTime; @@ -53,7 +61,7 @@ public CartographyTableMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -54,6 +_,34 @@ +@@ -54,6 +49,34 @@ public class CartographyTableMenu extends AbstractContainerMenu { public CartographyTableMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.CARTOGRAPHY_TABLE, containerId); @@ -88,7 +96,7 @@ this.access = access; this.addSlot(new Slot(this.container, 0, 15, 15) { { -@@ -101,10 +_,12 @@ +@@ -101,10 +124,12 @@ public class CartographyTableMenu extends AbstractContainerMenu { } }); this.addStandardInventorySlots(inventory, 8, 84); @@ -101,7 +109,7 @@ return stillValid(this.access, player, Blocks.CARTOGRAPHY_TABLE); } -@@ -120,6 +_,7 @@ +@@ -120,6 +145,7 @@ public class CartographyTableMenu extends AbstractContainerMenu { } else { this.resultContainer.removeItemNoUpdate(2); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 9e4ceb9aedc1..154aad422eab 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/EnchantmentMenu.java b/net/minecraft/world/inventory/EnchantmentMenu.java +index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1d7965823 100644 --- a/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -32,23 +_,17 @@ +@@ -32,23 +32,17 @@ import net.minecraft.world.level.block.EnchantingTableBlock; public class EnchantmentMenu extends AbstractContainerMenu { private static final Identifier EMPTY_SLOT_LAPIS_LAZULI = Identifier.withDefaultNamespace("container/slot/lapis_lazuli"); @@ -29,7 +37,7 @@ public EnchantmentMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -56,6 +_,22 @@ +@@ -56,6 +50,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { public EnchantmentMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.ENCHANTMENT, containerId); @@ -52,7 +60,7 @@ this.access = access; this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { { -@@ -93,13 +_,14 @@ +@@ -93,13 +103,14 @@ public class EnchantmentMenu extends AbstractContainerMenu { this.addDataSlot(DataSlot.shared(this.levelClue, 0)); this.addDataSlot(DataSlot.shared(this.levelClue, 1)); this.addDataSlot(DataSlot.shared(this.levelClue, 2)); @@ -68,7 +76,7 @@ this.access.execute((level, pos) -> { IdMap> holders = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int bookcases = 0; -@@ -132,6 +_,42 @@ +@@ -132,6 +143,42 @@ public class EnchantmentMenu extends AbstractContainerMenu { } } @@ -111,7 +119,7 @@ this.broadcastChanges(); }); } else { -@@ -158,19 +_,52 @@ +@@ -158,19 +205,52 @@ public class EnchantmentMenu extends AbstractContainerMenu { return false; } else { this.access.execute((level, pos) -> { @@ -119,6 +127,9 @@ + ItemStack enchantmentItem = itemStack; // Paper - diff on change List newEnchantment = this.getEnchantmentList(level.registryAccess(), itemStack, buttonId, this.costs[buttonId]); - if (!newEnchantment.isEmpty()) { +- player.onEnchantmentPerformed(itemStack, enchantmentCost); +- if (itemStack.is(Items.BOOK)) { +- enchantmentItem = itemStack.transmuteCopy(Items.ENCHANTED_BOOK); + // CraftBukkit start + IdMap> registry = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + if (true || !newEnchantment.isEmpty()) { @@ -142,8 +153,8 @@ + // Paper start + enchantmentItem = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(craftItemStack, event.getItem()); + if (enchantmentItem != itemStack) { -+ this.enchantSlots.setItem(0, enchantmentItem); -+ } + this.enchantSlots.setItem(0, enchantmentItem); + } + if (enchantmentItem.is(Items.BOOK)) { + enchantmentItem = enchantmentItem.transmuteCopy(Items.ENCHANTED_BOOK); + this.enchantSlots.setItem(0, enchantmentItem); @@ -156,26 +167,19 @@ + if (enchantment == null) { + continue; + } -+ -+ enchantmentItem.enchant(enchantment, entry.getValue()); -+ } -+ // CraftBukkit end - player.onEnchantmentPerformed(itemStack, enchantmentCost); -- if (itemStack.is(Items.BOOK)) { -- enchantmentItem = itemStack.transmuteCopy(Items.ENCHANTED_BOOK); -- this.enchantSlots.setItem(0, enchantmentItem); -- } -- + - for (EnchantmentInstance enchantment : newEnchantment) { - enchantmentItem.enchant(enchantment.enchantment(), enchantment.level()); -- } -- -+ ++ enchantmentItem.enchant(enchantment, entry.getValue()); + } ++ // CraftBukkit end ++ player.onEnchantmentPerformed(itemStack, enchantmentCost); + + // CraftBukkit - TODO: let plugins change this currency.consume(enchantmentCost, player); if (currency.isEmpty()) { this.enchantSlots.setItem(1, ItemStack.EMPTY); -@@ -215,6 +_,12 @@ +@@ -215,6 +295,12 @@ public class EnchantmentMenu extends AbstractContainerMenu { return goldStack.isEmpty() ? 0 : goldStack.getCount(); } @@ -188,7 +192,7 @@ public int getEnchantmentSeed() { return this.enchantmentSeed.get(); } -@@ -227,6 +_,7 @@ +@@ -227,6 +313,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { @@ -196,7 +200,7 @@ return stillValid(this.access, player, Blocks.ENCHANTING_TABLE); } -@@ -274,4 +_,17 @@ +@@ -274,4 +361,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { return clicked; } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 62e740e61299..37cec610efb4 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/GrindstoneMenu.java b/net/minecraft/world/inventory/GrindstoneMenu.java +index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da0736342c8b 100644 --- a/net/minecraft/world/inventory/GrindstoneMenu.java +++ b/net/minecraft/world/inventory/GrindstoneMenu.java -@@ -22,6 +_,21 @@ +@@ -22,6 +22,21 @@ import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.phys.Vec3; public class GrindstoneMenu extends AbstractContainerMenu { @@ -22,7 +30,7 @@ public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -30,18 +_,8 @@ +@@ -30,18 +45,8 @@ public class GrindstoneMenu extends AbstractContainerMenu { private static final int INV_SLOT_END = 30; private static final int USE_ROW_SLOT_START = 30; private static final int USE_ROW_SLOT_END = 39; @@ -43,7 +51,7 @@ private final ContainerLevelAccess access; public GrindstoneMenu(final int containerId, final Inventory inventory) { -@@ -50,6 +_,22 @@ +@@ -50,6 +55,22 @@ public class GrindstoneMenu extends AbstractContainerMenu { public GrindstoneMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.GRINDSTONE, containerId); @@ -66,7 +74,7 @@ this.access = access; this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { { -@@ -85,7 +_,11 @@ +@@ -85,7 +106,11 @@ public class GrindstoneMenu extends AbstractContainerMenu { public void onTake(final Player player, final ItemStack carried) { access.execute((level, pos) -> { if (level instanceof ServerLevel) { @@ -79,7 +87,7 @@ } level.levelEvent(LevelEvent.SOUND_GRINDSTONE_USED, pos, 0); -@@ -122,6 +_,7 @@ +@@ -122,6 +147,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { } }); this.addStandardInventorySlots(inventory, 8, 84); @@ -87,7 +95,7 @@ } @Override -@@ -129,11 +_,13 @@ +@@ -129,11 +155,13 @@ public class GrindstoneMenu extends AbstractContainerMenu { super.slotsChanged(container); if (container == this.repairSlots) { this.createResult(); @@ -102,7 +110,7 @@ this.broadcastChanges(); } -@@ -221,6 +_,7 @@ +@@ -221,6 +249,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch index dc86a706abf5..533e59d310b0 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/ItemCombinerMenu.java b/net/minecraft/world/inventory/ItemCombinerMenu.java +index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df608ef810 100644 --- a/net/minecraft/world/inventory/ItemCombinerMenu.java +++ b/net/minecraft/world/inventory/ItemCombinerMenu.java -@@ -16,16 +_,7 @@ +@@ -16,16 +16,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { protected final ContainerLevelAccess access; protected final Player player; protected final Container inputSlots; @@ -18,7 +26,7 @@ private final int resultSlotIndex; protected boolean mayPickup(final Player player, final boolean hasItem) { -@@ -45,6 +_,18 @@ +@@ -45,6 +36,18 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { ) { super(menuType, containerId); this.access = access; @@ -37,7 +45,7 @@ this.player = inventory.player; this.inputSlots = this.createContainer(itemInputSlots.getNumOfInputSlots()); this.resultSlotIndex = itemInputSlots.getResultSlotIndex(); -@@ -54,15 +_,15 @@ +@@ -54,15 +57,15 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { } private void createInputSlots(final ItemCombinerMenuSlotDefinition itemInputSlots) { @@ -56,7 +64,7 @@ } }); } -@@ -96,7 +_,7 @@ +@@ -96,7 +99,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { public abstract void createResult(); private SimpleContainer createContainer(final int size) { @@ -65,7 +73,7 @@ { Objects.requireNonNull(ItemCombinerMenu.this); } -@@ -114,6 +_,7 @@ +@@ -114,6 +117,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { super.slotsChanged(container); if (container == this.inputSlots) { this.createResult(); @@ -73,7 +81,7 @@ } } -@@ -125,6 +_,7 @@ +@@ -125,6 +129,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch index dc23de136d67..838a0a6a4e10 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch @@ -1,19 +1,23 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/LecternMenu.java b/net/minecraft/world/inventory/LecternMenu.java +index ae2b95dae3d57d53721a5da27db6c8a739a7a51e..8b8c60726facd1f0b93779bd44d7a3e879fd4086 100644 --- a/net/minecraft/world/inventory/LecternMenu.java +++ b/net/minecraft/world/inventory/LecternMenu.java -@@ -15,12 +_,29 @@ +@@ -15,12 +15,29 @@ public class LecternMenu extends AbstractContainerMenu { public static final int BUTTON_PAGE_JUMP_RANGE_START = 100; private final Container lectern; private final ContainerData lecternData; -- -- public LecternMenu(final int containerId) { -- this(containerId, new SimpleContainer(1), new SimpleContainerData(1)); -- } -- -- public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData) { + // CraftBukkit start + private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLecternView view = null; + private final org.bukkit.entity.Player player; -+ + +- public LecternMenu(final int containerId) { +- this(containerId, new SimpleContainer(1), new SimpleContainerData(1)); + @Override + public org.bukkit.craftbukkit.inventory.view.CraftLecternView getBukkitView() { + if (this.view != null) { @@ -23,9 +27,10 @@ + org.bukkit.craftbukkit.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLectern(this.lectern); + this.view = new org.bukkit.craftbukkit.inventory.view.CraftLecternView(this.player, inventory, this); + return this.view; -+ } + } + // CraftBukkit end -+ + +- public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData) { + // CraftBukkit start - add player inventory + public LecternMenu(final int containerId, final net.minecraft.world.entity.player.Inventory inventory) { + this(containerId, new SimpleContainer(1), new SimpleContainerData(1), inventory); @@ -36,7 +41,7 @@ super(MenuType.LECTERN, containerId); checkContainerSize(lectern, 1); checkContainerDataCount(lecternData, 1); -@@ -38,10 +_,12 @@ +@@ -38,10 +55,12 @@ public class LecternMenu extends AbstractContainerMenu { } }); this.addDataSlots(lecternData); @@ -49,7 +54,7 @@ if (buttonId >= 100) { int pageToSet = buttonId - 100; this.setData(0, pageToSet); -@@ -50,12 +_,26 @@ +@@ -50,12 +69,26 @@ public class LecternMenu extends AbstractContainerMenu { switch (buttonId) { case 1: { int currentPage = this.lecternData.get(0); @@ -78,7 +83,7 @@ return true; } case 3: -@@ -63,6 +_,12 @@ +@@ -63,6 +96,12 @@ public class LecternMenu extends AbstractContainerMenu { return false; } @@ -91,7 +96,7 @@ ItemStack book = this.lectern.removeItemNoUpdate(0); this.lectern.setChanged(); if (!player.getInventory().add(book)) { -@@ -89,6 +_,8 @@ +@@ -89,6 +128,8 @@ public class LecternMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch index 4e4bf954797f..5649ec42ebb9 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/LoomMenu.java b/net/minecraft/world/inventory/LoomMenu.java +index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b439a2364cc 100644 --- a/net/minecraft/world/inventory/LoomMenu.java +++ b/net/minecraft/world/inventory/LoomMenu.java -@@ -39,29 +_,23 @@ +@@ -39,29 +39,23 @@ public class LoomMenu extends AbstractContainerMenu { private final Slot patternSlot; private final Slot resultSlot; private long lastSoundTime; @@ -8,7 +16,12 @@ - { - Objects.requireNonNull(LoomMenu.this); - } -- ++ private final Container inputContainer; // Paper - Add missing InventoryHolders - move down ++ private final Container outputContainer; // Paper - Add missing InventoryHolders - move down ++ // CraftBukkit start ++ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLoomView view = null; ++ private final org.bukkit.entity.Player player; + - @Override - public void setChanged() { - super.setChanged(); @@ -19,26 +32,18 @@ - private final Container outputContainer = new SimpleContainer(1) { - { - Objects.requireNonNull(LoomMenu.this); -- } -- ++ @Override ++ public org.bukkit.craftbukkit.inventory.view.CraftLoomView getBukkitView() { ++ if (this.view != null) { ++ return this.view; + } + - @Override - public void setChanged() { - super.setChanged(); - LoomMenu.this.slotUpdateListener.run(); - } - }; -+ private final Container inputContainer; // Paper - Add missing InventoryHolders - move down -+ private final Container outputContainer; // Paper - Add missing InventoryHolders - move down -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLoomView view = null; -+ private final org.bukkit.entity.Player player; -+ -+ @Override -+ public org.bukkit.craftbukkit.inventory.view.CraftLoomView getBukkitView() { -+ if (this.view != null) { -+ return this.view; -+ } -+ + org.bukkit.craftbukkit.inventory.CraftInventoryLoom inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLoom(this.inputContainer, this.outputContainer); + this.view = new org.bukkit.craftbukkit.inventory.view.CraftLoomView(this.player, inventory, this); + return this.view; @@ -47,7 +52,7 @@ public LoomMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -70,6 +_,28 @@ +@@ -70,6 +64,28 @@ public class LoomMenu extends AbstractContainerMenu { public LoomMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.LOOM, containerId); this.access = access; @@ -76,7 +81,7 @@ this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { { Objects.requireNonNull(LoomMenu.this); -@@ -131,6 +_,7 @@ +@@ -131,6 +147,7 @@ public class LoomMenu extends AbstractContainerMenu { this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlot(this.selectedBannerPatternIndex); this.patternGetter = inventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN); @@ -84,7 +89,7 @@ } private static boolean isPatternItem(final ItemStack itemStack) { -@@ -143,14 +_,39 @@ +@@ -143,14 +160,39 @@ public class LoomMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { @@ -126,7 +131,7 @@ return true; } else { return false; -@@ -212,7 +_,8 @@ +@@ -212,7 +254,8 @@ public class LoomMenu extends AbstractContainerMenu { this.resultSlot.set(ItemStack.EMPTY); } @@ -136,7 +141,7 @@ } else { this.resultSlot.set(ItemStack.EMPTY); this.selectablePatterns = List.of(); -@@ -302,7 +_,14 @@ +@@ -302,7 +345,14 @@ public class LoomMenu extends AbstractContainerMenu { result.update( DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch rename to paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch index 8513d6e3f342..0708f1ddf11e 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/inventory/StonecutterMenu.java b/net/minecraft/world/inventory/StonecutterMenu.java +index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7db43a327 100644 --- a/net/minecraft/world/inventory/StonecutterMenu.java +++ b/net/minecraft/world/inventory/StonecutterMenu.java -@@ -26,7 +_,7 @@ +@@ -26,7 +26,7 @@ public class StonecutterMenu extends AbstractContainerMenu { private static final int USE_ROW_SLOT_START = 29; private static final int USE_ROW_SLOT_END = 38; private final ContainerLevelAccess access; @@ -9,7 +17,7 @@ private final Level level; private SelectableRecipe.SingleInputSet recipesForInput = SelectableRecipe.SingleInputSet.empty(); private ItemStack input = ItemStack.EMPTY; -@@ -34,19 +_,23 @@ +@@ -34,19 +34,23 @@ public class StonecutterMenu extends AbstractContainerMenu { final Slot inputSlot; final Slot resultSlot; private Runnable slotUpdateListener = () -> {}; @@ -17,26 +25,24 @@ - { - Objects.requireNonNull(StonecutterMenu.this); - } -- -- @Override -- public void setChanged() { -- super.setChanged(); -- StonecutterMenu.this.slotsChanged(this); -- StonecutterMenu.this.slotUpdateListener.run(); -- } -- }; -- private final ResultContainer resultContainer = new ResultContainer(); + public final Container container; // Paper - Add missing InventoryHolders - move down + private final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down + // CraftBukkit start + private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftStonecutterView view = null; + private final org.bukkit.entity.Player player; -+ + +- @Override +- public void setChanged() { +- super.setChanged(); +- StonecutterMenu.this.slotsChanged(this); +- StonecutterMenu.this.slotUpdateListener.run(); + @Override + public org.bukkit.craftbukkit.inventory.view.CraftStonecutterView getBukkitView() { + if (this.view != null) { + return this.view; -+ } + } +- }; +- private final ResultContainer resultContainer = new ResultContainer(); + + org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter(this.container, this.resultContainer); + this.view = new org.bukkit.craftbukkit.inventory.view.CraftStonecutterView(this.player, inventory, this); @@ -46,7 +52,7 @@ public StonecutterMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -56,6 +_,23 @@ +@@ -56,6 +60,23 @@ public class StonecutterMenu extends AbstractContainerMenu { super(MenuType.STONECUTTER, containerId); this.access = access; this.level = inventory.player.level(); @@ -70,7 +76,7 @@ this.inputSlot = this.addSlot(new Slot(this.container, 0, 20, 33)); this.resultSlot = this.addSlot(new Slot(this.resultContainer, 1, 143, 33) { { -@@ -92,6 +_,7 @@ +@@ -92,6 +113,7 @@ public class StonecutterMenu extends AbstractContainerMenu { }); this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlot(this.selectedRecipeIndex); @@ -78,7 +84,7 @@ } public int getSelectedRecipeIndex() { -@@ -112,6 +_,7 @@ +@@ -112,6 +134,7 @@ public class StonecutterMenu extends AbstractContainerMenu { @Override public boolean stillValid(final Player player) { @@ -86,7 +92,7 @@ return stillValid(this.access, player, Blocks.STONECUTTER); } -@@ -121,8 +_,34 @@ +@@ -121,8 +144,34 @@ public class StonecutterMenu extends AbstractContainerMenu { return false; } else { if (this.isValidRecipeIndex(buttonId)) { @@ -123,7 +129,7 @@ } return true; -@@ -140,6 +_,7 @@ +@@ -140,6 +189,7 @@ public class StonecutterMenu extends AbstractContainerMenu { this.input = input.copy(); this.setupRecipeList(input); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch index 2d44e2ce4371..c5f7697237fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java +index d671a17f3b76aa7fdf0b1f0d0640b74cd6868ff2..4b4cc75640cc567a74c99ec8653436b2f2a50df6 100644 --- a/net/minecraft/world/item/ArmorStandItem.java +++ b/net/minecraft/world/item/ArmorStandItem.java -@@ -45,6 +_,12 @@ +@@ -45,6 +45,12 @@ public class ArmorStandItem extends Item { float yRot = Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), yRot, 0.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch similarity index 61% rename from paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch index 167b36275867..744e07733e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/AxeItem.java b/net/minecraft/world/item/AxeItem.java +index 8d5fbffd9fbb8be137ec70c34263f879bbf1a17c..8fef4d23fdc70471055b389f80aa5bee4a63ff60 100644 --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -70,6 +_,11 @@ +@@ -70,6 +70,11 @@ public class AxeItem extends Item { return InteractionResult.PASS; } else { ItemStack itemInHand = context.getItemInHand(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch index b528d26d3d34..f128bae41332 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java +index acaf4d183b3a358d906ce87918cfdd2df19efaab..3167be4b7c2c61ef725af4a832d759ab6e061af0 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -56,6 +_,7 @@ +@@ -56,6 +56,7 @@ public class BlockItem extends Item { return InteractionResult.FAIL; } else { BlockState placementState = this.getPlacementState(updatedPlaceContext); @@ -8,7 +16,7 @@ if (placementState == null) { return InteractionResult.FAIL; } else if (!this.placeBlock(updatedPlaceContext, placementState)) { -@@ -68,21 +_,45 @@ +@@ -68,21 +69,45 @@ public class BlockItem extends Item { BlockState placedState = level.getBlockState(pos); if (placedState.is(placementState.getBlock())) { placedState = this.updateBlockStateFromTag(pos, level, itemStack, placedState); @@ -55,7 +63,7 @@ } } } -@@ -131,8 +_,20 @@ +@@ -131,8 +156,20 @@ public class BlockItem extends Item { protected boolean canPlace(final BlockPlaceContext context, final BlockState stateForPlacement) { Player player = context.getPlayer(); @@ -78,7 +86,7 @@ } protected boolean mustSurvive() { -@@ -156,7 +_,7 @@ +@@ -156,7 +193,7 @@ public class BlockItem extends Item { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch index 2c9c26a6af7c..c1ea337e483a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java +index 3147e06c79fdaecf444574eb7b52b407012a437d..cd7f38ab2553062dcd003bd6f758e4aba77051ea 100644 --- a/net/minecraft/world/item/BoatItem.java +++ b/net/minecraft/world/item/BoatItem.java -@@ -30,7 +_,7 @@ +@@ -30,7 +30,7 @@ public class BoatItem extends Item { @Override public InteractionResult use(final Level level, final Player player, final InteractionHand hand) { ItemStack itemStack = player.getItemInHand(hand); @@ -9,7 +17,7 @@ if (hitResult.getType() == HitResult.Type.MISS) { return InteractionResult.PASS; } else { -@@ -51,6 +_,13 @@ +@@ -51,6 +51,13 @@ public class BoatItem extends Item { } if (hitResult.getType() == HitResult.Type.BLOCK) { @@ -23,7 +31,7 @@ AbstractBoat boat = this.getBoat(level, hitResult, itemStack, player); if (boat == null) { return InteractionResult.FAIL; -@@ -60,7 +_,15 @@ +@@ -60,7 +67,15 @@ public class BoatItem extends Item { return InteractionResult.FAIL; } else { if (!level.isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch similarity index 61% rename from paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch index 6fde4d9f0c9e..8a8ce83c6b4a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/BowItem.java b/net/minecraft/world/item/BowItem.java +index bdc5303cbc2b22f6e32e4122edb5058ef4d5609b..f158f8f372b14066c4bc252611a01c276982c7ac 100644 --- a/net/minecraft/world/item/BowItem.java +++ b/net/minecraft/world/item/BowItem.java -@@ -38,7 +_,7 @@ +@@ -38,7 +38,7 @@ public class BowItem extends ProjectileWeaponItem { } else { List firedProjectiles = draw(itemStack, projectile, player); if (level instanceof ServerLevel serverLevel && !firedProjectiles.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch index bcc7764e4ea5..81d80a730ad9 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/BucketItem.java b/net/minecraft/world/item/BucketItem.java +index 08c4e98fc4509afd1df06f36b3bfb5e8fb5d00c3..fbd666f3861a2a45b6ac55961543b1419c16ab9c 100644 --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -32,6 +_,7 @@ +@@ -32,6 +32,7 @@ import net.minecraft.world.phys.HitResult; import org.jspecify.annotations.Nullable; public class BucketItem extends Item implements DispensibleContainerItem { @@ -8,7 +16,7 @@ public final Fluid content; public BucketItem(final Fluid content, final Item.Properties properties) { -@@ -56,12 +_,22 @@ +@@ -56,12 +57,22 @@ public class BucketItem extends Item implements DispensibleContainerItem { } else if (this.content == Fluids.EMPTY) { BlockState blockState = level.getBlockState(pos); if (blockState.getBlock() instanceof BucketPickup bucketPickupBlock) { @@ -32,7 +40,7 @@ if (!level.isClientSide()) { CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, taken); } -@@ -74,7 +_,7 @@ +@@ -74,7 +85,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { } else { BlockState clicked = level.getBlockState(pos); BlockPos placePos = clicked.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? pos : directionOffsetPos; @@ -41,7 +49,7 @@ this.checkExtraContent(player, level, itemStack, placePos); if (player instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, placePos, itemStack); -@@ -91,6 +_,13 @@ +@@ -91,6 +102,13 @@ public class BucketItem extends Item implements DispensibleContainerItem { } public static ItemStack getEmptySuccessItem(final ItemStack itemStack, final Player player) { @@ -55,7 +63,7 @@ return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : itemStack; } -@@ -100,6 +_,12 @@ +@@ -100,6 +118,12 @@ public class BucketItem extends Item implements DispensibleContainerItem { @Override public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { @@ -68,7 +76,7 @@ if (!(this.content instanceof FlowingFluid flowingFluid)) { return false; } else { -@@ -110,8 +_,18 @@ +@@ -110,8 +134,18 @@ public class BucketItem extends Item implements DispensibleContainerItem { boolean placeLiquid = mayReplace || block instanceof LiquidBlockContainer container && container.canPlaceLiquid(user, level, pos, blockState, this.content); boolean canPlaceFluidInsideBlock = blockState.isAir() || placeLiquid && (!shiftKeyDown || hitResult == null); diff --git a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch index de368c09a9c5..b69d834479e6 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/CrossbowItem.java b/net/minecraft/world/item/CrossbowItem.java +index 7a9348c84e5ef8824dfe94f3f64d3f9c2181e800..aee675f9e2bf71ad768c000da477558588b04292 100644 --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -88,8 +_,15 @@ +@@ -88,8 +88,15 @@ public class CrossbowItem extends ProjectileWeaponItem { return getPowerForTime(timeHeld, itemStack, entity) >= 1.0F && isCharged(itemStack); } @@ -17,7 +25,7 @@ if (!drawn.isEmpty()) { heldItem.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.ofNonEmpty(drawn)); return true; -@@ -159,7 +_,11 @@ +@@ -159,7 +166,11 @@ public class CrossbowItem extends ProjectileWeaponItem { final Level level, final LivingEntity shooter, final ItemStack heldItem, final ItemStack projectile, final boolean isCrit ) { if (projectile.is(Items.FIREWORK_ROCKET)) { @@ -30,7 +38,7 @@ } else { Projectile projectileEntity = super.createProjectile(level, shooter, heldItem, projectile, isCrit); if (projectileEntity instanceof AbstractArrow arrow) { -@@ -187,7 +_,7 @@ +@@ -187,7 +198,7 @@ public class CrossbowItem extends ProjectileWeaponItem { if (level instanceof ServerLevel serverLevel) { ChargedProjectiles charged = weapon.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.EMPTY); if (charged != null && !charged.isEmpty()) { @@ -39,7 +47,7 @@ if (shooter instanceof ServerPlayer player) { CriteriaTriggers.SHOT_CROSSBOW.trigger(player, weapon); player.awardStat(Stats.ITEM_USED.get(weapon.getItem())); -@@ -227,7 +_,13 @@ +@@ -227,7 +238,13 @@ public class CrossbowItem extends ProjectileWeaponItem { .ifPresent(sound -> level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound.value(), SoundSource.PLAYERS, 0.5F, 1.0F)); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch similarity index 73% rename from paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch index 3ec27164f56d..4716a826a7a5 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/EndCrystalItem.java b/net/minecraft/world/item/EndCrystalItem.java +index 3024444b2df4dfcc37d260fdbdc12757dd0533e3..1eca60c5a3e1eeb6f44edbb81fe1af011edd8732 100644 --- a/net/minecraft/world/item/EndCrystalItem.java +++ b/net/minecraft/world/item/EndCrystalItem.java -@@ -41,11 +_,17 @@ +@@ -41,11 +41,17 @@ public class EndCrystalItem extends Item { if (level instanceof ServerLevel) { EndCrystal crystal = new EndCrystal(level, x + 0.5, y, z + 0.5); crystal.setShowBottom(false); diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch index f5c54962a93a..fc46fe615f8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/EnderEyeItem.java b/net/minecraft/world/item/EnderEyeItem.java +index b8a091a417c0433cf85f4a556e1899e17be359fc..7f0486bfe2d8d82ec853b96868f72e32771c7e36 100644 --- a/net/minecraft/world/item/EnderEyeItem.java +++ b/net/minecraft/world/item/EnderEyeItem.java -@@ -44,6 +_,11 @@ +@@ -44,6 +44,11 @@ public class EnderEyeItem extends Item { return InteractionResult.SUCCESS; } else { BlockState newState = targetState.setValue(EndPortalFrameBlock.HAS_EYE, true); @@ -12,7 +20,7 @@ Block.pushEntitiesUp(targetState, newState, level, pos); level.setBlock(pos, newState, Block.UPDATE_CLIENTS); level.updateNeighbourForOutputSignal(pos, Blocks.END_PORTAL_FRAME); -@@ -61,7 +_,27 @@ +@@ -61,7 +66,27 @@ public class EnderEyeItem extends Item { } } @@ -41,7 +49,7 @@ } return InteractionResult.SUCCESS; -@@ -91,7 +_,11 @@ +@@ -91,7 +116,11 @@ public class EnderEyeItem extends Item { eyeOfEnder.setItem(itemStack); eyeOfEnder.signalTo(Vec3.atLowerCornerOf(nearestMapFeature)); level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch index 5f39279f9604..3813da901c7d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/FireworkRocketItem.java b/net/minecraft/world/item/FireworkRocketItem.java +index b76e31894758d0fc6a24555886f5099608a40b72..0afc0916e358d4b9c9c360358a6c1aebe1ac723b 100644 --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -36,7 +_,7 @@ +@@ -36,7 +36,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem { ItemStack itemStack = context.getItemInHand(); Vec3 clickLocation = context.getClickLocation(); Direction direction = context.getClickedFace(); @@ -9,7 +17,7 @@ new FireworkRocketEntity( level, context.getPlayer(), -@@ -46,9 +_,14 @@ +@@ -46,9 +46,14 @@ public class FireworkRocketItem extends Item implements ProjectileItem { itemStack ), serverLevel, @@ -26,7 +34,7 @@ } return InteractionResult.SUCCESS; -@@ -60,13 +_,24 @@ +@@ -60,13 +65,24 @@ public class FireworkRocketItem extends Item implements ProjectileItem { if (player.isFallFlying()) { ItemStack itemStack = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch index 363bf1f36218..b1a2768ce2c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java +index 17574ae594c802d4c5ddc84397a5951b3a131191..1e30fe428914c8ae4f6caf3cb5a05ced4e183393 100644 --- a/net/minecraft/world/item/HangingEntityItem.java +++ b/net/minecraft/world/item/HangingEntityItem.java -@@ -62,6 +_,20 @@ +@@ -62,6 +62,20 @@ public class HangingEntityItem extends Item { EntityType.createDefaultStackConfig(level, itemInHand, player).accept(entity); if (entity.survives()) { if (!level.isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch index 1a8cdc021d83..0a1de049b227 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java +index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a2ac968f0 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -187,12 +_,20 @@ +@@ -187,12 +187,20 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { @Override public void encode(final RegistryFriendlyByteBuf output, final ItemStack itemStack) { @@ -23,7 +31,7 @@ } } }; -@@ -204,7 +_,7 @@ +@@ -204,7 +212,7 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { public ItemStack decode(final RegistryFriendlyByteBuf input) { ItemStack itemStack = codec.decode(input); if (!itemStack.isEmpty()) { @@ -32,7 +40,7 @@ ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -368,10 +_,165 @@ +@@ -368,10 +376,165 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { return InteractionResult.PASS; } else { Item usedItem = this.getItem(); @@ -200,7 +208,7 @@ return result; } -@@ -448,31 +_,67 @@ +@@ -448,31 +611,67 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -276,7 +284,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -485,7 +_,26 @@ +@@ -485,7 +684,26 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { return; } @@ -304,7 +312,7 @@ this.applyDamage(newDamage, serverPlayer, i -> {}); } } -@@ -495,9 +_,14 @@ +@@ -495,9 +713,14 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public void hurtAndBreak(final int amount, final LivingEntity owner, final EquipmentSlot slot) { @@ -320,7 +328,7 @@ ); } } -@@ -748,6 +_,12 @@ +@@ -748,6 +971,12 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { return this.getItem().useOnRelease(this); } @@ -333,7 +341,7 @@ public @Nullable T set(final DataComponentType type, final @Nullable T value) { return this.components.set(type, value); } -@@ -791,6 +_,28 @@ +@@ -791,6 +1020,28 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { this.components.setAll(components); } @@ -362,7 +370,7 @@ public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -1006,6 +_,19 @@ +@@ -1006,6 +1257,19 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { EnchantmentHelper.forEachModifier(this, slot, consumer); } @@ -382,7 +390,7 @@ public Component getDisplayName() { MutableComponent hoverName = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1070,7 +_,7 @@ +@@ -1070,7 +1334,7 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public void consume(final int amount, final @Nullable LivingEntity owner) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch index 7f93debcac9a..5de4f289d262 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/LeadItem.java b/net/minecraft/world/item/LeadItem.java +index 863cab9e42b794524f2b13a8d70921c47778b376..a95075d63500625578c8628e0437165a1e83eaed 100644 --- a/net/minecraft/world/item/LeadItem.java +++ b/net/minecraft/world/item/LeadItem.java -@@ -27,24 +_,36 @@ +@@ -27,24 +27,36 @@ public class LeadItem extends Item { if (state.is(BlockTags.FENCES)) { Player player = context.getPlayer(); if (!level.isClientSide() && player != null) { @@ -40,7 +48,7 @@ leashable.setLeashedTo(activeKnot, true); anyLeashed = true; } -@@ -63,4 +_,10 @@ +@@ -63,4 +75,10 @@ public class LeadItem extends Item { } } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch similarity index 68% rename from paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch index 70ccca3b2790..a3be182714ae 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/MinecartItem.java b/net/minecraft/world/item/MinecartItem.java +index 47fc97b7949016e54111bca6ee4be7c8d28bf935..7464dbde8cc3348748d2a3733624bd2274f9c735 100644 --- a/net/minecraft/world/item/MinecartItem.java +++ b/net/minecraft/world/item/MinecartItem.java -@@ -57,7 +_,13 @@ +@@ -57,7 +57,13 @@ public class MinecartItem extends Item { } if (level instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch index c87d9272fa57..fdbbd6a8ff84 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/ProjectileWeaponItem.java b/net/minecraft/world/item/ProjectileWeaponItem.java +index 84e108fe5520e3d44f916e981f7a5f4805751898..9abc52c653f8416c62ca8b14c4794233d84ead59 100644 --- a/net/minecraft/world/item/ProjectileWeaponItem.java +++ b/net/minecraft/world/item/ProjectileWeaponItem.java -@@ -50,6 +_,7 @@ +@@ -50,6 +50,7 @@ public abstract class ProjectileWeaponItem extends Item { final float uncertainty, final boolean isCrit, final @Nullable LivingEntity targetOverride @@ -8,7 +16,7 @@ ) { float maxAngle = EnchantmentHelper.processProjectileSpread(level, weapon, shooter, 0.0F); float angleStep = projectiles.size() == 1 ? 0.0F : 2.0F * maxAngle / (projectiles.size() - 1); -@@ -62,12 +_,26 @@ +@@ -62,12 +63,26 @@ public abstract class ProjectileWeaponItem extends Item { float angle = angleOffset + direction * ((i + 1) / 2) * angleStep; direction = -direction; int index = i; @@ -41,7 +49,7 @@ weapon.hurtAndBreak(this.getDurabilityUse(projectile), shooter, hand.asEquipmentSlot()); if (weapon.isEmpty()) { break; -@@ -103,6 +_,12 @@ +@@ -103,6 +118,12 @@ public abstract class ProjectileWeaponItem extends Item { } protected static List draw(final ItemStack weapon, final ItemStack projectile, final LivingEntity shooter) { @@ -54,7 +62,7 @@ if (projectile.isEmpty()) { return List.of(); } else { -@@ -113,7 +_,7 @@ +@@ -113,7 +134,7 @@ public abstract class ProjectileWeaponItem extends Item { ItemStack projectileCopy = projectile.copy(); for (int i = 0; i < numProjectiles; i++) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch index 97a7cf9785fa..d17e2fbd2a46 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/ShovelItem.java b/net/minecraft/world/item/ShovelItem.java +index b0a4b124bfd5abc8c287a2f502d7935bc8ee0365..97c09033fb49156ff8743511bcfe65a54afe50c7 100644 --- a/net/minecraft/world/item/ShovelItem.java +++ b/net/minecraft/world/item/ShovelItem.java -@@ -45,20 +_,29 @@ +@@ -45,20 +45,29 @@ public class ShovelItem extends Item { Player player = context.getPlayer(); BlockState newState = FLATTENABLES.get(blockState.getBlock()); BlockState updatedState = null; diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch index 55e947834b83..eb7d7d4a4931 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/SpawnEggItem.java b/net/minecraft/world/item/SpawnEggItem.java +index 03087f5ea22c01376a7855556f471dcb9be7308a..d78965a0adebeb0172447bdec3fd019fdacc1a5d 100644 --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -61,6 +_,7 @@ +@@ -61,6 +61,7 @@ public class SpawnEggItem extends Item { return InteractionResult.FAIL; } else { @@ -8,7 +16,7 @@ spawnerHolder.setEntityId(type, level.getRandom()); level.sendBlockUpdated(pos, blockState, blockState, Block.UPDATE_ALL); level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, pos); -@@ -91,7 +_,7 @@ +@@ -91,7 +92,7 @@ public class SpawnEggItem extends Item { EntityType type = getType(itemStack); if (type == null) { return InteractionResult.FAIL; @@ -17,7 +25,7 @@ return InteractionResult.FAIL; } else { if (type.spawn((ServerLevel)level, itemStack, user, spawnPos, EntitySpawnReason.SPAWN_ITEM_USE, tryMoveDown, movedUp) != null) { -@@ -163,7 +_,7 @@ +@@ -163,7 +164,7 @@ public class SpawnEggItem extends Item { } else { offspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); offspring.applyComponentsFromItemStack(spawnEggStack); diff --git a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch index 786ea731da41..ec21440812ae 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/TridentItem.java b/net/minecraft/world/item/TridentItem.java +index 429978baeea934353d94021db25ef12fb316d3f4..a1e7f6138aa99b33152dd464f382bf36ad055c7f 100644 --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java -@@ -78,18 +_,38 @@ +@@ -78,18 +78,38 @@ public class TridentItem extends Item implements ProjectileItem { .orElse(SoundEvents.TRIDENT_THROW); player.awardStat(Stats.ITEM_USED.get(this)); if (level instanceof ServerLevel serverLevel) { @@ -42,7 +50,7 @@ } } -@@ -103,6 +_,7 @@ +@@ -103,6 +123,7 @@ public class TridentItem extends Item implements ProjectileItem { xd *= riptideStrength / dist; yd *= riptideStrength / dist; zd *= riptideStrength / dist; diff --git a/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 03fbf04cd2f2..9f93d79ef458 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/alchemy/PotionBrewing.java b/net/minecraft/world/item/alchemy/PotionBrewing.java +index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f5485c9843e6 100644 --- a/net/minecraft/world/item/alchemy/PotionBrewing.java +++ b/net/minecraft/world/item/alchemy/PotionBrewing.java -@@ -19,6 +_,7 @@ +@@ -19,6 +19,7 @@ public class PotionBrewing { private final List containers; private final List> potionMixes; private final List> containerMixes; @@ -8,7 +16,7 @@ private PotionBrewing( final List containers, final List> potionMixes, final List> containerMixes -@@ -29,7 +_,7 @@ +@@ -29,7 +30,7 @@ public class PotionBrewing { } public boolean isIngredient(final ItemStack ingredient) { @@ -17,7 +25,7 @@ } private boolean isContainer(final ItemStack input) { -@@ -73,6 +_,11 @@ +@@ -73,6 +74,11 @@ public class PotionBrewing { } public boolean hasMix(final ItemStack source, final ItemStack ingredient) { @@ -29,7 +37,7 @@ return this.isContainer(source) && (this.hasContainerMix(source, ingredient) || this.hasPotionMix(source, ingredient)); } -@@ -109,6 +_,13 @@ +@@ -109,6 +115,13 @@ public class PotionBrewing { if (potion.isEmpty()) { return source; } else { @@ -43,11 +51,10 @@ for (PotionBrewing.Mix mix : this.containerMixes) { if (source.is(mix.from) && mix.ingredient.test(ingredient)) { return PotionContents.createItemStack(mix.to.value(), potion.get()); -@@ -191,6 +_,50 @@ - builder.addMix(Potions.AWKWARD, Items.PHANTOM_MEMBRANE, Potions.SLOW_FALLING); +@@ -192,6 +205,50 @@ public class PotionBrewing { builder.addMix(Potions.SLOW_FALLING, Items.REDSTONE, Potions.LONG_SLOW_FALLING); } -+ + + // Paper start - Custom Potion Mixes + public boolean isCustomIngredient(ItemStack stack) { + for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { @@ -91,6 +98,7 @@ + return bootstrap(flags); + } + // Paper end - Custom Potion Mixes - ++ public static class Builder { private final List containers = new ArrayList<>(); + private final List> potionMixes = new ArrayList<>(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch similarity index 57% rename from paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch index 6a668d9014f3..6aa138b8a788 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/component/LodestoneTracker.java b/net/minecraft/world/item/component/LodestoneTracker.java +index a77e820d7b5ac01de7aa959fd6fed318b9169894..649988375dd5d6406ad4137534373d0a3548f0b3 100644 --- a/net/minecraft/world/item/component/LodestoneTracker.java +++ b/net/minecraft/world/item/component/LodestoneTracker.java -@@ -29,7 +_,7 @@ +@@ -29,7 +29,7 @@ public record LodestoneTracker(Optional target, boolean tracked) { return this; } else { BlockPos blockPos = this.target.get().pos(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch similarity index 75% rename from paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch index 8d73c45ced2a..bf27d3312bbc 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/component/ResolvableProfile.java b/net/minecraft/world/item/component/ResolvableProfile.java +index ee40ccbdc45678d94fdbb1d397dc5f29c32c1e7b..8b554b35c5670daf594d91cb276f93735242eb21 100644 --- a/net/minecraft/world/item/component/ResolvableProfile.java +++ b/net/minecraft/world/item/component/ResolvableProfile.java -@@ -46,7 +_,7 @@ +@@ -46,7 +46,7 @@ public abstract sealed class ResolvableProfile implements TooltipProvider permit private static ResolvableProfile create(final Either value, final PlayerSkin.Patch patch) { return value.map( full -> new ResolvableProfile.Static(Either.left(full), patch), @@ -9,7 +17,7 @@ ? partial.name .map(s -> new ResolvableProfile.Dynamic(Either.left(s), patch)) .orElseGet(() -> new ResolvableProfile.Dynamic(Either.right(partial.id.get()), patch)) -@@ -140,9 +_,10 @@ +@@ -140,9 +140,10 @@ public abstract sealed class ResolvableProfile implements TooltipProvider permit i -> i.group( ExtraCodecs.PLAYER_NAME.optionalFieldOf("name").forGetter(ResolvableProfile.Partial::name), UUIDUtil.CODEC.optionalFieldOf("id").forGetter(ResolvableProfile.Partial::id), diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch similarity index 62% rename from paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch index 412ccec493e3..b9c55e83135c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +index 1a413a0dbc63478ece9533f81ac5f1edd5d1f71b..66977396551bb2c3e0b602f4c1fc4b94d3a31777 100644 --- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -@@ -46,14 +_,14 @@ +@@ -46,14 +46,14 @@ public record ApplyStatusEffectsConsumeEffect(List effects, f } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index 8fd6968d7fbd..ea4fd9a6e02a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +index e8e56b454adafb5650cbdba7e23a98592d794e34..f9fa7d0eaf9f32959a4bd12b82e5a49ea808a44c 100644 --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -47,11 +_,20 @@ +@@ -47,11 +47,20 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { private final Ingredient base; private final Ingredient addition; private final Holder pattern; @@ -21,7 +29,7 @@ this.template = template; this.base = base; this.addition = addition; -@@ -60,10 +_,15 @@ +@@ -60,10 +69,15 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { @Override public ItemStack assemble(final SmithingRecipeInput input) { @@ -38,7 +46,7 @@ Holder material = materialItem.get(DataComponents.PROVIDES_TRIM_MATERIAL); if (material != null) { ArmorTrim existingTrim = baseItem.get(DataComponents.TRIM); -@@ -71,7 +_,7 @@ +@@ -71,7 +85,7 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { if (Objects.equals(existingTrim, newTrim)) { return ItemStack.EMPTY; } else { @@ -47,7 +55,7 @@ trimmedItem.set(DataComponents.TRIM, newTrim); return trimmedItem; } -@@ -120,4 +_,10 @@ +@@ -120,4 +134,10 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { ) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch rename to paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch index f20ec063cada..65531b433f2a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/item/trading/MerchantOffer.java b/net/minecraft/world/item/trading/MerchantOffer.java +index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea8180019e 100644 --- a/net/minecraft/world/item/trading/MerchantOffer.java +++ b/net/minecraft/world/item/trading/MerchantOffer.java -@@ -21,6 +_,7 @@ +@@ -21,6 +21,7 @@ public class MerchantOffer { Codec.INT.lenientOptionalFieldOf("demand", 0).forGetter(o -> o.demand), Codec.FLOAT.lenientOptionalFieldOf("priceMultiplier", 0.0F).forGetter(o -> o.priceMultiplier), Codec.INT.lenientOptionalFieldOf("xp", 1).forGetter(o -> o.xp) @@ -8,7 +16,7 @@ ) .apply(i, MerchantOffer::new) ); -@@ -37,6 +_,21 @@ +@@ -37,6 +38,21 @@ public class MerchantOffer { public int demand; public float priceMultiplier; public int xp; @@ -30,7 +38,7 @@ private MerchantOffer( final ItemCost baseCostA, -@@ -49,6 +_,7 @@ +@@ -49,6 +65,7 @@ public class MerchantOffer { final int demand, final float priceMultiplier, final int xp @@ -38,7 +46,7 @@ ) { this.baseCostA = baseCostA; this.costB = costB; -@@ -60,6 +_,7 @@ +@@ -60,6 +77,7 @@ public class MerchantOffer { this.demand = demand; this.priceMultiplier = priceMultiplier; this.xp = xp; @@ -46,7 +54,7 @@ } public MerchantOffer(final ItemCost buy, final ItemStack result, final int maxUses, final int xp, final float priceMultiplier) { -@@ -94,7 +_,7 @@ +@@ -94,7 +112,7 @@ public class MerchantOffer { final float priceMultiplier, final int demand ) { @@ -55,7 +63,7 @@ } private MerchantOffer(final MerchantOffer offer) { -@@ -109,6 +_,7 @@ +@@ -109,6 +127,7 @@ public class MerchantOffer { offer.demand, offer.priceMultiplier, offer.xp @@ -63,7 +71,7 @@ ); } -@@ -144,6 +_,7 @@ +@@ -144,6 +163,7 @@ public class MerchantOffer { public void updateDemand() { this.demand = this.demand + this.uses - (this.maxUses - this.uses); @@ -71,7 +79,7 @@ } public ItemStack assemble() { -@@ -222,7 +_,11 @@ +@@ -222,7 +242,11 @@ public class MerchantOffer { if (!this.satisfiedBy(buyA, buyB)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch index c7a01f579a58..1bad8f8f0df9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/BaseCommandBlock.java b/net/minecraft/world/level/BaseCommandBlock.java +index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004787bb6ab 100644 --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -30,6 +_,10 @@ +@@ -30,6 +30,10 @@ public abstract class BaseCommandBlock { private @Nullable Component lastOutput; private String command = ""; private @Nullable Component customName; @@ -11,7 +19,7 @@ public int getSuccessCount() { return this.successCount; -@@ -107,7 +_,13 @@ +@@ -107,7 +111,13 @@ public abstract class BaseCommandBlock { this.successCount++; } }); @@ -26,7 +34,7 @@ } } catch (Throwable var7) { CrashReport report = CrashReport.forThrowable(var7, "Executing command block"); -@@ -128,8 +_,8 @@ +@@ -128,8 +138,8 @@ public abstract class BaseCommandBlock { } } @@ -37,7 +45,7 @@ } public Component getName() { -@@ -162,15 +_,23 @@ +@@ -162,15 +172,23 @@ public abstract class BaseCommandBlock { public abstract boolean isValid(); @@ -63,7 +71,7 @@ } @Override -@@ -180,7 +_,7 @@ +@@ -180,7 +198,7 @@ public abstract class BaseCommandBlock { @Override public boolean acceptsFailure() { @@ -72,7 +80,7 @@ } @Override -@@ -190,7 +_,8 @@ +@@ -190,7 +208,8 @@ public abstract class BaseCommandBlock { @Override public void sendSystemMessage(final Component message) { @@ -82,7 +90,7 @@ BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message); BaseCommandBlock.this.onUpdated(this.level); } -@@ -200,5 +_,12 @@ +@@ -200,5 +219,12 @@ public abstract class BaseCommandBlock { public void close() throws Exception { this.closed = true; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/level/Level.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch index e51510437f3b..36ca62f57242 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d9807e2b3 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -89,8 +_,19 @@ +@@ -89,8 +89,19 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; @@ -20,7 +28,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); -@@ -132,6 +_,55 @@ +@@ -132,6 +143,55 @@ public abstract class Level implements LevelAccessor, AutoCloseable { private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; @@ -76,7 +84,7 @@ protected Level( final WritableLevelData levelData, final ResourceKey dimension, -@@ -141,7 +_,25 @@ +@@ -141,7 +201,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable { final boolean isDebug, final long biomeZoomSeed, final int maxChainedNeighborUpdates @@ -102,7 +110,7 @@ this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; this.dimension = dimension; -@@ -155,6 +_,46 @@ +@@ -155,6 +233,46 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.damageSources = new DamageSources(registryAccess); } @@ -149,7 +157,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -165,8 +_,15 @@ +@@ -165,8 +283,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return null; } @@ -166,7 +174,7 @@ } public boolean isInValidBounds(final BlockPos pos) { -@@ -178,7 +_,7 @@ +@@ -178,7 +303,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } private static boolean isInWorldBoundsHorizontal(final BlockPos pos) { @@ -175,7 +183,7 @@ } private static boolean isInValidBoundsHorizontal(final BlockPos pos) { -@@ -191,14 +_,79 @@ +@@ -191,14 +316,79 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return y < -20000000 || y >= 20000000; } @@ -187,7 +195,6 @@ @Override - public LevelChunk getChunk(final int chunkX, final int chunkZ) { - return (LevelChunk)this.getChunk(chunkX, chunkZ, ChunkStatus.FULL); -- } + public final LevelChunk getChunk(final int chunkX, final int chunkZ) { // Paper - final to help inline + // Paper start - Perf: make sure loaded chunks get the inlined variant of this function + net.minecraft.server.level.ServerChunkCache cps = ((ServerLevel)this).getChunkSource(); @@ -254,12 +261,12 @@ + // reduces need to do isLoaded before getType + public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos pos) { + return this.getWorldBorder().isWithinBounds(pos) ? this.getBlockStateIfLoaded(pos) : null; -+ } + } + // Paper end @Override public @Nullable ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatus status, final boolean loadOrGenerate) { -@@ -217,6 +_,22 @@ +@@ -217,6 +407,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public boolean setBlock(final BlockPos pos, final BlockState blockState, @Block.UpdateFlags final int updateFlags, final int updateLimit) { @@ -282,7 +289,7 @@ if (!this.isInValidBounds(pos)) { return false; } else if (!this.isClientSide() && this.isDebug()) { -@@ -224,11 +_,31 @@ +@@ -224,11 +430,31 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } else { LevelChunk chunk = this.getChunkAt(pos); Block block = blockState.getBlock(); @@ -314,7 +321,7 @@ if (newState == blockState) { if (oldState != newState) { this.setBlocksDirty(pos, oldState, newState); -@@ -256,12 +_,69 @@ +@@ -256,12 +482,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.updatePOIOnBlockStateChange(pos, oldState, newState); } @@ -384,7 +391,7 @@ public void updatePOIOnBlockStateChange(final BlockPos pos, final BlockState oldState, final BlockState newState) { } -@@ -272,19 +_,37 @@ +@@ -272,19 +555,37 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } @Override @@ -426,7 +433,7 @@ } boolean destroyed = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, updateLimit); -@@ -359,10 +_,18 @@ +@@ -359,10 +660,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public BlockState getBlockState(final BlockPos pos) { @@ -446,7 +453,7 @@ return chunk.getBlockState(pos); } } -@@ -523,6 +_,7 @@ +@@ -523,6 +832,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public void addBlockEntityTicker(final TickingBlockEntity ticker) { @@ -454,7 +461,7 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(ticker); } -@@ -533,18 +_,23 @@ +@@ -533,18 +843,23 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.pendingBlockEntityTickers.clear(); } @@ -482,7 +489,7 @@ this.tickingBlockEntities = false; } -@@ -552,12 +_,23 @@ +@@ -552,13 +867,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { try { tick.accept(entity); } catch (Throwable var6) { @@ -498,7 +505,7 @@ + // Paper end - Prevent block entity and entity crashes } } -+ + + // Paper start - Option to prevent armor stands from doing entity lookups + @Override + public boolean noCollision(@Nullable Entity entity, AABB box) { @@ -507,10 +514,11 @@ + return LevelAccessor.super.noCollision(entity, box); + } + // Paper end - Option to prevent armor stands from doing entity lookups - ++ public boolean shouldTickDeath(final Entity entity) { return true; -@@ -691,6 +_,12 @@ + } +@@ -691,6 +1017,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { @@ -523,7 +531,7 @@ if (!this.isInValidBounds(pos)) { return null; } else { -@@ -703,6 +_,12 @@ +@@ -703,6 +1035,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public void setBlockEntity(final BlockEntity blockEntity) { BlockPos pos = blockEntity.getBlockPos(); if (this.isInValidBounds(pos)) { @@ -536,7 +544,7 @@ this.getChunkAt(pos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1110,7 +_,8 @@ +@@ -1110,7 +1448,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { BLOCK("block"), MOB("mob"), TNT("tnt"), @@ -546,7 +554,7 @@ public static final Codec CODEC = StringRepresentable.fromEnum(Level.ExplosionInteraction::values); private final String id; -@@ -1124,4 +_,16 @@ +@@ -1124,4 +1463,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.id; } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch index d9abff23dc29..43ae6f813b57 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java +index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e367f8251 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -77,6 +_,13 @@ +@@ -77,6 +77,13 @@ public final class NaturalSpawner { if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { @@ -14,7 +22,7 @@ BlockPos pos = entity.blockPosition(); chunkGetter.query(ChunkPos.pack(pos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(pos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -101,17 +_,34 @@ +@@ -101,17 +108,34 @@ public final class NaturalSpawner { return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } @@ -51,7 +59,7 @@ } } -@@ -133,6 +_,16 @@ +@@ -133,6 +157,16 @@ public final class NaturalSpawner { profiler.pop(); } @@ -68,7 +76,7 @@ public static void spawnCategoryForChunk( final MobCategory mobCategory, final ServerLevel level, -@@ -162,8 +_,8 @@ +@@ -162,8 +196,8 @@ public final class NaturalSpawner { StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int yStart = start.getY(); @@ -79,7 +87,7 @@ BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); int clusterSize = 0; -@@ -185,7 +_,7 @@ +@@ -185,7 +219,7 @@ public final class NaturalSpawner { Player nearestPlayer = level.getNearestPlayer(xx, yStart, zz, -1.0, false); if (nearestPlayer != null) { double nearestPlayerDistanceSqr = nearestPlayer.distanceToSqr(xx, yStart, zz); @@ -88,7 +96,7 @@ if (currentSpawnData == null) { Optional nextSpawnData = getRandomSpawnMobAt( level, structureManager, generator, mobCategory, level.random, pos -@@ -198,7 +_,13 @@ +@@ -198,7 +232,13 @@ public final class NaturalSpawner { max = currentSpawnData.minCount() + level.random.nextInt(1 + currentSpawnData.maxCount() - currentSpawnData.minCount()); } @@ -103,7 +111,7 @@ && extraTest.test(currentSpawnData.type(), pos, chunk)) { Mob mob = getMobForSpawn(level, currentSpawnData.type()); if (mob == null) { -@@ -210,10 +_,15 @@ +@@ -210,10 +250,15 @@ public final class NaturalSpawner { groupData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.NATURAL, groupData ); @@ -123,7 +131,7 @@ if (clusterSize >= mob.getMaxSpawnClusterSize()) { return; } -@@ -247,7 +_,15 @@ +@@ -247,7 +292,15 @@ public final class NaturalSpawner { } } @@ -140,7 +148,7 @@ final ServerLevel level, final MobCategory mobCategory, final StructureManager structureManager, -@@ -256,14 +_,27 @@ +@@ -256,14 +309,27 @@ public final class NaturalSpawner { final BlockPos.MutableBlockPos pos, final double nearestPlayerDistanceSqr ) { @@ -169,7 +177,7 @@ } private static @Nullable Mob getMobForSpawn(final ServerLevel level, final EntityType type) { -@@ -275,6 +_,7 @@ +@@ -275,6 +341,7 @@ public final class NaturalSpawner { LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(type)); } catch (Exception var4) { LOGGER.warn("Failed to create mob", (Throwable)var4); @@ -177,7 +185,7 @@ } return null; -@@ -402,6 +_,7 @@ +@@ -402,6 +469,7 @@ public final class NaturalSpawner { entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception var27) { LOGGER.warn("Failed to create mob", (Throwable)var27); @@ -185,7 +193,7 @@ continue; } -@@ -416,7 +_,7 @@ +@@ -416,7 +484,7 @@ public final class NaturalSpawner { groupSpawnData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, groupSpawnData ); @@ -194,7 +202,7 @@ success = true; } } -@@ -534,8 +_,10 @@ +@@ -534,8 +602,10 @@ public final class NaturalSpawner { return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch index 112f8088bfe2..3ed0a5b11b1c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/BedBlock.java b/net/minecraft/world/level/block/BedBlock.java +index 6096d39488c378271228029d08ef11df7ab82431..fea3df8af41f61e3f91f6cd6bd06dc0a0ced232b 100644 --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -91,7 +_,7 @@ +@@ -91,7 +91,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock } BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); @@ -9,7 +17,7 @@ bedRule.errorMessage().ifPresent(player::sendOverlayMessage); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -103,22 +_,61 @@ +@@ -103,22 +103,61 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), null, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -72,7 +80,7 @@ private boolean kickVillagerOutOfBed(final Level level, final BlockPos pos) { List villagers = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); if (villagers.isEmpty()) { -@@ -298,6 +_,11 @@ +@@ -298,6 +337,11 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock if (!level.isClientSide()) { BlockPos otherPos = pos.relative(state.getValue(FACING)); level.setBlock(otherPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch index 4546e8981575..afaa75a543bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/ButtonBlock.java b/net/minecraft/world/level/block/ButtonBlock.java +index ae7ad024d194698c233777032602c980780df6cd..86f4dcd959bb83247c6d2c5e947c79230aed3189 100644 --- a/net/minecraft/world/level/block/ButtonBlock.java +++ b/net/minecraft/world/level/block/ButtonBlock.java -@@ -92,6 +_,11 @@ +@@ -92,6 +92,11 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { if (state.getValue(POWERED)) { return InteractionResult.CONSUME; } else { @@ -12,7 +20,7 @@ this.press(state, level, pos, player); return InteractionResult.SUCCESS; } -@@ -102,7 +_,9 @@ +@@ -102,7 +107,9 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { final BlockState state, final ServerLevel level, final BlockPos pos, final Explosion explosion, final BiConsumer onHit ) { if (explosion.canTriggerBlocks() && !state.getValue(POWERED)) { @@ -22,7 +30,7 @@ } super.onExplosionHit(state, level, pos, explosion, onHit); -@@ -162,6 +_,7 @@ +@@ -162,6 +169,7 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -30,7 +38,7 @@ if (!level.isClientSide() && this.type.canButtonBeActivatedByArrows() && !state.getValue(POWERED)) { this.checkPressed(state, level, pos); } -@@ -173,7 +_,21 @@ +@@ -173,7 +181,21 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { : null; boolean shouldBePressed = firstArrow != null; boolean wasPressed = state.getValue(POWERED); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch index 44157946d3de..e4a632eff2b7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/CakeBlock.java b/net/minecraft/world/level/block/CakeBlock.java +index 72c79ff33d31a8c2e3f46d28f0a4ae42528d9e87..14b3dd17c5fbeea87c3576b88a1fe0a71c9320b3 100644 --- a/net/minecraft/world/level/block/CakeBlock.java +++ b/net/minecraft/world/level/block/CakeBlock.java -@@ -63,6 +_,12 @@ +@@ -63,6 +63,12 @@ public class CakeBlock extends Block { ) { Item item = itemStack.getItem(); if (itemStack.is(ItemTags.CANDLES) && state.getValue(BITES) == 0 && Block.byItem(item) instanceof CandleBlock candleBlock) { @@ -13,7 +21,7 @@ itemStack.consume(1, player); level.playSound(null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(candleBlock)); -@@ -95,9 +_,28 @@ +@@ -95,9 +101,28 @@ public class CakeBlock extends Block { if (!player.canEat(false)) { return InteractionResult.PASS; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch index c774cd0cec40..da4c66cdc77f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/ChestBlock.java b/net/minecraft/world/level/block/ChestBlock.java +index 676b3f41a136e036dcaea719bd72a8f4da4b381c..d3f0680d59ec87990b54dc3dbce27706bfadf5f1 100644 --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -97,7 +_,7 @@ +@@ -97,7 +97,7 @@ public class ChestBlock extends AbstractChestBlock implements @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); @@ -9,7 +17,7 @@ { Objects.requireNonNull(container); } -@@ -122,10 +_,10 @@ +@@ -122,10 +122,10 @@ public class ChestBlock extends AbstractChestBlock implements if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +30,7 @@ } @Override -@@ -268,8 +_,7 @@ +@@ -268,8 +268,7 @@ public class ChestBlock extends AbstractChestBlock implements ) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -32,7 +40,7 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -310,7 +_,13 @@ +@@ -310,7 +309,13 @@ public class ChestBlock extends AbstractChestBlock implements @Override public @Nullable MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) { @@ -47,7 +55,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity entity) { -@@ -352,6 +_,11 @@ +@@ -352,6 +357,11 @@ public class ChestBlock extends AbstractChestBlock implements } private static boolean isCatSittingOnChest(final LevelAccessor level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch similarity index 73% rename from paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch index 7266450ee6ab..fa1eaa35fe8f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/ComparatorBlock.java b/net/minecraft/world/level/block/ComparatorBlock.java +index efdf488c97567ee62e0da2b6aaff3a08d0bec8c9..45e11737bc2558a4ebfffe133d43111f45dd7d16 100644 --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -137,7 +_,7 @@ +@@ -137,7 +137,7 @@ public class ComparatorBlock extends DiodeBlock implements EntityBlock { float pitch = state.getValue(MODE) == ComparatorMode.SUBTRACT ? 0.55F : 0.5F; level.playSound(player, pos, SoundEvents.COMPARATOR_CLICK, SoundSource.BLOCKS, 0.3F, pitch); level.setBlock(pos, state, Block.UPDATE_CLIENTS); @@ -9,7 +17,7 @@ return InteractionResult.SUCCESS; } } -@@ -168,8 +_,18 @@ +@@ -168,8 +168,18 @@ public class ComparatorBlock extends DiodeBlock implements EntityBlock { boolean sourceOn = this.shouldTurnOn(level, pos, state); boolean isOn = state.getValue(POWERED); if (isOn && !sourceOn) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch index 37f69c8d76c9..324cb9d56d95 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java +index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e294d4b48e7 100644 --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -258,6 +_,11 @@ +@@ -258,6 +258,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { if (fillLevel < 8 && COMPOSTABLES.containsKey(itemStack.getItem())) { if (fillLevel < 7 && !level.isClientSide()) { BlockState newState = addItem(player, state, level, pos, itemStack); @@ -12,7 +20,7 @@ level.levelEvent(LevelEvent.COMPOSTER_FILL, pos, state != newState ? 1 : 0); player.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); itemStack.consume(1, player); -@@ -287,7 +_,19 @@ +@@ -287,7 +292,19 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { ) { int fillLevel = state.getValue(LEVEL); if (fillLevel < 7 && COMPOSTABLES.containsKey(itemStack.getItem())) { @@ -33,7 +41,7 @@ itemStack.shrink(1); return newState; } else { -@@ -296,6 +_,14 @@ +@@ -296,6 +313,14 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { } public static BlockState extractProduce(final Entity sourceEntity, final BlockState state, final Level level, final BlockPos pos) { @@ -48,14 +56,14 @@ if (!level.isClientSide()) { Vec3 itemPos = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandomXZ(level.getRandom(), 0.7F); ItemEntity entity = new ItemEntity(level, itemPos.x(), itemPos.y(), itemPos.z(), new ItemStack(Items.BONE_MEAL)); -@@ -315,16 +_,44 @@ +@@ -315,16 +340,44 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { return newState; } + @Nullable // Paper private static BlockState addItem( final @Nullable Entity sourceEntity, final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack itemStack - ) { ++ ) { + // CraftBukkit start + return ComposterBlock.addItem(sourceEntity, state, level, pos, itemStack, level.getRandom().nextDouble()); + } @@ -63,7 +71,7 @@ + private static BlockState addItem( + final @Nullable Entity sourceEntity, final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack itemStack, final double rand + // CraftBukkit end -+ ) { + ) { int fillLevel = state.getValue(LEVEL); float chance = COMPOSTABLES.getFloat(itemStack.getItem()); - if ((fillLevel != 0 || !(chance > 0.0F)) && !(level.getRandom().nextDouble() < chance)) { @@ -94,7 +102,7 @@ level.setBlock(pos, newState, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(sourceEntity, newState)); if (newLevel == 7) { -@@ -369,13 +_,14 @@ +@@ -369,13 +422,14 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { if (contentLevel == 8) { return new ComposterBlock.OutputContainer(state, level, pos, new ItemStack(Items.BONE_MEAL)); } else { @@ -111,7 +119,7 @@ } @Override -@@ -402,6 +_,7 @@ +@@ -402,6 +456,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { public InputContainer(final BlockState state, final LevelAccessor level, final BlockPos pos) { super(1); @@ -119,7 +127,7 @@ this.state = state; this.level = level; this.pos = pos; -@@ -433,6 +_,11 @@ +@@ -433,6 +488,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { if (!contents.isEmpty()) { this.changed = true; BlockState newState = ComposterBlock.addItem(null, this.state, this.level, this.pos, contents); @@ -131,7 +139,7 @@ this.level.levelEvent(LevelEvent.COMPOSTER_FILL, this.pos, newState != this.state ? 1 : 0); this.removeItemNoUpdate(0); } -@@ -447,6 +_,7 @@ +@@ -447,6 +507,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { public OutputContainer(final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack contents) { super(contents); @@ -139,7 +147,7 @@ this.state = state; this.level = level; this.pos = pos; -@@ -474,8 +_,15 @@ +@@ -474,8 +535,15 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @Override public void setChanged() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch similarity index 73% rename from paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch index f7127c58613a..936135243418 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/CopperGolemStatueBlock.java b/net/minecraft/world/level/block/CopperGolemStatueBlock.java +index 61549c4877a857411f49cdb0254711421dbf0b35..9c36eee7798f0a9a60041ac7691e50001c9f42ea 100644 --- a/net/minecraft/world/level/block/CopperGolemStatueBlock.java +++ b/net/minecraft/world/level/block/CopperGolemStatueBlock.java -@@ -111,15 +_,21 @@ +@@ -111,15 +111,21 @@ public class CopperGolemStatueBlock extends BaseEntityBlock implements SimpleWat if (itemStack.is(ItemTags.AXES)) { return InteractionResult.PASS; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch similarity index 69% rename from paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch index cfd5138462c3..e866340ea1af 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/DoubleBlockCombiner.java b/net/minecraft/world/level/block/DoubleBlockCombiner.java +index fe08e68f9bd0cafdaf74afdeb685e755e57d65a2..865b239095aca8672af3f33a6b3720cbaf6df577 100644 --- a/net/minecraft/world/level/block/DoubleBlockCombiner.java +++ b/net/minecraft/world/level/block/DoubleBlockCombiner.java -@@ -34,7 +_,12 @@ +@@ -34,7 +34,12 @@ public class DoubleBlockCombiner { return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); } else { BlockPos neighborPos = pos.relative(connectionResolver.apply(state)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch index 920164481523..32438fab8e00 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java +index fb97cf764616da14ef33fd4a7c442aa9420dac1a..fcf0f6cf9211a5453353d2fb44e0f94d72efc2e5 100644 --- a/net/minecraft/world/level/block/EndPortalBlock.java +++ b/net/minecraft/world/level/block/EndPortalBlock.java -@@ -66,8 +_,14 @@ +@@ -66,8 +66,14 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -15,7 +23,7 @@ player.showEndCredits(); } else { entity.setAsInsidePortal(this, pos); -@@ -78,8 +_,7 @@ +@@ -78,8 +84,7 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { @Override public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { LevelData.RespawnData respawnData = currentLevel.getRespawnData(); @@ -25,7 +33,7 @@ ResourceKey newDimension = fromEnd ? respawnData.dimension() : Level.END; BlockPos spawnBlockPos = fromEnd ? respawnData.pos() : ServerLevel.END_SPAWN_POINT; ServerLevel newLevel = currentLevel.getServer().getLevel(newDimension); -@@ -91,7 +_,7 @@ +@@ -91,7 +96,7 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { float xRot; Set relatives; if (!fromEnd) { @@ -34,7 +42,7 @@ yRot = Direction.WEST.toYRot(); xRot = 0.0F; relatives = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); -@@ -103,15 +_,26 @@ +@@ -103,15 +108,26 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { xRot = respawnData.pitch(); relatives = Relative.union(Relative.DELTA, Relative.ROTATION); if (entity instanceof ServerPlayer serverPlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch index 80ee1af7526e..35aef5628693 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java +index 97fdb6cef743606d3e86f0e7e19367afa3de0b09..24a2c411da0ebbb7f97d621bb76ff686621f9aae 100644 --- a/net/minecraft/world/level/block/EnderChestBlock.java +++ b/net/minecraft/world/level/block/EnderChestBlock.java -@@ -82,14 +_,15 @@ +@@ -82,14 +82,15 @@ public class EnderChestBlock extends AbstractChestBlock i PlayerEnderChestContainer container = player.getEnderChestInventory(); if (container != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChest) { BlockPos above = pos.above(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch index 34e617023453..776189e4dc2e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/FlowerPotBlock.java b/net/minecraft/world/level/block/FlowerPotBlock.java +index 54641a7a672be8fd46256593e6c3c37b1bbda56f..784ae26280d939c27a0946dd6d880489c79f1334 100644 --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -72,6 +_,18 @@ +@@ -72,6 +72,18 @@ public class FlowerPotBlock extends Block { } else if (!this.isEmpty()) { return InteractionResult.CONSUME; } else { @@ -19,7 +27,7 @@ level.setBlock(pos, newContents, Block.UPDATE_ALL); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); player.awardStat(Stats.POT_FLOWER); -@@ -88,6 +_,18 @@ +@@ -88,6 +100,18 @@ public class FlowerPotBlock extends Block { return InteractionResult.CONSUME; } else { ItemStack plant = new ItemStack(this.potted); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch similarity index 68% rename from paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch index d04287fd33da..50355c315828 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/MushroomBlock.java b/net/minecraft/world/level/block/MushroomBlock.java +index 5d482a8df571566f8f46731db81185dba51af608..dd736330ddb1457172774dbcdcffd101f60903ce 100644 --- a/net/minecraft/world/level/block/MushroomBlock.java +++ b/net/minecraft/world/level/block/MushroomBlock.java -@@ -46,7 +_,7 @@ +@@ -46,7 +46,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock @Override protected void randomTick(final BlockState state, final ServerLevel level, BlockPos pos, final RandomSource random) { @@ -9,7 +17,7 @@ int max = 5; int r = 4; -@@ -59,6 +_,7 @@ +@@ -59,6 +59,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock } BlockPos offset = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); @@ -17,7 +25,7 @@ for (int i = 0; i < 4; i++) { if (level.isEmptyBlock(offset) && state.canSurvive(level, offset)) { -@@ -69,7 +_,7 @@ +@@ -69,7 +70,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock } if (level.isEmptyBlock(offset) && state.canSurvive(level, offset)) { @@ -26,7 +34,7 @@ } } } -@@ -92,6 +_,7 @@ +@@ -92,6 +93,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock return false; } else { level.removeBlock(pos, false); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch index 18b9b33953c2..73b446dee086 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java +index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be550a8f5e0 100644 --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -66,7 +_,7 @@ +@@ -66,7 +66,7 @@ public class NetherPortalBlock extends Block implements Portal { @Override protected void randomTick(final BlockState state, final ServerLevel level, BlockPos pos, final RandomSource random) { @@ -9,7 +17,7 @@ && level.environmentAttributes().getValue(EnvironmentAttributes.NETHER_PORTAL_SPAWNS_PIGLINS, pos) && random.nextInt(2000) < level.getDifficulty().getId() && level.anyPlayerCloseEnoughForSpawning(pos)) { -@@ -75,9 +_,13 @@ +@@ -75,9 +75,13 @@ public class NetherPortalBlock extends Block implements Portal { } if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { @@ -24,7 +32,7 @@ Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -115,7 +_,13 @@ +@@ -115,7 +119,13 @@ public class NetherPortalBlock extends Block implements Portal { final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -38,7 +46,7 @@ entity.setAsInsidePortal(this, pos); } } -@@ -133,16 +_,39 @@ +@@ -133,16 +143,39 @@ public class NetherPortalBlock extends Block implements Portal { @Override public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { @@ -81,7 +89,7 @@ } } -@@ -153,8 +_,9 @@ +@@ -153,8 +186,9 @@ public class NetherPortalBlock extends Block implements Portal { final BlockPos approximateExitPos, final boolean toNether, final WorldBorder worldBorder @@ -92,7 +100,7 @@ BlockUtil.FoundRectangle exitPortal; TeleportTransition.PostTeleportTransition post; if (exitPortalPos.isPresent()) { -@@ -169,17 +_,22 @@ +@@ -169,17 +203,22 @@ public class NetherPortalBlock extends Block implements Portal { blockPos -> newLevel.getBlockState(blockPos) == portalState ); post = TeleportTransition.PLAY_PORTAL_SOUND.then(e -> e.placePortalTicket(pos)); @@ -118,7 +126,7 @@ return getDimensionTransitionFromExit(entity, portalEntryPos, exitPortal, newLevel, post); } -@@ -234,7 +_,7 @@ +@@ -234,7 +273,7 @@ public class NetherPortalBlock extends Block implements Portal { ); Vec3 collisionFreePos = PortalShape.findCollisionFreePosition(targetPos, newLevel, entity, dimensions); return new TeleportTransition( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch index a7de8dc2e270..c6c8d9d0f6a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/RespawnAnchorBlock.java b/net/minecraft/world/level/block/RespawnAnchorBlock.java +index a1ea6aff9a0ddb609f0213993564dbbf7c1acfb3..d854f4bbf97d625dd9e775d139e8446b9008c215 100644 --- a/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -115,11 +_,16 @@ +@@ -115,11 +115,16 @@ public class RespawnAnchorBlock extends Block { LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false ); if (respawnConfig == null || !respawnConfig.isSamePosition(newRespawnConfig)) { @@ -18,7 +26,7 @@ } } -@@ -156,6 +_,7 @@ +@@ -156,6 +161,7 @@ public class RespawnAnchorBlock extends Block { } private void explode(final BlockState state, final ServerLevel level, final BlockPos pos) { @@ -26,7 +34,7 @@ level.removeBlock(pos, false); boolean anyWaterNeighbors = Direction.Plane.HORIZONTAL.stream().map(pos::relative).anyMatch(neighborPos -> isWaterThatWouldFlow(neighborPos, level)); final boolean inWater = anyWaterNeighbors || level.getFluidState(pos.above()).is(FluidTags.WATER); -@@ -174,7 +_,7 @@ +@@ -174,7 +180,7 @@ public class RespawnAnchorBlock extends Block { } }; Vec3 boomPos = pos.getCenter(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch index a2dbd1b38a0a..57fe73d72459 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/TntBlock.java b/net/minecraft/world/level/block/TntBlock.java +index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f74e4cb41 100644 --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -47,7 +_,7 @@ +@@ -47,7 +47,7 @@ public class TntBlock extends Block { @Override protected void onPlace(final BlockState state, final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) { if (!oldState.is(state.getBlock())) { @@ -9,7 +17,7 @@ level.removeBlock(pos, false); } } -@@ -57,7 +_,7 @@ +@@ -57,7 +57,7 @@ public class TntBlock extends Block { protected void neighborChanged( final BlockState state, final Level level, final BlockPos pos, final Block block, final @Nullable Orientation orientation, final boolean movedByPiston ) { @@ -18,7 +26,7 @@ level.removeBlock(pos, false); } } -@@ -65,7 +_,7 @@ +@@ -65,7 +65,7 @@ public class TntBlock extends Block { @Override public BlockState playerWillDestroy(final Level level, final BlockPos pos, final BlockState state, final Player player) { if (!level.isClientSide() && !player.getAbilities().instabuild && state.getValue(UNSTABLE)) { @@ -27,7 +35,7 @@ } return super.playerWillDestroy(level, pos, state, player); -@@ -82,11 +_,16 @@ +@@ -82,11 +82,16 @@ public class TntBlock extends Block { } public static boolean prime(final Level level, final BlockPos pos) { @@ -47,7 +55,7 @@ PrimedTnt tnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, source); level.addFreshEntity(tnt); level.playSound(null, tnt.getX(), tnt.getY(), tnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -110,7 +_,7 @@ +@@ -110,7 +115,7 @@ public class TntBlock extends Block { if (!itemStack.is(Items.FLINT_AND_STEEL) && !itemStack.is(Items.FIRE_CHARGE)) { return super.useItemOn(itemStack, state, level, pos, player, hand, hitResult); } else { @@ -56,7 +64,7 @@ level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); Item item = itemStack.getItem(); if (itemStack.is(Items.FLINT_AND_STEEL)) { -@@ -136,7 +_,7 @@ +@@ -136,7 +141,7 @@ public class TntBlock extends Block { Entity owner = projectile.getOwner(); if (projectile.isOnFire() && projectile.mayInteract(serverLevel, pos) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch index 08c15476b412..05375b93ee74 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java +index 2d902d97fbbc9b18faea9a31c8093fbc659a7983..31f8b7225ae5804ed66e7b17862ee56ac6ae5237 100644 --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -119,10 +_,10 @@ +@@ -119,10 +119,10 @@ public class TripWireHookBlock extends Block { if (facingOptional.isPresent()) { Direction direction = facingOptional.get(); boolean wasAttached = state.getOptionalValue(ATTACHED).orElse(false); @@ -13,7 +21,7 @@ int receiverPos = 0; BlockState[] wireStates = new BlockState[42]; -@@ -158,8 +_,15 @@ +@@ -158,8 +158,15 @@ public class TripWireHookBlock extends Block { attached &= receiverPos > 1; powered &= attached; BlockState newState = block.defaultBlockState().trySetValue(ATTACHED, attached).trySetValue(POWERED, powered); @@ -29,17 +37,16 @@ Direction opposite = direction.getOpposite(); level.setBlock(testPosx, newState.setValue(FACING, opposite), Block.UPDATE_ALL); notifyNeighbors(block, level, testPosx, opposite); -@@ -169,15 +_,24 @@ +@@ -169,15 +176,24 @@ public class TripWireHookBlock extends Block { } emitState(level, testPosx, attached, powered, wasAttached, wasPowered); -- } + } // Paper - Call BlockRedstoneEvent + } + // Paper start - Call BlockRedstoneEvent + if (wasPowered != powered) { + cancelledEmitterHook = !org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, powered); -+ } + } + // Paper end - Call BlockRedstoneEvent + if (!cancelledEmitterHook) { // Paper - Call BlockRedstoneEvent @@ -55,7 +62,7 @@ if (wasAttached != attached) { for (int i = 1; i < receiverPos; i++) { -@@ -186,7 +_,7 @@ +@@ -186,7 +202,7 @@ public class TripWireHookBlock extends Block { if (wireData != null) { BlockState testPosState = level.getBlockState(testPosx); if (testPosState.is(Blocks.TRIPWIRE) || testPosState.is(Blocks.TRIPWIRE_HOOK)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index 64409208f817..e67bad1d0b1b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2bf84f3a75 100644 --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -86,6 +_,7 @@ +@@ -86,6 +86,7 @@ public class BeehiveBlockEntity extends BlockEntity { public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600; private List stored = Lists.newArrayList(); public @Nullable BlockPos savedFlowerPos; @@ -8,7 +16,7 @@ public BeehiveBlockEntity(final BlockPos worldPosition, final BlockState blockState) { super(BlockEntityType.BEEHIVE, worldPosition, blockState); -@@ -119,16 +_,17 @@ +@@ -119,16 +120,17 @@ public class BeehiveBlockEntity extends BlockEntity { } public boolean isFull() { @@ -28,7 +36,7 @@ } else { bee.setStayOutOfHiveCountdown(400); } -@@ -138,10 +_,15 @@ +@@ -138,10 +140,15 @@ public class BeehiveBlockEntity extends BlockEntity { } private List releaseAllOccupants(final BlockState state, final BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { @@ -45,7 +53,7 @@ ); if (!spawned.isEmpty()) { super.setChanged(); -@@ -155,6 +_,12 @@ +@@ -155,6 +162,12 @@ public class BeehiveBlockEntity extends BlockEntity { return this.stored.size(); } @@ -58,7 +66,7 @@ public static int getHoneyLevel(final BlockState blockState) { return blockState.getValue(BeehiveBlock.HONEY_LEVEL); } -@@ -165,7 +_,16 @@ +@@ -165,7 +178,16 @@ public class BeehiveBlockEntity extends BlockEntity { } public void addOccupant(final Bee bee) { @@ -76,7 +84,7 @@ bee.stopRiding(); bee.ejectPassengers(); bee.dropLeash(); -@@ -190,7 +_,7 @@ +@@ -190,7 +212,7 @@ public class BeehiveBlockEntity extends BlockEntity { this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -85,7 +93,7 @@ super.setChanged(); } } -@@ -199,6 +_,12 @@ +@@ -199,6 +221,12 @@ public class BeehiveBlockEntity extends BlockEntity { this.stored.add(new BeehiveBlockEntity.BeeData(occupant)); } @@ -98,7 +106,7 @@ private static boolean releaseOccupant( final Level level, final BlockPos blockPos, -@@ -207,8 +_,9 @@ +@@ -207,8 +235,9 @@ public class BeehiveBlockEntity extends BlockEntity { final @Nullable List spawned, final BeehiveBlockEntity.BeeReleaseStatus releaseStatus, final @Nullable BlockPos savedFlowerPos @@ -109,7 +117,7 @@ && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { return false; } else { -@@ -220,6 +_,17 @@ +@@ -220,6 +249,17 @@ public class BeehiveBlockEntity extends BlockEntity { } else { Entity entity = beeData.createEntity(level, blockPos); if (entity != null) { @@ -127,7 +135,7 @@ if (entity instanceof Bee bee) { RandomSource random = level.getRandom(); if (savedFlowerPos != null && !bee.hasSavedFlowerPos() && random.nextFloat() < 0.9F) { -@@ -236,7 +_,13 @@ +@@ -236,7 +276,13 @@ public class BeehiveBlockEntity extends BlockEntity { levelIncrease--; } @@ -142,7 +150,7 @@ } } } -@@ -245,17 +_,19 @@ +@@ -245,17 +291,19 @@ public class BeehiveBlockEntity extends BlockEntity { spawned.add(bee); } @@ -163,7 +171,7 @@ } else { return false; } -@@ -283,6 +_,11 @@ +@@ -283,6 +331,11 @@ public class BeehiveBlockEntity extends BlockEntity { changed = true; iterator.remove(); } @@ -175,7 +183,7 @@ } } -@@ -304,9 +_,10 @@ +@@ -304,9 +357,10 @@ public class BeehiveBlockEntity extends BlockEntity { @Override protected void loadAdditional(final ValueInput input) { super.loadAdditional(input); @@ -187,7 +195,7 @@ } @Override -@@ -314,12 +_,13 @@ +@@ -314,12 +368,13 @@ public class BeehiveBlockEntity extends BlockEntity { super.saveAdditional(output); output.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees()); output.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); @@ -202,7 +210,7 @@ List bees = components.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees(); bees.forEach(this::storeBee); } -@@ -347,15 +_,18 @@ +@@ -347,15 +402,18 @@ public class BeehiveBlockEntity extends BlockEntity { private static class BeeData { private final BeehiveBlockEntity.Occupant occupant; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch index d3a465b684db..171cf02fedc0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +index d84d7d687f48b899cdaab47912743d66106fafaa..cddfd5b5b1d3f991682a1f96b935636ca27c219d 100644 --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -67,9 +_,26 @@ +@@ -67,9 +67,26 @@ public class BrushableBlockEntity extends BlockEntity { return false; } else { this.coolDownEndsAtTick = gameTime + 10L; @@ -29,7 +37,7 @@ this.brushingCompleted(level, user, brush); return true; } else { -@@ -77,7 +_,7 @@ +@@ -77,7 +94,7 @@ public class BrushableBlockEntity extends BlockEntity { int completionState = this.getCompletionState(); if (previousCompletionState != completionState) { BlockState previousState = this.getBlockState(); @@ -38,7 +46,7 @@ level.setBlock(this.getBlockPos(), state, Block.UPDATE_ALL); } -@@ -118,6 +_,12 @@ +@@ -118,6 +135,12 @@ public class BrushableBlockEntity extends BlockEntity { this.dropContent(level, user, brush); BlockState blockState = this.getBlockState(); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); @@ -51,7 +59,7 @@ Block turnsInto; if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { turnsInto = brushableBlock.getTurnsInto(); -@@ -125,6 +_,12 @@ +@@ -125,6 +148,12 @@ public class BrushableBlockEntity extends BlockEntity { turnsInto = Blocks.AIR; } @@ -64,7 +72,7 @@ level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); } -@@ -141,7 +_,12 @@ +@@ -141,7 +170,12 @@ public class BrushableBlockEntity extends BlockEntity { double zo = dropPos.getZ() + 0.5 * centerRange + halfSize; ItemEntity entity = new ItemEntity(level, xo, yo, zo, this.item.split(level.getRandom().nextInt(21) + 10)); entity.setDeltaMovement(Vec3.ZERO); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index 15397f883fde..bc76607fdbdf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/CommandBlockEntity.java b/net/minecraft/world/level/block/entity/CommandBlockEntity.java +index 8846095f59bb5278610698280aa1006c484dc19b..9051256d40c0fd0d2edb050cd317b4cd372e4cf4 100644 --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -32,6 +_,18 @@ +@@ -32,6 +32,18 @@ public class CommandBlockEntity extends BlockEntity { Objects.requireNonNull(CommandBlockEntity.this); } @@ -19,7 +27,7 @@ @Override public void setCommand(final String command) { super.setCommand(command); -@@ -52,7 +_,7 @@ +@@ -52,7 +64,7 @@ public class CommandBlockEntity extends BlockEntity { Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, facing.toYRot()), level, diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index bb2bc131a7fc..9569982384a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0eb7d26455 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -39,6 +_,40 @@ +@@ -39,6 +39,40 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private long tickedGameTime; private Direction facing; @@ -41,7 +49,7 @@ public HopperBlockEntity(final BlockPos worldPosition, final BlockState blockState) { super(BlockEntityType.HOPPER, worldPosition, blockState); this.facing = blockState.getValue(HopperBlock.FACING); -@@ -99,7 +_,12 @@ +@@ -99,7 +133,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen entity.tickedGameTime = level.getGameTime(); if (!entity.isOnCooldown()) { entity.setCooldown(0); @@ -55,7 +63,7 @@ } } -@@ -120,7 +_,7 @@ +@@ -120,7 +159,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } if (changed) { @@ -64,7 +72,7 @@ setChanged(level, pos, state); return true; } -@@ -153,14 +_,47 @@ +@@ -153,14 +192,47 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen ItemStack itemStack = self.getItem(slot); if (!itemStack.isEmpty()) { int originalCount = itemStack.getCount(); @@ -114,7 +122,7 @@ self.setItem(slot, itemStack); } } -@@ -223,7 +_,7 @@ +@@ -223,7 +295,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen Direction direction = Direction.DOWN; for (int slot : getSlots(container, direction)) { @@ -123,7 +131,7 @@ return true; } } -@@ -245,18 +_,55 @@ +@@ -245,18 +317,55 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } } @@ -182,7 +190,7 @@ container.setItem(slot, itemStack); } } -@@ -266,12 +_,20 @@ +@@ -266,12 +375,20 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean addItem(final Container container, final ItemEntity entity) { boolean changed = false; @@ -204,7 +212,7 @@ } else { entity.setItem(result); } -@@ -317,11 +_,18 @@ +@@ -317,11 +434,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen boolean success = false; boolean wasEmpty = container.isEmpty(); if (current.isEmpty()) { @@ -225,7 +233,7 @@ int count = Math.min(itemStack.getCount(), space); itemStack.shrink(count); current.grow(count); -@@ -335,7 +_,7 @@ +@@ -335,7 +459,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen skipTickCount = 1; } @@ -234,11 +242,10 @@ } container.setChanged(); -@@ -344,13 +_,57 @@ - +@@ -345,12 +469,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen return itemStack; } -+ + + // CraftBukkit start + private static @Nullable Container runHopperInventorySearchEvent( + Container container, @@ -256,7 +263,7 @@ + return (event.getInventory() != null) ? ((org.bukkit.craftbukkit.inventory.CraftInventory) event.getInventory()).getInventory() : null; + } + // CraftBukkit end - ++ private static @Nullable Container getAttachedContainer(final Level level, final BlockPos blockPos, final HopperBlockEntity self) { - return getContainerAt(level, blockPos.relative(self.facing)); + // Paper start @@ -294,7 +301,7 @@ } public static List getItemsAtAndAbove(final Level level, final Hopper hopper) { -@@ -374,6 +_,7 @@ +@@ -374,6 +542,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } private static @Nullable Container getBlockContainer(final Level level, final BlockPos pos, final BlockState state) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index 8715b52b205d..eb136e23f409 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/LecternBlockEntity.java b/net/minecraft/world/level/block/entity/LecternBlockEntity.java +index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b6a64bf6e 100644 --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -36,11 +_,56 @@ +@@ -36,11 +36,56 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -58,7 +66,7 @@ @Override public int getContainerSize() { return 1; -@@ -84,11 +_,19 @@ +@@ -84,11 +129,19 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr @Override public void setItem(final int slot, final ItemStack itemStack) { @@ -79,7 +87,7 @@ } @Override -@@ -170,7 +_,7 @@ +@@ -170,7 +223,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr if (newPage != this.page) { this.page = newPage; this.setChanged(); @@ -88,7 +96,7 @@ } } -@@ -192,6 +_,36 @@ +@@ -192,6 +245,36 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr return book; } @@ -125,7 +133,7 @@ private CommandSourceStack createCommandSourceStack(final @Nullable Player player, final ServerLevel level) { String textName; Component displayName; -@@ -205,7 +_,7 @@ +@@ -205,7 +288,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr Vec3 pos = Vec3.atCenterOf(this.worldPosition); return new CommandSourceStack( @@ -134,7 +142,7 @@ ); } -@@ -246,7 +_,7 @@ +@@ -246,7 +329,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr @Override public AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 719a70f6d376..cbd38a436a3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/entity/SignBlockEntity.java b/net/minecraft/world/level/block/entity/SignBlockEntity.java +index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bdabf9eba9 100644 --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -59,10 +_,15 @@ +@@ -59,10 +59,15 @@ public class SignBlockEntity extends BlockEntity { } public boolean isFacingFrontText(final Player player) { @@ -18,7 +26,7 @@ float signYRot = sign.getYRotationDegrees(this.getBlockState()); float playerYRot = (float)(Mth.atan2(zd, xd) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(signYRot, playerYRot) <= 90.0F; -@@ -130,11 +_,13 @@ +@@ -130,11 +135,13 @@ public class SignBlockEntity extends BlockEntity { public void updateSignText(final Player player, final boolean frontText, final List lines) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { @@ -33,7 +41,7 @@ } } -@@ -143,19 +_,41 @@ +@@ -143,19 +150,41 @@ public class SignBlockEntity extends BlockEntity { return this.setText(function.apply(text), isFrontText); } @@ -78,7 +86,7 @@ return text; } -@@ -194,7 +_,23 @@ +@@ -194,7 +223,23 @@ public class SignBlockEntity extends BlockEntity { Style style = message.getStyle(); switch (style.getClickEvent()) { case ClickEvent.RunCommand command: @@ -103,7 +111,7 @@ hasAnyClickCommand = true; break; case ClickEvent.ShowDialog dialog: -@@ -213,11 +_,55 @@ +@@ -213,11 +258,55 @@ public class SignBlockEntity extends BlockEntity { return hasAnyClickCommand; } @@ -161,7 +169,7 @@ ); } -@@ -236,12 +_,17 @@ +@@ -236,12 +325,17 @@ public class SignBlockEntity extends BlockEntity { } public @Nullable UUID getPlayerWhoMayEdit() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 19d3e28e7056..29d7a67561de 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/grower/TreeGrower.java b/net/minecraft/world/level/block/grower/TreeGrower.java +index 9c898521851528c0625e019a72b69a3916e5da0a..4fbd75fcb86b5520ceee3218a53a661c9fc0ab44 100644 --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -132,6 +_,7 @@ +@@ -132,6 +132,7 @@ public final class TreeGrower { .get(megaFeatureKey) .orElse(null); if (featureHolder != null) { @@ -8,7 +16,7 @@ for (int dx = 0; dx >= -1; dx--) { for (int dz = 0; dz >= -1; dz--) { if (isTwoByTwoSapling(state, level, pos, dx, dz)) { -@@ -164,6 +_,7 @@ +@@ -164,6 +165,7 @@ public final class TreeGrower { if (featureHolder == null) { return false; } else { @@ -16,7 +24,7 @@ ConfiguredFeature feature = featureHolder.value(); BlockState emptyBlock = level.getFluidState(pos).createLegacyBlock(); level.setBlock(pos, emptyBlock, Block.UPDATE_NONE); -@@ -210,4 +_,58 @@ +@@ -210,4 +212,58 @@ public final class TreeGrower { : OptionalInt.empty(); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index e0e76a8fab22..21aa40fc69e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java +index 0080f8dc04994fa149ae9ce50bade886f43c9cfb..a2bc07a8348c5d7f30aafa0344d66715c89994b0 100644 --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -150,6 +_,12 @@ +@@ -150,6 +150,12 @@ public class PistonBaseBlock extends DirectionalBlock { @Override protected boolean triggerEvent(final BlockState state, final Level level, final BlockPos pos, final int b0, final int b1) { Direction direction = state.getValue(FACING); @@ -13,7 +21,7 @@ BlockState extendedState = state.setValue(EXTENDED, true); if (!level.isClientSide()) { boolean extend = this.getNeighborSignal(level, pos, direction); -@@ -182,10 +_,17 @@ +@@ -182,10 +188,17 @@ public class PistonBaseBlock extends DirectionalBlock { .defaultBlockState() .setValue(MovingPistonBlock.FACING, direction) .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); @@ -32,7 +40,7 @@ ) ); level.updateNeighborsAt(pos, movingPistonState.getBlock()); -@@ -209,13 +_,27 @@ +@@ -209,13 +222,27 @@ public class PistonBaseBlock extends DirectionalBlock { || movingState.getPistonPushReaction() != PushReaction.NORMAL && !movingState.is(Blocks.PISTON) && !movingState.is(Blocks.STICKY_PISTON)) { @@ -61,7 +69,7 @@ } level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.15F + 0.6F); -@@ -233,7 +_,7 @@ +@@ -233,7 +260,7 @@ public class PistonBaseBlock extends DirectionalBlock { final boolean allowDestroyable, final Direction connectionDirection ) { @@ -70,7 +78,7 @@ return false; } else if (state.isAir()) { return true; -@@ -289,12 +_,58 @@ +@@ -289,12 +316,58 @@ public class PistonBaseBlock extends DirectionalBlock { BlockState[] toUpdate = new BlockState[toPush.size() + toDestroy.size()]; Direction pushDirection = extending ? direction : direction.getOpposite(); int updateIndex = 0; @@ -130,7 +138,7 @@ if (!state.is(BlockTags.FIRE) && level.isClientSide()) { level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, getId(state)); } -@@ -305,13 +_,28 @@ +@@ -305,13 +378,28 @@ public class PistonBaseBlock extends DirectionalBlock { } for (int i = toPush.size() - 1; i >= 0; i--) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch index 6a0b645686f7..94b3f6baf970 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/border/WorldBorder.java b/net/minecraft/world/level/border/WorldBorder.java +index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e673cb1eac 100644 --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -37,6 +_,8 @@ +@@ -37,6 +37,8 @@ public class WorldBorder extends SavedData { private double centerZ; private int absoluteMaxSize = 29999984; private WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); @@ -9,7 +17,7 @@ public WorldBorder() { this(WorldBorder.Settings.DEFAULT); -@@ -58,6 +_,20 @@ +@@ -58,6 +60,20 @@ public class WorldBorder extends SavedData { return this.isWithinBounds(pos.getMinBlockX(), pos.getMinBlockZ()) && this.isWithinBounds(pos.getMaxBlockX(), pos.getMaxBlockZ()); } @@ -30,7 +38,7 @@ public boolean isWithinBounds(final AABB aabb) { return this.isWithinBounds(aabb.minX, aabb.minZ, aabb.maxX - 1.0E-5F, aabb.maxZ - 1.0E-5F); } -@@ -161,7 +_,15 @@ +@@ -161,7 +177,15 @@ public class WorldBorder extends SavedData { return this.centerZ; } @@ -47,7 +55,7 @@ this.centerX = x; this.centerZ = z; this.extent.onCenterChange(); -@@ -184,7 +_,18 @@ +@@ -184,7 +208,18 @@ public class WorldBorder extends SavedData { return this.extent.getLerpTarget(); } @@ -67,7 +75,7 @@ this.extent = new WorldBorder.StaticBorderExtent(size); this.setDirty(); -@@ -193,7 +_,21 @@ +@@ -193,7 +228,21 @@ public class WorldBorder extends SavedData { } } @@ -90,7 +98,7 @@ this.extent = (WorldBorder.BorderExtent)(from == to ? new WorldBorder.StaticBorderExtent(to) : new WorldBorder.MovingBorderExtent(from, to, ticks, gameTime)); -@@ -209,6 +_,7 @@ +@@ -209,6 +258,7 @@ public class WorldBorder extends SavedData { } public void addListener(final BorderChangeListener listener) { @@ -98,7 +106,7 @@ this.listeners.add(listener); } -@@ -282,6 +_,12 @@ +@@ -282,6 +332,12 @@ public class WorldBorder extends SavedData { } public void tick() { @@ -111,7 +119,7 @@ this.extent = this.extent.update(); } -@@ -302,6 +_,22 @@ +@@ -302,6 +358,22 @@ public class WorldBorder extends SavedData { } } @@ -134,7 +142,7 @@ private interface BorderExtent { double getMinX(final float deltaPartialTick); -@@ -438,6 +_,7 @@ +@@ -438,6 +510,7 @@ public class WorldBorder extends SavedData { this.previousSize = this.size; this.size = this.calculateSize(); if (this.lerpProgress <= 0L) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index 44a2ccd05e44..452a15e6f68c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java +index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420e396540d 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -105,8 +_,8 @@ +@@ -105,8 +105,8 @@ public abstract class ChunkGenerator { protected abstract MapCodec codec(); @@ -11,7 +19,7 @@ } public Optional getTypeNameForDataFixer() { -@@ -127,11 +_,29 @@ +@@ -127,11 +127,29 @@ public abstract class ChunkGenerator { ); public @Nullable Pair> findNearestMapStructure( @@ -42,7 +50,7 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> placementScans = new Object2ObjectArrayMap<>(); -@@ -226,6 +_,7 @@ +@@ -226,6 +244,7 @@ public abstract class ChunkGenerator { BlockPos.MutableBlockPos structurePos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : positions) { @@ -50,7 +58,7 @@ structurePos.set(SectionPos.sectionToBlockCoord(chunkPos.x(), 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z(), 8)); double distSqr = structurePos.distSqr(pos); boolean isClosest = closestPos == null || distSqr < closest; -@@ -260,9 +_,12 @@ +@@ -260,9 +279,12 @@ public abstract class ChunkGenerator { for (int x = -radius; x <= radius; x++) { boolean xEdge = x == -radius || x == radius; @@ -66,7 +74,7 @@ int sectorX = chunkOriginX + spacing * x; int sectorZ = chunkOriginZ + spacing * z; ChunkPos chunkTarget = config.getPotentialStructureChunk(seed, sectorX, sectorZ); -@@ -314,7 +_,7 @@ +@@ -314,7 +336,7 @@ public abstract class ChunkGenerator { } } @@ -75,7 +83,7 @@ ChunkPos centerPos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(centerPos)) { SectionPos sectionPos = SectionPos.of(centerPos, level.getMinSectionY()); -@@ -388,7 +_,14 @@ +@@ -388,7 +410,14 @@ public abstract class ChunkGenerator { Supplier currentlyGenerating = () -> featureRegistry.getResourceKey(feature) .map(Object::toString) .orElseGet(feature::toString); @@ -91,7 +99,7 @@ try { level.setCurrentlyGenerating(currentlyGenerating); -@@ -416,6 +_,34 @@ +@@ -416,6 +445,34 @@ public abstract class ChunkGenerator { } } } @@ -126,7 +134,7 @@ private static BoundingBox getWritableArea(final ChunkAccess chunk) { ChunkPos chunkPos = chunk.getPos(); -@@ -495,7 +_,7 @@ +@@ -495,7 +552,7 @@ public abstract class ChunkGenerator { } } @@ -135,7 +143,7 @@ if (structures.size() == 1) { this.tryGenerateStructure( structures.get(0), -@@ -590,6 +_,14 @@ +@@ -590,6 +647,14 @@ public abstract class ChunkGenerator { biomePredicate ); if (start.isValid()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index 7b2700f09563..17f2c0f04453 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +index 21995b893634bf315d9181991ce60a19d8967387..d43105cf0c29cb86a5e3c7c59dc5e02d2ab8e53f 100644 --- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java -@@ -41,22 +_,109 @@ +@@ -41,22 +41,109 @@ public class ChunkGeneratorStructureState { private final Map>> ringPositions = new Object2ObjectArrayMap<>(); private boolean hasGeneratedPositions; private final List> possibleStructureSets; @@ -23,9 +31,8 @@ .filter(structureSet -> hasBiomesForStructureSet(structureSet.value(), biomeSource)) .collect(Collectors.toUnmodifiableList()); - return new ChunkGeneratorStructureState(randomState, biomeSource, levelSeed, levelSeed, structures); -- } + return new ChunkGeneratorStructureState(randomState, biomeSource, levelSeed, levelSeed, ChunkGeneratorStructureState.injectSpigot(structures, conf), conf); // Spigot -+ } + } + // Paper start - Add missing structure set seed configs; horrible hack because spigot creates a ton of direct Holders which lose track of the identifying key + public static final class KeyedRandomSpreadStructurePlacement extends net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement { + public final net.minecraft.resources.ResourceKey key; @@ -115,7 +122,7 @@ private static boolean hasBiomesForStructureSet(final StructureSet structureSet, final BiomeSource biomeSource) { Stream> structureBiomes = structureSet.structures().stream().flatMap(entry -> { -@@ -71,13 +_,14 @@ +@@ -71,13 +158,14 @@ public class ChunkGeneratorStructureState { final BiomeSource biomeSource, final long levelSeed, final long concentricRingsSeed, @@ -131,7 +138,7 @@ } public List> possibleStructureSets() { -@@ -115,7 +_,13 @@ +@@ -115,7 +203,13 @@ public class ChunkGeneratorStructureState { int spread = placement.spread(); HolderSet preferredBiomes = placement.preferredBiomes(); RandomSource random = RandomSource.create(); @@ -145,7 +152,7 @@ double angle = random.nextDouble() * Math.PI * 2.0; int positionInCircle = 0; int circle = 0; -@@ -193,7 +_,7 @@ +@@ -193,7 +287,7 @@ public class ChunkGeneratorStructureState { for (int testX = sourceX - range; testX <= sourceX + range; testX++) { for (int testZ = sourceZ - range; testZ <= sourceZ + range; testZ++) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch index 403cc1a43287..924c608ce378 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java +index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed484cd42b 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -88,13 +_,21 @@ +@@ -88,13 +88,21 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { }; private final Map tickersInLevel = Maps.newHashMap(); public boolean loaded; @@ -23,7 +31,7 @@ public LevelChunk(final Level level, final ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -112,7 +_,7 @@ +@@ -112,7 +120,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { final @Nullable BlendingData blendingData ) { super(pos, upgradeData, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -32,7 +40,7 @@ this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); for (Heightmap.Types type : Heightmap.Types.values()) { -@@ -164,6 +_,10 @@ +@@ -164,6 +172,10 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.skyLightSources = protoChunk.skyLightSources; this.setLightCorrect(protoChunk.isLightCorrect()); this.markUnsaved(); @@ -43,7 +51,7 @@ } public void setUnsavedListener(final LevelChunk.UnsavedListener unsavedListener) { -@@ -172,6 +_,12 @@ +@@ -172,6 +184,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { unsavedListener.setUnsaved(this.chunkPos); } } @@ -56,7 +64,7 @@ @Override public void markUnsaved() { -@@ -205,8 +_,28 @@ +@@ -205,8 +223,28 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { : super.getListenerRegistry(section); } @@ -85,7 +93,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -241,28 +_,42 @@ +@@ -241,28 +279,42 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } } @@ -130,7 +138,7 @@ } @Override -@@ -323,7 +_,7 @@ +@@ -323,7 +375,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { if (!section.getBlockState(localX, localY, localZ).is(newBlock)) { return null; } else { @@ -139,7 +147,7 @@ state.onPlace(this.level, pos, oldState, movedByPiston); } -@@ -369,7 +_,12 @@ +@@ -369,7 +421,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } public @Nullable BlockEntity getBlockEntity(final BlockPos pos, final LevelChunk.EntityCreationType creationType) { @@ -153,7 +161,7 @@ if (blockEntity == null) { CompoundTag tag = this.pendingBlockEntities.remove(pos); if (tag != null) { -@@ -424,7 +_,13 @@ +@@ -424,7 +481,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { BlockPos pos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(pos); if (!blockState.hasBlockEntity()) { @@ -168,7 +176,7 @@ } else { BlockState cachedBlockState = blockEntity.getBlockState(); if (blockState != cachedBlockState) { -@@ -471,6 +_,11 @@ +@@ -471,6 +534,11 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { public void removeBlockEntity(final BlockPos pos) { if (this.isInLevel()) { BlockEntity removeThis = this.blockEntities.remove(pos); @@ -180,7 +188,7 @@ if (removeThis != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(removeThis, serverLevel); -@@ -514,6 +_,65 @@ +@@ -514,6 +582,65 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } } @@ -246,7 +254,7 @@ public boolean isEmpty() { return false; } -@@ -703,6 +_,7 @@ +@@ -703,6 +830,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } private void updateBlockEntityTicker(final T blockEntity) { @@ -254,7 +262,7 @@ BlockState state = blockEntity.getBlockState(); BlockEntityTicker ticker = state.getTicker(this.level, (BlockEntityType)blockEntity.getType()); if (ticker == null) { -@@ -752,23 +_,24 @@ +@@ -752,23 +880,24 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch similarity index 74% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch index 0b28e108703a..4f7fdc9a8258 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java +index 8be87ecbdad9988c67caf07751688c62e848013e..e2208bc7b58b0241192b1b79e3ac1aa0bb35f354 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -90,14 +_,31 @@ +@@ -90,14 +90,31 @@ public class ProtoChunk extends ChunkAccess { return new ChunkAccess.PackedTicks(this.blockTicks.pack(currentTick), this.fluidTicks.pack(currentTick)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch index df53949c1abb..ef01c23ca40d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java +index 985d64ce5aa8513f8fdc9877d2296e90bbb25c43..9409cc5c8dbd12ce6bdf34843da70170ebce41bd 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -83,6 +_,14 @@ +@@ -83,6 +83,14 @@ public class RegionFile implements AutoCloseable { if (offset != 0) { int sectorNumber = getSectorNumber(offset); int numSectors = getNumSectors(offset); @@ -15,7 +23,7 @@ if (sectorNumber < 2) { LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i, sectorNumber); this.offsets.put(i, 0); -@@ -117,6 +_,13 @@ +@@ -117,6 +125,13 @@ public class RegionFile implements AutoCloseable { } else { int sectorNumber = getSectorNumber(offset); int numSectors = getNumSectors(offset); @@ -29,7 +37,7 @@ int sectorsLength = numSectors * 4096; ByteBuffer buffer = ByteBuffer.allocate(sectorsLength); this.file.read(buffer, sectorNumber * 4096); -@@ -258,6 +_,7 @@ +@@ -258,6 +273,7 @@ public class RegionFile implements AutoCloseable { return true; } } catch (IOException var9) { @@ -37,7 +45,7 @@ return false; } } -@@ -329,6 +_,11 @@ +@@ -329,6 +345,11 @@ public class RegionFile implements AutoCloseable { try (FileChannel extFile = FileChannel.open(tmpPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { data.position(5); extFile.write(data); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch index 1c6ee4a3c21b..544b1c544fd2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +index c2a372e923ea76481adb08af51481c3fc5244db0..4473503da2459016859b2d72ecd7825df23f4be4 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -29,18 +_,20 @@ +@@ -29,18 +29,20 @@ public final class RegionFileStorage implements AutoCloseable { this.info = info; } @@ -23,7 +31,7 @@ RegionFile newRegion = new RegionFile(this.info, file, this.folder, this.sync); this.regionCache.putAndMoveToFirst(key, newRegion); return newRegion; -@@ -48,7 +_,12 @@ +@@ -48,7 +50,12 @@ public final class RegionFileStorage implements AutoCloseable { } public @Nullable CompoundTag read(final ChunkPos pos) throws IOException { @@ -37,7 +45,7 @@ CompoundTag var4; try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { -@@ -63,7 +_,12 @@ +@@ -63,7 +70,12 @@ public final class RegionFileStorage implements AutoCloseable { } public void scanChunk(final ChunkPos pos, final StreamTagVisitor scanner) throws IOException { @@ -51,7 +59,7 @@ try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { if (regionChunkInputStream != null) { -@@ -74,7 +_,7 @@ +@@ -74,7 +86,7 @@ public final class RegionFileStorage implements AutoCloseable { protected void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch index 803a761358c2..4d2a641697b0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +index b4809d1035bb7b8dc9557e146a2820ee94edfaa2..480623c30777fd230bf8428b16364db09806562b 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -92,6 +_,7 @@ +@@ -92,6 +92,7 @@ public record SerializableChunkData( List entities, List blockEntities, CompoundTag structureData @@ -8,7 +16,7 @@ ) { private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); -@@ -107,13 +_,39 @@ +@@ -107,13 +108,39 @@ public record SerializableChunkData( public static final String BLOCK_LIGHT_TAG = "BlockLight"; public static final String SKY_LIGHT_TAG = "SkyLight"; @@ -49,7 +57,7 @@ long lastUpdateTime = chunkData.getLongOr("LastUpdate", 0L); long inhabitedTime = chunkData.getLongOr("InhabitedTime", 0L); ChunkStatus status = chunkData.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); -@@ -152,7 +_,7 @@ +@@ -152,7 +179,7 @@ public record SerializableChunkData( CompoundTag structureData = chunkData.getCompoundOrEmpty("structures"); ListTag sectionTags = chunkData.getListOrEmpty("sections"); List sectionData = new ArrayList<>(sectionTags.size()); @@ -58,7 +66,7 @@ Codec> blockStatesCodec = containerFactory.blockStatesContainerCodec(); for (int i = 0; i < sectionTags.size(); i++) { -@@ -169,7 +_,7 @@ +@@ -169,7 +196,7 @@ public record SerializableChunkData( .getOrThrow(SerializableChunkData.ChunkReadException::new) ) .orElseGet(containerFactory::createForBlockStates); @@ -67,7 +75,7 @@ .map( container -> biomesCodec.parse(NbtOps.INSTANCE, container) .promotePartial(msg -> logErrors(chunkPos, y, msg)) -@@ -206,6 +_,7 @@ +@@ -206,6 +233,7 @@ public record SerializableChunkData( entities, blockEntities, structureData @@ -75,7 +83,7 @@ ); } } -@@ -283,6 +_,12 @@ +@@ -283,6 +311,12 @@ public record SerializableChunkData( } } @@ -88,7 +96,7 @@ chunk.setLightCorrect(this.lightCorrect); EnumSet toPrime = EnumSet.noneOf(Heightmap.Types.class); -@@ -389,6 +_,12 @@ +@@ -389,6 +423,12 @@ public record SerializableChunkData( CompoundTag structureData = packStructureData( StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() ); @@ -101,7 +109,7 @@ return new SerializableChunkData( level.palettedContainerFactory(), pos, -@@ -408,6 +_,7 @@ +@@ -408,6 +448,7 @@ public record SerializableChunkData( entities, blockEntities, structureData @@ -109,7 +117,7 @@ ); } } -@@ -475,6 +_,11 @@ +@@ -475,6 +516,11 @@ public record SerializableChunkData( this.heightmaps.forEach((type, data) -> heightmapsTag.put(type.getSerializationKey(), new LongArrayTag(data))); tag.put("Heightmaps", heightmapsTag); tag.put("structures", this.structureData); @@ -121,7 +129,7 @@ return tag; } -@@ -558,6 +_,12 @@ +@@ -558,6 +604,12 @@ public record SerializableChunkData( } else { StructureStart start = StructureStart.loadStaticStart(context, startsTag.getCompoundOrEmpty(key), seed); if (start != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch index 1de77966b738..e35935cbeae6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +index 55b5e09e0809d4c25868fc0cb9b62f5a1632a0dc..c5ac299e4a23d51a7777a678a0e1735bfb194f09 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -@@ -44,7 +_,19 @@ +@@ -44,7 +44,19 @@ public class SimpleRegionStorage implements AutoCloseable { } public CompletableFuture write(final ChunkPos pos, final Supplier supplier) { @@ -21,7 +29,7 @@ } public CompoundTag upgradeChunkTag(CompoundTag chunkTag, final int defaultVersion, final @Nullable CompoundTag dataFixContextTag, final int targetVersion) { -@@ -53,8 +_,25 @@ +@@ -53,8 +65,25 @@ public class SimpleRegionStorage implements AutoCloseable { return chunkTag; } else { try { diff --git a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index 1008a9bc4535..786141c54ffe 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e41561fa1a75 100644 --- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java -@@ -53,6 +_,16 @@ +@@ -53,6 +53,16 @@ public class PersistentEntitySectionManager implements A this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } @@ -17,7 +25,7 @@ private void removeSectionIfEmpty(final long sectionPos, final EntitySection section) { if (section.isEmpty()) { this.sectionStorage.remove(sectionPos); -@@ -60,6 +_,7 @@ +@@ -60,6 +70,7 @@ public class PersistentEntitySectionManager implements A } private boolean addEntityUuid(final T entity) { @@ -25,7 +33,7 @@ if (!this.knownUuids.add(entity.getUUID())) { LOGGER.warn("UUID of added entity already exists: {}", entity); return false; -@@ -73,6 +_,17 @@ +@@ -73,6 +84,17 @@ public class PersistentEntitySectionManager implements A } private boolean addEntity(final T entity, final boolean loaded) { @@ -43,7 +51,7 @@ if (!this.addEntityUuid(entity)) { return false; } else { -@@ -114,19 +_,23 @@ +@@ -114,19 +136,23 @@ public class PersistentEntitySectionManager implements A } private void startTicking(final T entity) { @@ -67,7 +75,7 @@ this.callbacks.onTrackingEnd(entity); this.visibleEntityStorage.remove(entity); } -@@ -137,6 +_,7 @@ +@@ -137,6 +163,7 @@ public class PersistentEntitySectionManager implements A } public void updateChunkStatus(final ChunkPos pos, final Visibility chunkStatus) { @@ -75,7 +83,7 @@ long chunkPosKey = pos.pack(); if (chunkStatus == Visibility.HIDDEN) { this.chunkVisibility.remove(chunkPosKey); -@@ -170,6 +_,7 @@ +@@ -170,6 +197,7 @@ public class PersistentEntitySectionManager implements A } public void ensureChunkQueuedForLoad(final long chunkPos) { @@ -83,7 +91,7 @@ PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPos); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.FRESH) { this.requestChunkLoad(chunkPos); -@@ -177,6 +_,11 @@ +@@ -177,6 +205,11 @@ public class PersistentEntitySectionManager implements A } private boolean storeChunkSections(final long chunkPos, final Consumer savedEntityVisitor) { @@ -95,7 +103,7 @@ PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPos); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) { return false; -@@ -187,6 +_,7 @@ +@@ -187,6 +220,7 @@ public class PersistentEntitySectionManager implements A .collect(Collectors.toList()); if (rootEntitiesToSave.isEmpty()) { if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) { @@ -103,7 +111,7 @@ this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), ImmutableList.of())); } -@@ -195,6 +_,7 @@ +@@ -195,6 +229,7 @@ public class PersistentEntitySectionManager implements A this.requestChunkLoad(chunkPos); return false; } else { @@ -111,7 +119,7 @@ this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), rootEntitiesToSave)); rootEntitiesToSave.forEach(savedEntityVisitor); return true; -@@ -203,6 +_,7 @@ +@@ -203,6 +238,7 @@ public class PersistentEntitySectionManager implements A } private void requestChunkLoad(final long chunkKey) { @@ -119,7 +127,7 @@ this.chunkLoadStatuses.put(chunkKey, PersistentEntitySectionManager.ChunkLoadStatus.PENDING); ChunkPos pos = ChunkPos.unpack(chunkKey); this.permanentStorage.loadEntities(pos).thenAccept(this.loadingInbox::add).exceptionally(t -> { -@@ -212,7 +_,8 @@ +@@ -212,7 +248,8 @@ public class PersistentEntitySectionManager implements A } private boolean processChunkUnload(final long chunkKey) { @@ -129,7 +137,7 @@ if (!storeSuccessful) { return false; } else { -@@ -222,7 +_,7 @@ +@@ -222,7 +259,7 @@ public class PersistentEntitySectionManager implements A } private void unloadEntity(final EntityAccess e) { @@ -138,7 +146,7 @@ e.setLevelCallback(EntityInLevelCallback.NULL); } -@@ -231,14 +_,20 @@ +@@ -231,14 +268,20 @@ public class PersistentEntitySectionManager implements A } public void processPendingLoads() { @@ -159,7 +167,7 @@ this.processPendingLoads(); this.processUnloads(); } -@@ -256,6 +_,7 @@ +@@ -256,6 +299,7 @@ public class PersistentEntitySectionManager implements A } public void autoSave() { @@ -167,7 +175,7 @@ this.getAllChunksToSave().forEach(chunkKey -> { boolean shouldUnload = this.chunkVisibility.get(chunkKey) == Visibility.HIDDEN; if (shouldUnload) { -@@ -267,6 +_,7 @@ +@@ -267,6 +311,7 @@ public class PersistentEntitySectionManager implements A } public void saveAll() { @@ -175,7 +183,7 @@ LongSet chunksToSave = this.getAllChunksToSave(); while (!chunksToSave.isEmpty()) { -@@ -283,7 +_,13 @@ +@@ -283,7 +328,13 @@ public class PersistentEntitySectionManager implements A @Override public void close() throws IOException { @@ -190,7 +198,7 @@ this.permanentStorage.close(); } -@@ -386,6 +_,7 @@ +@@ -386,6 +437,7 @@ public class PersistentEntitySectionManager implements A BlockPos pos = this.entity.blockPosition(); long newSectionPos = SectionPos.asLong(pos); if (newSectionPos != this.currentSectionKey) { @@ -198,7 +206,7 @@ Visibility previousStatus = this.currentSection.getStatus(); if (!this.currentSection.remove(this.entity)) { PersistentEntitySectionManager.LOGGER -@@ -433,6 +_,7 @@ +@@ -433,6 +485,7 @@ public class PersistentEntitySectionManager implements A @Override public void onRemove(final Entity.RemovalReason reason) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index e102937119a9..1f54d0fd123b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java +index 5b4bcf60db341d19380019d8a25d3ad4222c860b..d37ded5474cdb1065bb573e89075d88b6d16243f 100644 --- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java +++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java -@@ -123,7 +_,7 @@ +@@ -123,7 +123,7 @@ public interface VibrationSystem { public static final Codec CODEC = RecordCodecBuilder.create( i -> i.group( VibrationInfo.CODEC.lenientOptionalFieldOf("event").forGetter(o -> Optional.ofNullable(o.currentVibration)), @@ -9,7 +17,7 @@ ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.Data::getTravelTimeInTicks) ) .apply( -@@ -219,7 +_,14 @@ +@@ -219,7 +219,14 @@ public interface VibrationSystem { return false; } else { Vec3 destination = listenerSourcePos.get(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 5bbe28c783cf..1a08f4e973c4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/levelgen/PatrolSpawner.java b/net/minecraft/world/level/levelgen/PatrolSpawner.java +index 7a41b894b22c68a10667be43e2232d399ae9cd2a..17f9b46c5876f6f9f40246aacbf0f4b59958b4c1 100644 --- a/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -18,17 +_,51 @@ +@@ -18,17 +18,51 @@ public class PatrolSpawner implements CustomSpawner { @Override public void tick(final ServerLevel level, final boolean spawnEnemies) { @@ -59,7 +67,7 @@ if (!player.isSpectator()) { if (!level.isCloseToVillage(player.blockPosition(), 2)) { int x = (24 + random.nextInt(24)) * (random.nextBoolean() ? -1 : 1); -@@ -80,7 +_,7 @@ +@@ -80,7 +114,7 @@ public class PatrolSpawner implements CustomSpawner { mob.setPos(pos.getX(), pos.getY(), pos.getZ()); mob.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch index f3f18c1d4f9d..9459e299d55b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java +index a3a99a0995b6c93041110164fde70d6e1547955a..469fb7695b46420b5817928b8f905c4df3aa9bfe 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -43,7 +_,7 @@ +@@ -43,7 +43,7 @@ public class StructureCheck { private final ChunkScanAccess storageAccess; private final RegistryAccess registryAccess; private final StructureTemplateManager structureTemplateManager; @@ -9,7 +17,7 @@ private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; -@@ -57,7 +_,7 @@ +@@ -57,7 +57,7 @@ public class StructureCheck { final ChunkScanAccess storageAccess, final RegistryAccess registryAccess, final StructureTemplateManager structureTemplateManager, @@ -18,7 +26,7 @@ final ChunkGenerator chunkGenerator, final RandomState randomState, final LevelHeightAccessor heightAccessor, -@@ -77,6 +_,20 @@ +@@ -77,6 +77,20 @@ public class StructureCheck { this.fixerUpper = fixerUpper; } @@ -39,7 +47,7 @@ public StructureCheckResult checkStart(final ChunkPos pos, final Structure structure, final StructurePlacement placement, final boolean requireUnreferenced) { long posKey = pos.pack(); Object2IntMap cachedResult = this.loadedChunks.get(posKey); -@@ -86,7 +_,7 @@ +@@ -86,7 +100,7 @@ public class StructureCheck { StructureCheckResult storageCheckResult = this.tryLoadFromStorage(pos, structure, requireUnreferenced, posKey); if (storageCheckResult != null) { return storageCheckResult; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 7dda6e8c0a52..827b401af2bf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +index 61019270d4816912e2097aabe3791c6ce4b9b833..b8e6c84f633778d4023fe4b31475b10e61b67ce4 100644 --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -80,6 +_,10 @@ +@@ -80,6 +80,10 @@ public class StructureTemplate { public final List entityInfoList = Lists.newArrayList(); private Vec3i size = Vec3i.ZERO; private String author = "?"; @@ -11,7 +19,7 @@ public Vec3i getSize() { return this.size; -@@ -251,7 +_,7 @@ +@@ -251,7 +255,7 @@ public class StructureTemplate { } public boolean placeInWorld( @@ -20,7 +28,7 @@ final BlockPos position, final BlockPos referencePos, final StructurePlaceSettings settings, -@@ -261,6 +_,19 @@ +@@ -261,6 +265,19 @@ public class StructureTemplate { if (this.palettes.isEmpty()) { return false; } else { @@ -40,7 +48,7 @@ List blockInfoList = settings.getRandomPalette(this.palettes, position).blocks(); if ((!blockInfoList.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 -@@ -288,6 +_,20 @@ +@@ -288,6 +305,20 @@ public class StructureTemplate { level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); } @@ -61,7 +69,7 @@ if (level.setBlock(blockPos, state, updateMode)) { minX = Math.min(minX, blockPos.getX()); minY = Math.min(minY, blockPos.getY()); -@@ -299,7 +_,7 @@ +@@ -299,7 +330,7 @@ public class StructureTemplate { if (blockInfo.nbt != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { @@ -70,7 +78,7 @@ blockInfo.nbt.putLong("LootTableSeed", random.nextLong()); } -@@ -384,7 +_,11 @@ +@@ -384,7 +415,11 @@ public class StructureTemplate { if (blockInfox.getSecond() != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { @@ -83,7 +91,7 @@ } } } -@@ -392,7 +_,7 @@ +@@ -392,7 +427,7 @@ public class StructureTemplate { if (!settings.isIgnoreEntities()) { this.placeEntities( @@ -92,7 +100,7 @@ position, settings.getMirror(), settings.getRotation(), -@@ -512,14 +_,17 @@ +@@ -512,14 +547,17 @@ public class StructureTemplate { }); } } @@ -115,7 +123,7 @@ } public Vec3i getSize(final Rotation rotation) { -@@ -710,6 +_,11 @@ +@@ -710,6 +748,11 @@ public class StructureTemplate { tag.put("entities", entityList); tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); @@ -127,7 +135,7 @@ return NbtUtils.addCurrentDataVersion(tag); } -@@ -735,6 +_,11 @@ +@@ -735,6 +778,11 @@ public class StructureTemplate { BlockPos blockPos = new BlockPos(blockPosTag.getIntOr(0, 0), blockPosTag.getIntOr(1, 0), blockPosTag.getIntOr(2, 0)); entityTag.getCompound("nbt").ifPresent(nbt -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(pos, blockPos, nbt))); }); @@ -139,7 +147,7 @@ } private void loadPalette(final HolderGetter blockLookup, final ListTag paletteList, final ListTag blockList) { -@@ -834,7 +_,7 @@ +@@ -834,7 +882,7 @@ public class StructureTemplate { public static final class Palette { private final List blocks; diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch index adbd1fb3edbd..0c58f015cc5a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java +index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30ebf4854f6 100644 --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -121,6 +_,15 @@ +@@ -121,6 +121,15 @@ public abstract class FlowingFluid extends Fluid { Fluid newBelowFluidType = newBelowFluid.getType(); if (belowFluid.canBeReplacedWith(level, belowPos, newBelowFluidType, Direction.DOWN) && canHoldSpecificFluid(level, belowPos, belowState, newBelowFluidType)) { @@ -16,7 +24,7 @@ this.spreadTo(level, belowPos, belowState, Direction.DOWN, newBelowFluid); if (this.sourceNeighborCount(level, pos) >= 3) { this.spreadToSides(level, pos, fluidState, state); -@@ -149,7 +_,18 @@ +@@ -149,7 +158,18 @@ public abstract class FlowingFluid extends Fluid { Direction spread = entry.getKey(); FluidState newNeighborFluid = entry.getValue(); BlockPos neighborPos = pos.relative(spread); @@ -36,7 +44,7 @@ } } } -@@ -161,7 +_,8 @@ +@@ -161,7 +181,8 @@ public abstract class FlowingFluid extends Fluid { for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos relativePos = mutablePos.setWithOffset(pos, direction); @@ -46,7 +54,7 @@ FluidState fluidState = blockState.getFluidState(); if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, relativePos, blockState)) { if (fluidState.isSource()) { -@@ -264,13 +_,15 @@ +@@ -264,13 +285,15 @@ public abstract class FlowingFluid extends Fluid { container.placeLiquid(level, pos, state, target); } else { if (!state.isAir()) { @@ -63,7 +71,7 @@ protected abstract void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state); protected int getSlopeDistance( -@@ -281,7 +_,8 @@ +@@ -281,7 +304,8 @@ public abstract class FlowingFluid extends Fluid { for (Direction direction : Direction.Plane.HORIZONTAL) { if (direction != from) { BlockPos testPos = pos.relative(direction); @@ -73,7 +81,7 @@ FluidState testFluidState = testState.getFluidState(); if (this.canPassThrough(level, this.getFlowing(), pos, state, direction, testPos, testState, testFluidState)) { if (context.isHole(testPos)) { -@@ -363,7 +_,8 @@ +@@ -363,7 +387,8 @@ public abstract class FlowingFluid extends Fluid { for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos testPos = pos.relative(direction); @@ -83,7 +91,7 @@ FluidState testFluidState = testState.getFluidState(); if (this.canMaybePassThrough(level, pos, state, direction, testPos, testState, testFluidState)) { FluidState newFluid = this.getNewLiquid(level, testPos, testState); -@@ -434,10 +_,24 @@ +@@ -434,10 +459,24 @@ public abstract class FlowingFluid extends Fluid { if (newFluidState.isEmpty()) { fluidState = newFluidState; blockState = Blocks.AIR.defaultBlockState(); @@ -108,7 +116,7 @@ level.setBlock(pos, blockState, Block.UPDATE_ALL); level.scheduleTick(pos, newFluidState.getType(), tickDelay); } -@@ -510,8 +_,27 @@ +@@ -510,8 +549,27 @@ public abstract class FlowingFluid extends Fluid { return this.getBlockState(pos, this.getCacheKey(pos)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch index 94746ee3e6ba..febf1b50a595 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/portal/PortalForcer.java b/net/minecraft/world/level/portal/PortalForcer.java +index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469f7a500a3 100644 --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java -@@ -39,18 +_,32 @@ +@@ -39,18 +39,32 @@ public class PortalForcer { this.level = level; } @@ -34,7 +42,7 @@ Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, portalAxis); double closestFullDistanceSqr = -1.0; BlockPos closestFullPosition = null; -@@ -58,10 +_,15 @@ +@@ -58,10 +72,15 @@ public class PortalForcer { BlockPos closestPartialPosition = null; WorldBorder worldBorder = this.level.getWorldBorder(); int maxPlaceableY = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); @@ -51,7 +59,7 @@ int height = Math.min(maxPlaceableY, this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, columnPos.getX(), columnPos.getZ())); if (worldBorder.isWithinBounds(columnPos) && worldBorder.isWithinBounds(columnPos.move(direction, 1))) { columnPos.move(direction.getOpposite(), 1); -@@ -105,6 +_,7 @@ +@@ -105,6 +124,7 @@ public class PortalForcer { closestFullDistanceSqr = closestPartialDistanceSqr; } @@ -59,7 +67,7 @@ if (closestFullDistanceSqr == -1.0) { int minStartY = Math.max(this.level.getMinY() - -1, 70); int maxStartY = maxPlaceableY - 9; -@@ -129,7 +_,7 @@ +@@ -129,7 +149,7 @@ public class PortalForcer { height, width * direction.getStepZ() + box * clockWise.getStepZ() ); @@ -68,7 +76,7 @@ } } } -@@ -139,7 +_,7 @@ +@@ -139,7 +159,7 @@ public class PortalForcer { for (int height = -1; height < 4; height++) { if (width == -1 || width == 2 || height == -1 || height == 3) { mutable.setWithOffset(closestFullPosition, width * direction.getStepX(), height, width * direction.getStepZ()); @@ -77,7 +85,7 @@ } } } -@@ -149,10 +_,20 @@ +@@ -149,10 +169,20 @@ public class PortalForcer { for (int width = 0; width < 2; width++) { for (int heightx = 0; heightx < 3; heightx++) { mutable.setWithOffset(closestFullPosition, width * direction.getStepX(), heightx, width * direction.getStepZ()); @@ -99,7 +107,7 @@ return Optional.of(new BlockUtil.FoundRectangle(closestFullPosition.immutable(), 2, 3)); } -@@ -169,6 +_,13 @@ +@@ -169,6 +199,13 @@ public class PortalForcer { mutable.setWithOffset( origin, direction.getStepX() * width + clockWise.getStepX() * offset, height, direction.getStepZ() * width + clockWise.getStepZ() * offset ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch index 17f9e3ae898f..508418c11b6e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/portal/PortalShape.java b/net/minecraft/world/level/portal/PortalShape.java +index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014ddf4b549 100644 --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -38,10 +_,14 @@ +@@ -38,10 +38,14 @@ public class PortalShape { private final BlockPos bottomLeft; private final int height; private final int width; @@ -16,7 +24,7 @@ this.axis = axis; this.numPortalBlocks = portalBlockCount; this.rightDir = rightDir; -@@ -67,23 +_,24 @@ +@@ -67,23 +71,24 @@ public class PortalShape { } public static PortalShape findAnyShape(final BlockGetter level, final BlockPos pos, final Direction.Axis axis) { @@ -48,7 +56,7 @@ int minY = Math.max(level.getMinY(), pos.getY() - 21); while (pos.getY() > minY && isEmpty(level.getBlockState(pos.below()))) { -@@ -91,16 +_,16 @@ +@@ -91,16 +96,16 @@ public class PortalShape { } Direction leftDir = rightDir.getOpposite(); @@ -69,7 +77,7 @@ BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); for (int width = 0; width <= 21; width++) { -@@ -108,6 +_,7 @@ +@@ -108,6 +113,7 @@ public class PortalShape { BlockState blockState = level.getBlockState(blockPos); if (!isEmpty(blockState)) { if (FRAME.test(blockState, level, blockPos)) { @@ -77,7 +85,7 @@ return width; } break; -@@ -117,27 +_,29 @@ +@@ -117,27 +123,29 @@ public class PortalShape { if (!FRAME.test(belowState, level, blockPos)) { break; } @@ -111,7 +119,7 @@ } return true; -@@ -149,7 +_,7 @@ +@@ -149,7 +157,7 @@ public class PortalShape { final Direction rightDir, final BlockPos.MutableBlockPos pos, final int width, @@ -120,7 +128,7 @@ ) { for (int height = 0; height < 21; height++) { pos.set(bottomLeft).move(Direction.UP, height).move(rightDir, -1); -@@ -173,6 +_,10 @@ +@@ -173,6 +181,10 @@ public class PortalShape { portalBlockCount.increment(); } } @@ -131,7 +139,7 @@ } return 21; -@@ -186,10 +_,23 @@ +@@ -186,10 +198,23 @@ public class PortalShape { return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -141,7 +149,7 @@ + org.bukkit.World bworld = level.getMinecraftWorld().getWorld(); + // Copy below for loop BlockState portalState = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); - BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) ++ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + .forEach(pos -> this.blocks.setBlock(pos, portalState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE)); + org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getSnapshotBlocks(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); + level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); // todo the list is not really mutable here unlike other call and the portal frame is included @@ -150,7 +158,7 @@ + return false; + } + // CraftBukkit end -+ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) .forEach(pos -> level.setBlock(pos, portalState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE)); + return true; // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch index d9bc406db00b..0730cbca92bc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java +index 65624f84591c51b3344d0a9e041f2b3fd163f6fa..353085151026b0d695be3c35d0638ecd39a962ce 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java -@@ -66,8 +_,26 @@ +@@ -66,8 +66,26 @@ public interface NeighborUpdater { final @Nullable Orientation orientation, final boolean movedByPiston ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 515c75d42202..9bd430363d06 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/storage/LevelStorageSource.java b/net/minecraft/world/level/storage/LevelStorageSource.java +index e3de51f7171931bb0d00fd31a2e0fd173af4d390..ea43d9b47cc9f2e201fd43e56d8dc896e4b1cabd 100644 --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -149,12 +_,13 @@ +@@ -149,12 +149,13 @@ public class LevelStorageSource { final WorldDataConfiguration dataConfiguration, final Registry datapackDimensions, final HolderLookup.Provider registryAccess @@ -15,7 +23,7 @@ .mapOrElse( Function.identity(), error -> { -@@ -174,13 +_,13 @@ +@@ -174,13 +175,13 @@ public class LevelStorageSource { } public static DataResult readExistingSavedData( @@ -32,7 +40,7 @@ } catch (IOException var6) { return DataResult.error(var6::getMessage); } -@@ -396,7 +_,7 @@ +@@ -396,7 +397,7 @@ public class LevelStorageSource { public LevelStorageSource.LevelStorageAccess validateAndCreateAccess(final String levelId) throws IOException, ContentValidationException { Path levelPath = this.getLevelPath(levelId); diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch similarity index 80% rename from paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index 3403b87ebef5..bae069df3e09 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/storage/PlayerDataStorage.java b/net/minecraft/world/level/storage/PlayerDataStorage.java +index 4671807c1abad46678beb8870e0645b575d18236..41cbb27861f33ad8d7523f3b2fef9a30a69693a9 100644 --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -31,6 +_,7 @@ +@@ -31,6 +31,7 @@ public class PlayerDataStorage { } public void save(final Player player) { @@ -8,7 +16,7 @@ try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(player.problemPath(), LOGGER)) { TagValueOutput output = TagValueOutput.createWithContext(reporter, player.registryAccess()); player.saveWithoutId(output); -@@ -42,7 +_,7 @@ +@@ -42,7 +43,7 @@ public class PlayerDataStorage { Path oldFile = playerDirPath.resolve(player.getStringUUID() + ".dat_old"); Util.safeReplaceFile(realFile, tmpFile, oldFile); } catch (Exception var11) { @@ -17,7 +25,7 @@ } } -@@ -62,9 +_,25 @@ +@@ -62,9 +63,25 @@ public class PlayerDataStorage { private Optional load(final NameAndId nameAndId, final String suffix) { File realFile = new File(this.playerDir, nameAndId.id() + suffix); @@ -44,7 +52,7 @@ } catch (Exception var5) { LOGGER.warn("Failed to load player data for {}", nameAndId.name()); } -@@ -84,4 +_,10 @@ +@@ -84,4 +101,10 @@ public class PlayerDataStorage { return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, tag, version); }); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch index ff0ee4e714cc..21ff7692989c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/storage/SavedDataStorage.java b/net/minecraft/world/level/storage/SavedDataStorage.java +index 9b9af027bab82c19d12c8b7e26bf3a940c6123e2..971c3f3311f5eb132817589ee5b7f65736c25b76 100644 --- a/net/minecraft/world/level/storage/SavedDataStorage.java +++ b/net/minecraft/world/level/storage/SavedDataStorage.java -@@ -156,7 +_,7 @@ +@@ -156,7 +156,7 @@ public class SavedDataStorage implements AutoCloseable { } else { int threads = Util.maxAllowedExecutorThreads(); int taskCount = tagsToSave.size(); @@ -9,7 +17,7 @@ this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(ignored -> { List> tasks = new ArrayList<>(threads); int bucketSize = Mth.positiveCeilDiv(taskCount, threads); -@@ -177,7 +_,7 @@ +@@ -177,7 +177,7 @@ public class SavedDataStorage implements AutoCloseable { ignored -> CompletableFuture.allOf( tagsToSave.entrySet() .stream() diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch rename to paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch index 8862d67128e3..f13f2772654b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch +++ b/paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch @@ -1,6 +1,14 @@ +From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 +From: File +Date: Sun, 20 Apr 1997 14:37:42 +0100 +Subject: [PATCH] paper File Patches + + +diff --git a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +index 27e2c28bfabe090ee7035a4f78c6b4d8ce1eee92..425d499f45280b59ba225d19218a991614ce06db 100644 --- a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -@@ -83,9 +_,25 @@ +@@ -83,9 +83,25 @@ public class ExplorationMapFunction extends LootItemConditionalFunction { Vec3 lootPos = context.getOptionalParameter(LootContextParams.ORIGIN); if (lootPos != null) { ServerLevel level = context.getLevel(); diff --git a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch index be129bb6bd26..cd847e191d32 100644 --- a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch +++ b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch @@ -8,7 +8,7 @@ } public String getTitle() { -@@ -217,7 +_,7 @@ +@@ -214,7 +_,7 @@ } public static void preload() { diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch index b6cb3432e751..686ffc34053d 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/EntityArgument.java +++ b/net/minecraft/commands/arguments/EntityArgument.java -@@ -107,9 +_,14 @@ +@@ -106,9 +_,14 @@ } private EntitySelector parse(final StringReader reader, final boolean allowSelectors) throws CommandSyntaxException { @@ -16,7 +16,7 @@ if (selector.getMaxResults() > 1 && this.single) { if (this.playersOnly) { reader.setCursor(0); -@@ -131,7 +_,13 @@ +@@ -130,7 +_,13 @@ if (contextBuilder.getSource() instanceof SharedSuggestionProvider source) { StringReader reader = new StringReader(builder.getInput()); reader.setCursor(builder.getStart()); diff --git a/paper-server/patches/sources/net/minecraft/core/RegistrySetBuilder.java.patch b/paper-server/patches/sources/net/minecraft/core/RegistrySetBuilder.java.patch index 3f34cbfa1e2b..f65cdf1d81ab 100644 --- a/paper-server/patches/sources/net/minecraft/core/RegistrySetBuilder.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/RegistrySetBuilder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/RegistrySetBuilder.java +++ b/net/minecraft/core/RegistrySetBuilder.java -@@ -42,6 +_,13 @@ +@@ -41,6 +_,13 @@ final Map, Holder.Reference> entries ) { return new RegistrySetBuilder.EmptyTagRegistryLookup(owner) { @@ -14,7 +14,7 @@ @Override public ResourceKey> key() { return key; -@@ -128,6 +_,13 @@ +@@ -123,6 +_,13 @@ public Optional> lookup(final ResourceKey> registryKey) { return getEntry(registryKey).map(Entry::opsInfo); } diff --git a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch index 70d5f3e67fab..b53444754aeb 100644 --- a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch @@ -10,5 +10,5 @@ - InteractionResult interact(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack itemInHand); + InteractionResult interact(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack itemInHand, net.minecraft.core.Direction hitDirection); // Paper - add hitDirection - public static class Dispatcher { + class Dispatcher { private final Map, CauldronInteraction> tags = new HashMap<>(); diff --git a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch index 651d45dd8b23..5e6262f04cb4 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java -@@ -54,7 +_,7 @@ +@@ -51,7 +_,7 @@ private static CompoundTag loadCompound(final DataInput input, final NbtAccounter accounter) throws IOException { accounter.accountBytes(48L); @@ -9,7 +9,7 @@ byte tagType; while ((tagType = input.readByte()) != 0) { -@@ -171,7 +_,7 @@ +@@ -165,7 +_,7 @@ } public CompoundTag() { @@ -18,7 +18,7 @@ } @Override -@@ -400,9 +_,16 @@ +@@ -394,9 +_,16 @@ @Override public CompoundTag copy() { @@ -38,7 +38,7 @@ } @Override -@@ -523,22 +_,47 @@ +@@ -517,22 +_,47 @@ this.merge((CompoundTag)codec.encoder().encodeStart(ops, value).getOrThrow()); } diff --git a/paper-server/patches/sources/net/minecraft/nbt/NbtAccounter.java.patch b/paper-server/patches/sources/net/minecraft/nbt/NbtAccounter.java.patch index b0f9bc4d69ca..48cfa9296ed5 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtAccounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtAccounter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/nbt/NbtAccounter.java +++ b/net/minecraft/nbt/NbtAccounter.java -@@ -48,6 +_,16 @@ - } +@@ -50,6 +_,16 @@ + this.usage += size; } + // Paper start - Track codec depth diff --git a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch index e94e7511736f..153bf5a8bd81 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -117,7 +_,12 @@ +@@ -108,7 +_,12 @@ return read(input, NbtAccounter.unlimitedHeap()); } diff --git a/paper-server/patches/sources/net/minecraft/network/PacketEncoder.java.patch b/paper-server/patches/sources/net/minecraft/network/PacketEncoder.java.patch index ad66db91b916..aeff0a1f1538 100644 --- a/paper-server/patches/sources/net/minecraft/network/PacketEncoder.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/PacketEncoder.java.patch @@ -16,7 +16,7 @@ if (LOGGER.isDebugEnabled()) { @@ -44,7 +_,33 @@ - throw var9; + throw t; } finally { + // Paper start - Handle large packets disconnecting client + int packetLength = output.readableBytes(); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch index 1c01a7e3c5f9..31495aad7995 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/OutgoingChatMessage.java.patch @@ -11,10 +11,10 @@ + // Paper end + static OutgoingChatMessage create(final PlayerChatMessage message) { - return (OutgoingChatMessage)(message.isSystem() - ? new OutgoingChatMessage.Disguised(message.decoratedContent()) -@@ -16,7 +_,13 @@ - public record Disguised(@Override Component content) implements OutgoingChatMessage { + return message.isSystem() ? new OutgoingChatMessage.Disguised(message.decoratedContent()) : new OutgoingChatMessage.Player(message); + } +@@ -14,7 +_,13 @@ + record Disguised(@Override Component content) implements OutgoingChatMessage { @Override public void sendToPlayer(final ServerPlayer player, final boolean filtered, final ChatType.Bound chatType) { - player.connection.sendDisguisedChatMessage(this.content, chatType); @@ -28,7 +28,7 @@ } } -@@ -28,7 +_,14 @@ +@@ -26,7 +_,14 @@ @Override public void sendToPlayer(final ServerPlayer player, final boolean filtered, final ChatType.Bound chatType) { diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch index 200a4d0c8260..aeb5a6b6d50b 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java +++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java -@@ -20,7 +_,7 @@ +@@ -16,7 +_,7 @@ } private ClientIntentionPacket(final FriendlyByteBuf input) { diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch index 33c19095a735..74bbabef15c6 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -14,7 +14,7 @@ public boolean isDirty() { return this.isDirty; } -@@ -167,6 +_,19 @@ +@@ -171,6 +_,19 @@ return new SynchedEntityData(this.entity, this.itemsById); } } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch index c6335f8a1965..3716c968149e 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/DebugCommand.java +++ b/net/minecraft/server/commands/DebugCommand.java -@@ -277,6 +_,13 @@ +@@ -273,6 +_,13 @@ return true; } @@ -13,4 +13,4 @@ + @Override public void close() { - IOUtils.closeQuietly((Writer)this.output); + IOUtils.closeQuietly(this.output); diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/ServerWatchdog.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/ServerWatchdog.java.patch index d0a306f98961..6979890a62db 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/ServerWatchdog.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/ServerWatchdog.java +++ b/net/minecraft/server/dedicated/ServerWatchdog.java -@@ -49,7 +_,7 @@ +@@ -48,7 +_,7 @@ CrashReport report = createWatchdogCrashReport("Watching Server", this.server.getRunningThread().threadId()); this.server.fillSystemReport(report.getSystemReport()); CrashReportCategory serverStats = report.addCategory("Performance stats"); diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch index 9b7f098a142d..9bf3449060fc 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch @@ -26,9 +26,9 @@ public static Properties loadFromFile(final Path file) { + if (!Files.exists(file)) return new Properties(); // CraftBukkit - SPIGOT-7465, MC-264979: Don't load if file doesn't exist try { - try { - Properties var13; -@@ -65,7 +_,53 @@ + try (InputStream is = Files.newInputStream(file)) { + CharsetDecoder reportingUtf8Decoder = StandardCharsets.UTF_8 +@@ -57,7 +_,53 @@ } public void store(final Path output) { @@ -81,9 +81,9 @@ + java.io.BufferedWriter os = new java.io.BufferedWriter(new java.io.OutputStreamWriter(bufferedOutputStream, java.nio.charset.StandardCharsets.UTF_8.newEncoder())); + // Paper end - allow skipping server.properties comments this.properties.store(os, "Minecraft server properties"); - } catch (IOException var7) { + } catch (IOException e) { LOGGER.error("Failed to store properties to file: {}", output); -@@ -95,7 +_,7 @@ +@@ -87,7 +_,7 @@ } public @Nullable String getStringRaw(final String key) { @@ -92,7 +92,7 @@ } protected @Nullable V getLegacy(final String key, final Function deserializer) { -@@ -109,6 +_,16 @@ +@@ -101,6 +_,16 @@ } protected V get(final String key, final Function deserializer, final Function serializer, final V defaultValue) { @@ -109,7 +109,7 @@ String value = this.getStringRaw(key); V result = MoreObjects.firstNonNull(value != null ? deserializer.apply(value) : null, defaultValue); this.properties.put(key, serializer.apply(result)); -@@ -191,7 +_,7 @@ +@@ -183,7 +_,7 @@ return result; } @@ -118,7 +118,7 @@ public class MutableValue implements Supplier { private final String key; -@@ -214,7 +_,7 @@ +@@ -204,7 +_,7 @@ public T update(final RegistryAccess registryAccess, final V value) { Properties properties = Settings.this.cloneProperties(); properties.put(this.key, this.serializer.apply(value)); diff --git a/paper-server/patches/sources/net/minecraft/server/gui/MinecraftServerGui.java.patch b/paper-server/patches/sources/net/minecraft/server/gui/MinecraftServerGui.java.patch index 53a34b4876cc..7d1652db9cb0 100644 --- a/paper-server/patches/sources/net/minecraft/server/gui/MinecraftServerGui.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/gui/MinecraftServerGui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/gui/MinecraftServerGui.java +++ b/net/minecraft/server/gui/MinecraftServerGui.java -@@ -54,6 +_,13 @@ +@@ -53,6 +_,13 @@ frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); @@ -14,15 +14,15 @@ frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent event) { -@@ -75,6 +_,7 @@ +@@ -74,6 +_,7 @@ this.setLayout(new BorderLayout()); try { + this.add(this.buildOnboardingPanel(), "North"); // Paper - Add onboarding message for initial server start this.add(this.buildChatPanel(), "Center"); this.add(this.buildInfoPanel(), "West"); - } catch (Exception var3) { -@@ -88,7 +_,7 @@ + } catch (Exception e) { +@@ -87,7 +_,7 @@ private JComponent buildInfoPanel() { JPanel panel = new JPanel(new BorderLayout()); @@ -31,7 +31,7 @@ this.finalizers.add(comp::close); panel.add(comp, "North"); panel.add(this.buildPlayerPanel(), "Center"); -@@ -155,6 +_,7 @@ +@@ -150,6 +_,7 @@ this.finalizers.forEach(Runnable::run); } @@ -39,7 +39,7 @@ public void print(final JTextArea console, final JScrollPane scrollPane, final String line) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> this.print(console, scrollPane, line)); -@@ -167,7 +_,7 @@ +@@ -162,7 +_,7 @@ } try { @@ -48,7 +48,7 @@ } catch (BadLocationException var8) { } -@@ -176,4 +_,37 @@ +@@ -171,4 +_,37 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch index 0b09c2876f86..fc6279bfda6a 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -73,6 +_,12 @@ +@@ -72,6 +_,12 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -13,7 +13,7 @@ for (ChunkHolder chunksToUpdateFuture : this.chunksToUpdateFutures) { chunksToUpdateFuture.updateHighestAllowedStatus(scheduler); } -@@ -120,8 +_,10 @@ +@@ -119,8 +_,10 @@ ChunkPos chunk = pos.chunk(); long chunkPos = chunk.pack(); ObjectSet chunkPlayers = this.playersPerChunk.get(chunkPos); diff --git a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch index ab3151fb49dd..51a37b731551 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch @@ -53,15 +53,22 @@ if (in.isReadable()) { - if (!readCustomPayloadPacket(in)) { +- return; + // Paper start - Replace below + if (in.readUnsignedByte() != LegacyProtocolUtils.CUSTOM_PAYLOAD_PACKET_ID) { + body = this.readLegacy1_6(ctx, in); + if (body == null) { + return; + } -+ } + } +- +- LOGGER.debug("Ping: (1.6) from {}", socket); + // Paper end - Replace below -+ } else { + } else { +- LOGGER.debug("Ping: (1.4-1.5.x) from {}", socket); +- } +- +- String body = createVersion1Response(this.server); + LOGGER.debug("Ping: (1.4-1.5.x) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? socket : ""); // Paper - Respect logIPs option + } + @@ -72,12 +79,9 @@ + ctx.close(); + in.release(); + connectNormally = false; - return; - } - -- LOGGER.debug("Ping: (1.6) from {}", socket); -- } else { -- LOGGER.debug("Ping: (1.4-1.5.x) from {}", socket); ++ return; ++ } ++ + // See createVersion1Response + body = String.format( + Locale.ROOT, @@ -88,9 +92,7 @@ + event.getMaxPlayers() + ); + // Paper end - Call PaperServerListPingEvent and use results - } -- -- String body = createVersion1Response(this.server); ++ } sendFlushAndClose(ctx, createLegacyDisconnectPacket(ctx.alloc(), body)); } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch index 9d6515de84a2..cd94a1842b79 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch @@ -96,9 +96,9 @@ if (loginError != null) { this.disconnect(loginError); return; -@@ -229,4 +_,29 @@ - this.startNextTask(); - } +@@ -231,4 +_,29 @@ + this.currentTask = null; + this.startNextTask(); } + + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/server/players/ProfileResolver.java.patch b/paper-server/patches/sources/net/minecraft/server/players/ProfileResolver.java.patch index 0ea61aa2ca67..e9aa7334268d 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/ProfileResolver.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/ProfileResolver.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/ProfileResolver.java +++ b/net/minecraft/server/players/ProfileResolver.java -@@ -26,7 +_,7 @@ +@@ -25,7 +_,7 @@ private final LoadingCache> profileCacheByName; private final LoadingCache> profileCacheById; @@ -9,7 +9,7 @@ this.profileCacheById = CacheBuilder.newBuilder() .expireAfterAccess(Duration.ofMinutes(10L)) .maximumSize(256L) -@@ -38,7 +_,13 @@ +@@ -33,7 +_,13 @@ @Override public Optional load(final UUID profileId) { ProfileResult result = sessionService.fetchProfile(profileId, true); diff --git a/paper-server/patches/sources/net/minecraft/server/players/UserBanListEntry.java.patch b/paper-server/patches/sources/net/minecraft/server/players/UserBanListEntry.java.patch index ff61eda61ae4..de30853b7873 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/UserBanListEntry.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/UserBanListEntry.java.patch @@ -11,7 +11,7 @@ @Override @@ -39,4 +_,31 @@ NameAndId user = this.getUser(); - return (Component)(user != null ? Component.literal(user.name()) : MESSAGE_UNKNOWN_USER); + return user != null ? Component.literal(user.name()) : MESSAGE_UNKNOWN_USER; } + + // Spigot start diff --git a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch b/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch index dc552adc08ca..978ae5743a5c 100644 --- a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch @@ -39,7 +39,7 @@ + } // Paper - optimize ServerWaypointManager with locator bar disabled if (player.isTransmittingWaypoint()) { - this.trackWaypoint((WaypointTransmitter)player); + this.trackWaypoint(player); @@ -65,6 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch index a095b44e2e5a..d93c2ca8aa6a 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java @@ -75,9 +_,21 @@ - LOGGER.error("Couldn't parse statistics file {}", file, var9); + LOGGER.error("Couldn't parse statistics file {}", file, e); } } + // Paper start - Moved after stat fetching for player state file diff --git a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch index 09f37b6e02ff..30caf439d8c8 100644 --- a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch @@ -11,8 +11,8 @@ + // Paper end final Map> newTags = new HashMap<>(); TagEntry.Lookup lookup = new TagEntry.Lookup() { - { -@@ -116,7 +_,7 @@ + @Override +@@ -112,7 +_,7 @@ ) .ifRight(tag -> newTags.put(id, (List)tag)) ); @@ -21,7 +21,7 @@ } public static Map, List>> loadTagsFromNetwork(final TagNetworkSerialization.NetworkPayload tags, final Registry registry) { -@@ -124,18 +_,39 @@ +@@ -120,18 +_,39 @@ } public static List> loadTagsForExistingRegistries(final ResourceManager manager, final RegistryAccess layer) { @@ -64,7 +64,7 @@ } private static Map, List>> wrapTags( -@@ -144,12 +_,12 @@ +@@ -140,12 +_,12 @@ return tags.entrySet().stream().collect(Collectors.toUnmodifiableMap(e -> TagKey.create(registryKey, e.getKey()), Entry::getValue)); } diff --git a/paper-server/patches/sources/net/minecraft/util/PlaceholderLookupProvider.java.patch b/paper-server/patches/sources/net/minecraft/util/PlaceholderLookupProvider.java.patch index fd298fb998c3..8b6037975a17 100644 --- a/paper-server/patches/sources/net/minecraft/util/PlaceholderLookupProvider.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/PlaceholderLookupProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/PlaceholderLookupProvider.java +++ b/net/minecraft/util/PlaceholderLookupProvider.java -@@ -57,6 +_,13 @@ +@@ -52,6 +_,13 @@ ) ); } diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixTypes.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixTypes.java.patch index b4b8c5b0387c..873079b65960 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixTypes.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixTypes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixTypes.java +++ b/net/minecraft/util/datafix/DataFixTypes.java -@@ -15,6 +_,7 @@ +@@ -14,6 +_,7 @@ import net.minecraft.util.datafix.fixes.References; public enum DataFixTypes { @@ -8,7 +8,7 @@ LEVEL(References.LEVEL), LEVEL_SUMMARY(References.LIGHTWEIGHT_LEVEL), PLAYER(References.PLAYER), -@@ -81,6 +_,7 @@ +@@ -76,6 +_,7 @@ } public Dynamic update(final DataFixer fixerUpper, final Dynamic input, final int fromVersion, final int toVersion) { diff --git a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch index 8f7f4e9277be..77e33b2b417c 100644 --- a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/parsing/packrat/Scope.java +++ b/net/minecraft/util/parsing/packrat/Scope.java -@@ -279,4 +_,31 @@ +@@ -265,4 +_,31 @@ return true; } diff --git a/paper-server/patches/sources/net/minecraft/world/Container.java.patch b/paper-server/patches/sources/net/minecraft/world/Container.java.patch index 3cb5c688c52b..3c41d7c7df52 100644 --- a/paper-server/patches/sources/net/minecraft/world/Container.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/Container.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -32,9 +_,7 @@ +@@ -31,9 +_,7 @@ void setItem(int slot, ItemStack itemStack); @@ -11,7 +11,7 @@ default int getMaxStackSize(final ItemStack itemStack) { return Math.min(this.getMaxStackSize(), itemStack.getMaxStackSize()); -@@ -147,4 +_,22 @@ +@@ -142,4 +_,22 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch index 951cc1765580..fe3410c3f32e 100644 --- a/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/LockCode.java +++ b/net/minecraft/world/LockCode.java -@@ -23,8 +_,14 @@ +@@ -22,8 +_,14 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch index 7cd390264779..25036bc72c6f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch @@ -23,18 +23,20 @@ private EntitySelector() { } -@@ -33,12 +_,12 @@ +@@ -33,14 +_,14 @@ ? Predicates.alwaysFalse() : NO_SPECTATORS.and( input -> { - if (!input.isPushable()) { + if (!input.isPushable() || !input.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(input)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule return false; - } else if (!entity.level().isClientSide() || input instanceof Player player && player.isLocalPlayer()) { + } + + if (!entity.level().isClientSide() || input instanceof Player player && player.isLocalPlayer()) { Team theirTeam = input.getTeam(); Team.CollisionRule theirCollisionRule = theirTeam == null ? Team.CollisionRule.ALWAYS : theirTeam.getCollisionRule(); - if (theirCollisionRule == Team.CollisionRule.NEVER) { + if (theirCollisionRule == Team.CollisionRule.NEVER || (input instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions)) { // Paper - Configurable player collision return false; - } else { - boolean sameTeam = ownTeam != null && ownTeam.isAlliedTo(theirTeam); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 849af41b4e84..e6b3913dced5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -159,7 +159,7 @@ ); } -@@ -1616,8 +_,23 @@ +@@ -1610,8 +_,23 @@ return this.builtInRegistryHolder; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch index d459738f55c7..ff81da3f9853 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/InsideBlockEffectApplier.java +++ b/net/minecraft/world/entity/InsideBlockEffectApplier.java @@ -32,7 +_,7 @@ - public static class StepBasedCollector implements InsideBlockEffectApplier { + class StepBasedCollector implements InsideBlockEffectApplier { private static final InsideBlockEffectType[] APPLY_ORDER = InsideBlockEffectType.values(); private static final int NO_STEP = -1; - private final Set effectsInStep = EnumSet.noneOf(InsideBlockEffectType.class); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index d225c0e9b8a8..1c620fa1f0b8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -13,7 +13,7 @@ } } -@@ -134,7 +_,7 @@ +@@ -136,7 +_,7 @@ default void stopBeingAngry() { this.setLastHurtByMob(null); this.setPersistentAngerTarget(null); @@ -22,7 +22,7 @@ this.setPersistentAngerEndTime(-1L); } -@@ -144,9 +_,21 @@ +@@ -146,9 +_,21 @@ void setTarget(final @Nullable LivingEntity target); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index 8d8868ad1659..3832201368a2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java +++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java -@@ -108,7 +_,9 @@ +@@ -110,7 +_,9 @@ Block block = blockState.getBlock(); Block blockBelow = level.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState)) { @@ -10,7 +10,7 @@ } if (blockState.isAir() && blockBelow instanceof FarmlandBlock && body.hasFarmSeeds()) { -@@ -119,9 +_,11 @@ +@@ -121,9 +_,11 @@ boolean ok = false; if (!itemStack.isEmpty() && itemStack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) && itemStack.getItem() instanceof BlockItem blockItem) { BlockState place = blockItem.getBlock().defaultBlockState(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch index f1da063b5129..fb545187280b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -71,7 +_,7 @@ +@@ -75,7 +_,7 @@ public void tick() { boolean isOwnerFarAway = this.tamable.shouldTryTeleportToOwner(); if (!isOwnerFarAway) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch index 6bff6c78716a..4f0f4e0f07d2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -44,7 +44,7 @@ this.level().broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); this.level().playSound(player, this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(player, interactionItem); -@@ -381,6 +_,7 @@ +@@ -385,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,7 +52,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -433,7 +_,7 @@ +@@ -437,7 +_,7 @@ super.readAdditionalSaveData(input); this.readInventoryFromTag(input); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -61,7 +61,7 @@ } @Override -@@ -452,15 +_,17 @@ +@@ -456,15 +_,17 @@ this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch index 4b25ea0df6ad..dbfa9347d75d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -270,7 +_,7 @@ +@@ -269,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -9,7 +9,7 @@ } public Axolotl.Variant getVariant() { -@@ -484,10 +_,10 @@ +@@ -483,10 +_,10 @@ if (regenEffect == null || regenEffect.endsWithin(2399)) { int previousDuration = regenEffect != null ? regenEffect.getDuration() : 0; int regenDuration = Math.min(2400, 100 + previousDuration); @@ -22,7 +22,7 @@ } @Override -@@ -565,6 +_,13 @@ +@@ -564,6 +_,13 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch index 566982fdccc6..9d5f60997782 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch @@ -58,7 +58,7 @@ } } } -@@ -573,7 +_,7 @@ +@@ -571,7 +_,7 @@ 0.3F * Mth.sin(Dolphin.this.getXRot() * Mth.DEG_TO_RAD) * 1.5F, 0.3F * Mth.cos(Dolphin.this.getYRot() * Mth.DEG_TO_RAD) * Mth.cos(Dolphin.this.getXRot() * Mth.DEG_TO_RAD) + Mth.sin(dir) * pow2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index 5e1eb25224f2..f0d60ff3e63d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java -@@ -75,6 +_,12 @@ +@@ -74,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch index 73571e79cb8a..c29009405f50 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/equine/AbstractHorse.java -@@ -125,6 +_,7 @@ +@@ -124,6 +_,7 @@ protected boolean canGallop = true; protected int gallopSoundCounter; public @Nullable EntityReference owner; @@ -8,7 +8,7 @@ protected AbstractHorse(final EntityType type, final Level level) { super(type, level); -@@ -253,7 +_,7 @@ +@@ -252,7 +_,7 @@ } @Override @@ -17,7 +17,7 @@ return !this.isVehicle(); } -@@ -300,7 +_,7 @@ +@@ -299,7 +_,7 @@ public void createInventory() { SimpleContainer old = this.inventory; @@ -26,7 +26,7 @@ if (old != null) { int max = Math.min(old.getContainerSize(), this.inventory.getContainerSize()); -@@ -392,7 +_,7 @@ +@@ -391,7 +_,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -455,7 +_,7 @@ +@@ -454,7 +_,7 @@ temper = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { itemUsed = true; @@ -44,7 +44,7 @@ } } else if (itemStack.is(Items.GOLDEN_APPLE) || itemStack.is(Items.ENCHANTED_GOLDEN_APPLE)) { heal = 10.0F; -@@ -463,12 +_,12 @@ +@@ -462,12 +_,12 @@ temper = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { itemUsed = true; @@ -59,7 +59,7 @@ itemUsed = true; } -@@ -539,7 +_,7 @@ +@@ -538,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel level && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -641,6 +_,16 @@ +@@ -640,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(final Player player, final InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -792,6 +_,7 @@ +@@ -793,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -802,6 +_,7 @@ +@@ -803,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -895,6 +_,17 @@ +@@ -896,6 +_,17 @@ @Override public void handleStartJump(final int jumpScale) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch index b759422d79b9..d2befdb881c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch @@ -21,7 +21,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -601,15 +_,20 @@ +@@ -603,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -46,7 +46,7 @@ ); } -@@ -635,7 +_,7 @@ +@@ -637,7 +_,7 @@ } private static class CatTemptGoal extends TemptGoal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch index 19a985077464..6455b126ac7d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/fox/Fox.java +++ b/net/minecraft/world/entity/animal/fox/Fox.java -@@ -447,7 +_,7 @@ +@@ -446,7 +_,7 @@ input.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity); this.setSleeping(input.getBooleanOr("Sleeping", false)); this.setVariant(input.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT)); @@ -9,7 +9,7 @@ this.setIsCrouching(input.getBooleanOr("Crouching", false)); if (this.level() instanceof ServerLevel) { this.setTargetGoals(); -@@ -464,6 +_,12 @@ +@@ -463,6 +_,12 @@ } public void setSitting(final boolean value) { @@ -22,7 +22,7 @@ this.setFlag(FLAG_SITTING, value); } -@@ -523,19 +_,20 @@ +@@ -522,19 +_,20 @@ thrownItem.setPickUpDelay(40); thrownItem.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = itemStack.getCount(); if (count > 1) { this.dropItemStack(itemStack.split(count - 1)); -@@ -546,7 +_,7 @@ +@@ -545,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, itemStack.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, itemStack.getCount()); @@ -55,7 +55,7 @@ this.ticksSinceEaten = 0; } } -@@ -637,12 +_,12 @@ +@@ -636,12 +_,12 @@ } @Override @@ -70,7 +70,7 @@ } private void wakeUp() { -@@ -703,15 +_,33 @@ +@@ -702,15 +_,33 @@ return this.getTrustedEntities().anyMatch(trusted -> trusted.matches(entity)); } @@ -108,7 +108,7 @@ } public static boolean isPathClear(final Fox fox, final LivingEntity target) { -@@ -896,6 +_,19 @@ +@@ -883,6 +_,19 @@ offspring.addTrustedEntity(partnerLoveCause); } @@ -128,7 +128,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(loveCause, this.animal, this.partner, offspring); -@@ -905,14 +_,12 @@ +@@ -892,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -146,7 +146,7 @@ ); } } -@@ -977,6 +_,7 @@ +@@ -963,6 +_,7 @@ private void pickSweetBerries(final BlockState state) { int age = state.getValue(SweetBerryBushBlock.AGE); state.setValue(SweetBerryBushBlock.AGE, 1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch index e5842b62dbdd..a9689ab74200 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch @@ -37,7 +37,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand); } -@@ -281,20 +_,27 @@ +@@ -287,20 +_,27 @@ private void turnToStatue(final ServerLevel level) { BlockPos pos = this.blockPosition(); @@ -71,7 +71,7 @@ this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { -@@ -424,12 +_,32 @@ +@@ -430,12 +_,32 @@ } @Override @@ -108,7 +108,7 @@ @Override public boolean readyForShearing() { -@@ -443,9 +_,13 @@ +@@ -449,9 +_,13 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch index afbb13319fe3..88a50e071cab 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch @@ -16,5 +16,5 @@ - if (!below.entityCanStandOn(level, belowPos, this)) { + if (!below.entityCanStandOn(level, belowPos, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper - Add option to allow iron golems to spawn in air return false; - } else { - for (int i = 1; i < 3; i++) { + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch index e201972bc875..270b632f02a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/happyghast/HappyGhast.java +++ b/net/minecraft/world/entity/animal/happyghast/HappyGhast.java -@@ -300,7 +_,7 @@ +@@ -299,7 +_,7 @@ @Override protected void addPassenger(final Entity passenger) { if (!this.isVehicle()) { @@ -9,7 +9,7 @@ } super.addPassenger(passenger); -@@ -314,16 +_,21 @@ +@@ -313,16 +_,21 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 3d324243e54b..2acdfb97c877 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -23,7 +23,7 @@ } } } -@@ -431,7 +_,7 @@ +@@ -433,7 +_,7 @@ } private void tryToTame(final Player player) { @@ -32,7 +32,7 @@ this.tame(player); this.navigation.stop(); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -486,7 +_,7 @@ +@@ -488,7 +_,7 @@ protected void createInventory() { SimpleContainer old = this.inventory; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch index 422c65d8fdf1..91e231893a2b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/panda/Panda.java +++ b/net/minecraft/world/entity/animal/panda/Panda.java -@@ -133,6 +_,7 @@ +@@ -132,6 +_,7 @@ } public void sit(final boolean value) { @@ -8,7 +8,7 @@ this.setFlag(FLAG_SIT, value); } -@@ -517,24 +_,28 @@ +@@ -516,24 +_,28 @@ for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { @@ -39,7 +39,7 @@ } } -@@ -629,8 +_,9 @@ +@@ -632,8 +_,9 @@ } if (!this.level().isClientSide() && this.getAge() == 0 && this.canFallInLove()) { @@ -50,7 +50,7 @@ } else { if (!(this.level() instanceof ServerLevel level) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -640,7 +_,9 @@ +@@ -643,7 +_,9 @@ this.eat(true); ItemStack pandasCurrentItem = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!pandasCurrentItem.isEmpty() && !player.hasInfiniteMaterials()) { @@ -60,7 +60,7 @@ } this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(interactionItemStack.getItem(), 1)); -@@ -862,7 +_,7 @@ +@@ -867,7 +_,7 @@ @Override protected void alertOther(final Mob other, final LivingEntity hurtByMob) { if (other instanceof Panda && other.isAggressive()) { @@ -69,7 +69,7 @@ } } } -@@ -1093,7 +_,9 @@ +@@ -1094,7 +_,9 @@ public void stop() { ItemStack itemStack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch index 1876e579f8ef..a2a9d4c236a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/pig/Pig.java +++ b/net/minecraft/world/entity/animal/pig/Pig.java -@@ -198,7 +_,14 @@ +@@ -196,7 +_,14 @@ ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), zp -> { zp.populateDefaultEquipmentSlots(this.getRandom(), level.getCurrentDifficultyAt(this.blockPosition())); zp.setPersistenceRequired(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 291d4a74687c..b7c12399fc8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -233,7 +233,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -738,6 +_,7 @@ +@@ -739,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); @@ -241,7 +241,7 @@ } @Override -@@ -745,6 +_,7 @@ +@@ -746,6 +_,7 @@ super.readAdditionalSaveData(input); input.getInt("DragonPhase").ifPresent(phaseId -> this.phaseManager.setPhase(EnderDragonPhase.getById(phaseId))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); @@ -249,7 +249,7 @@ } @Override -@@ -785,7 +_,7 @@ +@@ -786,7 +_,7 @@ EnderDragonPhase phase = phaseInstance.getPhase(); Vec3 result; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -258,7 +258,7 @@ float dist = Math.max((float)Math.sqrt(egg.distToCenterSqr(this.position())) / 4.0F, 1.0F); float yOffset = 6.0F / dist; float xRotOld = this.getXRot(); -@@ -872,4 +_,19 @@ +@@ -873,4 +_,19 @@ protected float sanitizeScale(final float scale) { return 1.0F; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index ecb892c4f6a5..8301b5f05a36 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -74,6 +_,7 @@ +@@ -73,6 +_,7 @@ private final int[] nextHeadUpdate = new int[2]; private final int[] idleHeadUpdates = new int[2]; private int destroyBlocksTick; @@ -8,7 +8,7 @@ public final ServerBossEvent bossEvent = Util.make( new ServerBossEvent(Mth.createInsecureUUID(this.random), this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS), e -> e.setDarkenScreen(true) -@@ -265,15 +_,40 @@ +@@ -264,15 +_,40 @@ int newCount = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - newCount / 220.0F); if (newCount <= 0) { @@ -52,7 +52,7 @@ } } else { super.customServerAiStep(level); -@@ -307,6 +_,7 @@ +@@ -306,6 +_,7 @@ ); if (!entities.isEmpty()) { LivingEntity selected = entities.get(this.random.nextInt(entities.size())); @@ -60,7 +60,7 @@ this.setAlternativeTarget(i, selected.getId()); } } -@@ -336,6 +_,11 @@ +@@ -335,6 +_,11 @@ )) { BlockState state = level.getBlockState(blockPos); if (canDestroy(state)) { @@ -72,7 +72,7 @@ destroyed = level.destroyBlock(blockPos, true, this) || destroyed; } } -@@ -347,7 +_,7 @@ +@@ -346,7 +_,7 @@ } if (this.tickCount % 20 == 0) { @@ -81,7 +81,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -485,16 +_,16 @@ +@@ -488,16 +_,16 @@ @Override protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { super.dropCustomDeathLoot(level, source, killedByPlayer); @@ -102,7 +102,7 @@ } else { this.noActionTime = 0; } -@@ -549,12 +_,18 @@ +@@ -552,12 +_,18 @@ @Override public boolean canUsePortal(final boolean ignorePassenger) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch index 831086353ed5..9206393a4921 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch @@ -13,7 +13,7 @@ private static boolean isReflectedFireball(final DamageSource source) { return source.getDirectEntity() instanceof LargeFireball && source.getEntity() instanceof Player; } -@@ -375,6 +_,7 @@ +@@ -377,6 +_,7 @@ } LargeFireball entity = new LargeFireball(level, this.ghast, direction.normalize(), this.ghast.getExplosionPower()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch index 877221a21da5..c0103a325d3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -277,8 +_,10 @@ +@@ -276,8 +_,10 @@ } @Override @@ -13,7 +13,7 @@ if (this.level().isClientSide()) { this.clientOldAttachPosition = this.blockPosition(); } -@@ -389,6 +_,14 @@ +@@ -388,6 +_,14 @@ && this.level().getWorldBorder().isWithinBounds(target) && this.level().noCollision(this, new AABB(target).deflate(1.0E-6))) { Direction attachmentDirection = this.findAttachableSurface(target); @@ -28,7 +28,7 @@ if (attachmentDirection != null) { this.unRide(); this.setAttachFace(attachmentDirection); -@@ -453,7 +_,12 @@ +@@ -452,7 +_,12 @@ if (baby != null) { baby.setVariant(this.getVariant()); baby.snapTo(oldPosition); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch index aa33a3442320..aab60ca41e1f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Vex.java +++ b/net/minecraft/world/entity/monster/Vex.java -@@ -293,7 +_,7 @@ +@@ -288,7 +_,7 @@ @Override public void start() { Mob owner = Vex.this.getOwner(); @@ -9,7 +9,7 @@ super.start(); } } -@@ -355,7 +_,10 @@ +@@ -347,7 +_,10 @@ for (int attempts = 0; attempts < 3; attempts++) { BlockPos testPos = boundOrigin.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index e1f7aa867c05..309b070b4b0b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -191,9 +_,9 @@ +@@ -193,9 +_,9 @@ } @Override @@ -12,7 +12,7 @@ } } -@@ -318,7 +_,7 @@ +@@ -320,7 +_,7 @@ } this.makeSound(this.getDeathSound()); @@ -21,7 +21,7 @@ } public void creakingDeathEffects(final DamageSource source) { -@@ -446,9 +_,9 @@ +@@ -448,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch index 48f194a1f2da..41c71c41f3d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/illager/Evoker.java +++ b/net/minecraft/world/entity/monster/illager/Evoker.java -@@ -271,7 +_,7 @@ +@@ -254,7 +_,7 @@ serverLevel.getScoreboard().addPlayerToTeam(vex.getScoreboardName(), evokerTeam); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch index 9be002440e38..110a69882b7e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/illager/Illusioner.java +++ b/net/minecraft/world/entity/monster/illager/Illusioner.java -@@ -175,7 +_,8 @@ +@@ -174,7 +_,8 @@ @Override public void performRangedAttack(final LivingEntity target, final float power) { @@ -10,7 +10,7 @@ ItemStack projectile = this.getProjectile(bowItem); AbstractArrow arrow = ProjectileUtil.getMobArrow(this, projectile, power, bowItem); double xd = target.getX() - this.getX(); -@@ -183,9 +_,21 @@ +@@ -182,9 +_,21 @@ double zd = target.getZ() - this.getZ(); double distanceToTarget = Math.sqrt(xd * xd + zd * zd); if (this.level() instanceof ServerLevel serverLevel) { @@ -33,7 +33,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -237,7 +_,7 @@ +@@ -231,7 +_,7 @@ @Override protected void performSpellCasting() { @@ -42,7 +42,7 @@ } @Override -@@ -274,7 +_,7 @@ +@@ -263,7 +_,7 @@ @Override protected void performSpellCasting() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch index 3c1ea820e027..e2bfaa22c116 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java +++ b/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java -@@ -216,6 +_,11 @@ +@@ -208,6 +_,11 @@ public void tick() { this.attackWarmupDelay--; if (this.attackWarmupDelay == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index ae7121d1021c..0d41994c6fd3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -76,7 +76,7 @@ body.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } } -@@ -467,7 +_,7 @@ +@@ -466,7 +_,7 @@ return false; } else if (isAdmiringDisabled(body) && body.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -85,7 +85,7 @@ return isNotHoldingLovedItemInOffHand(body); } else { boolean hasSpace = body.canAddToInventory(itemStack); -@@ -476,11 +_,16 @@ +@@ -475,11 +_,16 @@ } else if (isFood(itemStack)) { return !hasEatenRecently(body) && hasSpace; } else { @@ -103,7 +103,7 @@ protected static boolean isLovedItem(final ItemStack itemStack) { return itemStack.is(ItemTags.PIGLIN_LOVED); } -@@ -540,6 +_,7 @@ +@@ -537,6 +_,7 @@ } public static void angerNearbyPiglins(final ServerLevel level, final Player player, final boolean onlyIfTheySeeThePlayer) { @@ -111,7 +111,7 @@ List nearbyPiglins = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0)); nearbyPiglins.stream().filter(PiglinAi::isIdle).filter(piglin -> !onlyIfTheySeeThePlayer || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> { if (level.getGameRules().get(GameRules.UNIVERSAL_ANGER)) { -@@ -564,7 +_,7 @@ +@@ -561,7 +_,7 @@ } protected static boolean canAdmire(final Piglin body, final ItemStack playerHeldItemStack) { @@ -120,7 +120,7 @@ } protected static void wasHurtBy(final ServerLevel level, final Piglin body, final LivingEntity attacker) { -@@ -813,6 +_,11 @@ +@@ -811,6 +_,11 @@ return body.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -132,7 +132,7 @@ private static boolean isBarterCurrency(final ItemStack itemStack) { return itemStack.is(BARTERING_ITEM); } -@@ -850,7 +_,7 @@ +@@ -848,7 +_,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(final Piglin body) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch index 0f515a9b2f00..e74512076626 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java -@@ -71,6 +_,7 @@ +@@ -66,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; @@ -8,7 +8,7 @@ protected AbstractSkeleton(final EntityType type, final Level level) { super(type, level); -@@ -95,6 +_,21 @@ +@@ -90,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -30,7 +30,7 @@ @Override protected void playStepSound(final BlockPos pos, final BlockState blockState) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -125,7 +_,7 @@ +@@ -120,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); @@ -39,7 +39,7 @@ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) { this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.setDropChance(EquipmentSlot.HEAD, 0.0F); -@@ -163,7 +_,8 @@ +@@ -158,7 +_,8 @@ @Override public void performRangedAttack(final LivingEntity target, final float power) { @@ -49,7 +49,7 @@ ItemStack projectile = this.getProjectile(bowItem); AbstractArrow arrow = this.getArrow(projectile, power, bowItem); double xd = target.getX() - this.getX(); -@@ -171,9 +_,21 @@ +@@ -166,9 +_,21 @@ double zd = target.getZ() - this.getZ(); double distanceToTarget = Math.sqrt(xd * xd + zd * zd); if (this.level() instanceof ServerLevel serverLevel) { @@ -72,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -197,11 +_,14 @@ +@@ -192,11 +_,14 @@ protected void readAdditionalSaveData(final ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); @@ -89,7 +89,7 @@ if (!this.level().isClientSide()) { this.reassessWeaponGoal(); } -@@ -215,4 +_,12 @@ +@@ -210,4 +_,12 @@ public boolean wantsToPickUp(final ServerLevel level, final ItemStack itemStack) { return !itemStack.is(ItemTags.SPEARS) && super.wantsToPickUp(level, itemStack); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch index 576a3eeafcaa..0350347f6d76 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -404,7 +_,7 @@ +@@ -403,7 +_,7 @@ public static void applyDarknessAround(final ServerLevel level, final Vec3 position, final @Nullable Entity source, final int darknessRadius) { MobEffectInstance darkness = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false); @@ -9,7 +9,7 @@ } @Override -@@ -446,8 +_,17 @@ +@@ -445,8 +_,17 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch index 80d743b511a9..781915b36cfa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch @@ -9,7 +9,7 @@ } } -@@ -376,7 +_,12 @@ +@@ -378,7 +_,12 @@ this.updateDemand(); for (MerchantOffer offer : this.getOffers()) { @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -437,7 +_,12 @@ +@@ -439,7 +_,12 @@ int missedUpdates = 2 - this.numberOfRestocksToday; if (missedUpdates > 0) { for (MerchantOffer offer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -458,6 +_,7 @@ +@@ -460,6 +_,7 @@ int reputation = this.getPlayerReputation(player); if (reputation != 0) { for (MerchantOffer offer : this.getOffers()) { @@ -45,7 +45,7 @@ offer.addToSpecialPriceDiff(-Mth.floor(reputation * offer.getPriceMultiplier())); } } -@@ -467,6 +_,7 @@ +@@ -469,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer offer : this.getOffers()) { @@ -53,7 +53,7 @@ double modifier = 0.3 + 0.0625 * amplifier; int costReduction = (int)Math.floor(modifier * offer.getBaseCostA().getCount()); offer.addToSpecialPriceDiff(-Math.max(costReduction, 1)); -@@ -582,7 +_,7 @@ +@@ -584,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -600,7 +_,7 @@ +@@ -602,7 +_,7 @@ @Override public void die(final DamageSource source) { @@ -71,7 +71,7 @@ Entity murderer = source.getEntity(); if (murderer != null) { this.tellWitnessesThatIWasMurdered(murderer); -@@ -699,7 +_,7 @@ +@@ -701,7 +_,7 @@ return VillagerData.canLevelUp(currentLevel) && this.villagerXp >= VillagerData.getMaxXpPerLevel(currentLevel); } @@ -80,7 +80,7 @@ this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); this.updateTrades(level); } -@@ -762,12 +_,19 @@ +@@ -764,12 +_,19 @@ @Override public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -102,7 +102,7 @@ if (witch == null) { super.thunderHit(level, lightningBolt); } -@@ -807,15 +_,23 @@ +@@ -809,15 +_,23 @@ @Override protected void updateTrades(final ServerLevel level) { @@ -127,7 +127,7 @@ } public void gossip(final ServerLevel level, final Villager target, final long timestamp) { -@@ -847,7 +_,7 @@ +@@ -849,7 +_,7 @@ .limit(5L) .toList(); if (nearbyVillagersThatWantAGolem.size() >= villagersNeededToAgree) { @@ -136,7 +136,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -856,9 +_,11 @@ +@@ -858,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch index 0c52d50e362a..5258a43a862f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java +++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java -@@ -52,6 +_,10 @@ +@@ -51,6 +_,10 @@ private static final int DEFAULT_DESPAWN_DELAY = 0; private @Nullable BlockPos wanderTarget; private int despawnDelay = 0; @@ -11,7 +11,7 @@ public WanderingTrader(final EntityType type, final Level level) { super(type, level); -@@ -67,14 +_,14 @@ +@@ -66,14 +_,14 @@ this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, @@ -28,7 +28,7 @@ ) ); this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this)); -@@ -159,7 +_,7 @@ +@@ -158,7 +_,7 @@ protected void rewardTradeXp(final MerchantOffer offer) { if (offer.shouldRewardExp()) { int popXp = 3 + this.random.nextInt(4); @@ -37,7 +37,7 @@ } } -@@ -211,7 +_,7 @@ +@@ -210,7 +_,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch index 684f6afb5484..d64989c78893 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch @@ -54,5 +54,5 @@ - float dmg = 8.0F; + float dmg = (float) this.baseDamage; // Paper - Allow trident custom damage Entity currentOwner = this.getOwner(); - DamageSource damageSource = this.damageSources().trident(this, (Entity)(currentOwner == null ? this : currentOwner)); + DamageSource damageSource = this.damageSources().trident(this, currentOwner == null ? this : currentOwner); if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch index ece99bf0170f..ccfbd149040b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java -@@ -65,7 +_,7 @@ +@@ -63,7 +_,7 @@ super.onHit(hitResult); if (!this.level().isClientSide()) { this.level().broadcastEntityEvent(this, EntityEvent.DEATH); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch index fc089bfbd33d..3bb1d81c52d4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch @@ -44,11 +44,11 @@ entity.setAggressive(true); } -@@ -393,6 +_,7 @@ +@@ -390,6 +_,7 @@ } private boolean cannotPickUpBanner() { + if (!getServerLevel(this.mob).getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) return true; // Paper - respect game and entity rules for picking up items if (!this.mob.hasActiveRaid()) { return true; - } else if (this.mob.getCurrentRaid().isOver()) { + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 4ec5f3460b32..ebed84eb4ad1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -59,12 +_,12 @@ +@@ -58,12 +_,12 @@ default void addChestVehicleSaveData(final ValueOutput output) { if (this.getContainerLootTable() != null) { output.putString("LootTable", this.getContainerLootTable().identifier().toString()); @@ -15,7 +15,7 @@ } default void readChestVehicleSaveData(final ValueInput input) { -@@ -72,7 +_,12 @@ +@@ -71,7 +_,12 @@ ResourceKey lootTable = input.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setContainerLootTable(lootTable); this.setContainerLootTableSeed(input.getLongOr("LootTableSeed", 0L)); @@ -29,7 +29,7 @@ ContainerHelper.loadAllItems(input, this.getItemStacks()); } } -@@ -87,19 +_,27 @@ +@@ -86,19 +_,27 @@ } default InteractionResult interactWithContainerVehicle(final Player player) { @@ -60,7 +60,7 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -173,4 +_,14 @@ +@@ -168,4 +_,14 @@ default boolean isChestVehicleStillValid(final Player player) { return !this.isRemoved() && player.isWithinEntityInteractionRange(this.getBoundingBox(), 4.0); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch index aef6bd04c3d5..d540df29e0fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch @@ -84,7 +84,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); this.lastYd = 0.0; } -@@ -704,12 +_,20 @@ +@@ -702,12 +_,20 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch index 67ecbf491eed..cb1830a44de1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch @@ -15,7 +15,7 @@ } @Override -@@ -96,8 +_,8 @@ +@@ -98,8 +_,8 @@ @Override public void openCustomInventoryScreen(final Player player) { @@ -26,16 +26,16 @@ this.gameEvent(GameEvent.CONTAINER_OPEN, player); PiglinAi.angerNearbyPiglins(level, player, true); } -@@ -149,7 +_,7 @@ +@@ -151,7 +_,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { - if (this.lootTable != null && player.isSpectator()) { + if (this.lootTable != null && player.isSpectator()) { // Paper - LootTable API (TODO spectators can open chests that aren't ready to be re-generated but this doesn't support that) return null; - } else { - this.unpackLootTable(inventory.player); -@@ -195,4 +_,58 @@ + } + +@@ -197,4 +_,58 @@ public void stopOpen(final ContainerUser containerUser) { this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(containerUser.getLivingEntity())); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch index b90a4b0a86c3..21c84db1cc3f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java -@@ -88,7 +_,7 @@ +@@ -87,7 +_,7 @@ @Override public InteractionResult interact(final Player player, final InteractionHand hand, final Vec3 location) { - if (!player.canUseGameMasterBlocks()) { + if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission return InteractionResult.PASS; - } else { - if (player.level().isClientSide()) { -@@ -131,7 +_,7 @@ + } + +@@ -125,7 +_,7 @@ MinecartCommandBlock.this.position(), MinecartCommandBlock.this.getRotationVector(), level, @@ -18,7 +18,7 @@ this.getName().getString(), MinecartCommandBlock.this.getDisplayName(), level.getServer(), -@@ -143,5 +_,17 @@ +@@ -137,5 +_,17 @@ public boolean isValid() { return !MinecartCommandBlock.this.isRemoved(); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch index 456040a8a52b..4b86f66a63bd 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractCraftingMenu.java +++ b/net/minecraft/world/inventory/AbstractCraftingMenu.java -@@ -13,14 +_,17 @@ +@@ -12,14 +_,17 @@ public abstract class AbstractCraftingMenu extends RecipeBookMenu { private final int width; private final int height; diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index 67a7de55c2ab..b23652ee19a3 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -35,6 +_,21 @@ +@@ -34,6 +_,21 @@ private final RecipeType recipeType; private final RecipePropertySet acceptedInputs; private final RecipeBookType recipeBookType; @@ -22,7 +22,7 @@ protected AbstractFurnaceMenu( final MenuType menuType, -@@ -69,6 +_,7 @@ +@@ -68,6 +_,7 @@ this.addSlot(new Slot(container, 0, 56, 17)); this.addSlot(new FurnaceFuelSlot(this, container, 1, 56, 53)); this.addSlot(new FurnaceResultSlot(inventory.player, container, 2, 116, 35)); @@ -30,7 +30,7 @@ this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlots(data); } -@@ -86,6 +_,7 @@ +@@ -85,6 +_,7 @@ @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch index 34d8de1b61cd..59b69ac604cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/InventoryMenu.java +++ b/net/minecraft/world/inventory/InventoryMenu.java -@@ -45,9 +_,13 @@ +@@ -44,9 +_,13 @@ private static final EquipmentSlot[] SLOT_IDS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; public final boolean active; private final Player owner; @@ -15,7 +15,7 @@ this.active = active; this.owner = owner; this.addResultSlot(owner, 154, 28); -@@ -193,4 +_,54 @@ +@@ -188,4 +_,54 @@ protected Player owner() { return this.owner; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/DebugStickItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/DebugStickItem.java.patch index 77743d475147..61a37b8ae93b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/DebugStickItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/DebugStickItem.java.patch @@ -7,5 +7,5 @@ - if (!player.canUseGameMasterBlocks()) { + if (!player.canUseGameMasterBlocks() && !(player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.debugstick")) && !player.getBukkitEntity().hasPermission("minecraft.debugstick.always")) { // Spigot return false; - } else { - Holder block = state.typeHolder(); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/EmptyMapItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EmptyMapItem.java.patch index bc25fbb2abdb..de94a65c484b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EmptyMapItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EmptyMapItem.java.patch @@ -16,4 +16,4 @@ + // Paper end - PlayerMapFilledEvent if (itemStack.isEmpty()) { return InteractionResult.SUCCESS.heldItemTransformedTo(map); - } else { + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch index 2d3b87168c1e..835dc089562f 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch @@ -33,7 +33,7 @@ public static TypedEntityData of(final T type, final CompoundTag data) { return new TypedEntityData<>(type, data); } -@@ -182,7 +_,7 @@ +@@ -179,7 +_,7 @@ ) { if (this.type.getClass() == EntityType.class) { EntityType type = (EntityType)this.type; diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch index 95ff41a54c96..08fabd6c26a0 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ConsumeEffect.java.patch @@ -15,5 +15,5 @@ + } + // CraftBukkit end - public record Type(MapCodec codec, StreamCodec streamCodec) { + record Type(MapCodec codec, StreamCodec streamCodec) { public static final ConsumeEffect.Type APPLY_EFFECTS = register( diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch index 688cfaa2d6ef..45d5ff42e209 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -24,7 +24,7 @@ private Ingredient(final HolderSet values) { values.unwrap().ifRight(directValues -> { -@@ -60,6 +_,17 @@ +@@ -62,6 +_,17 @@ @Override public boolean test(final ItemStack input) { @@ -42,7 +42,7 @@ return input.is(this.values); } -@@ -70,7 +_,7 @@ +@@ -72,7 +_,7 @@ @Override public boolean equals(final Object o) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch index 710eb1e8c82e..6613a6b8b455 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -15,4 +15,4 @@ + ItemEnchantments oldEnchantments = createComponentIfMissing ? itemStack.getOrDefault(componentType, ItemEnchantments.EMPTY) : itemStack.get(componentType); // Paper - allowing updating enchantments on items without component if (oldEnchantments == null) { return ItemEnchantments.EMPTY; - } else { + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch index e5eb23c97b83..3d43378d1551 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/EntityGetter.java +++ b/net/minecraft/world/level/EntityGetter.java @@ -71,6 +_,12 @@ - } + return shapes.build(); } + // Paper start - Affects Spawning API diff --git a/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch index fd876791f3b9..bc5ad2f48be8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch @@ -7,7 +7,7 @@ - if (xc >= 0 && xc < this.chunks.length && zc >= 0 && zc < this.chunks[xc].length) { + if (xc >= 0 && xc < this.chunks.length && zc >= 0 && zc < this.chunks[xc].length) { // Paper - if this changes, update getChunkIfLoaded below ChunkAccess chunk = this.chunks[xc][zc]; - return (ChunkAccess)(chunk != null ? chunk : new EmptyLevelChunk(this.level, new ChunkPos(chunkX, chunkZ), this.plains.get())); + return chunk != null ? chunk : new EmptyLevelChunk(this.level, new ChunkPos(chunkX, chunkZ), this.plains.get()); } else { return new EmptyLevelChunk(this.level, new ChunkPos(chunkX, chunkZ), this.plains.get()); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index 4da082778cff..f88ec87b1a39 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -23,8 +23,8 @@ } private ExplosionDamageCalculator makeDamageCalculator(final @Nullable Entity source) { -@@ -141,7 +_,8 @@ - for (float stepSize = 0.3F; remainingPower > 0.0F; remainingPower -= 0.22500001F) { +@@ -142,7 +_,8 @@ + while (remainingPower > 0.0F) { BlockPos pos = BlockPos.containing(xp, yp, zp); BlockState block = this.level.getBlockState(pos); - FluidState fluid = this.level.getFluidState(pos); @@ -33,7 +33,7 @@ if (!this.level.isInWorldBounds(pos)) { break; } -@@ -153,6 +_,15 @@ +@@ -154,6 +_,15 @@ if (remainingPower > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { toBlowSet.add(pos); @@ -49,7 +49,7 @@ } xp += xd * 0.3F; -@@ -176,8 +_,9 @@ +@@ -178,8 +_,9 @@ int y1 = Mth.floor(this.center.y + doubleRadius + 1.0); int z0 = Mth.floor(this.center.z - doubleRadius - 1.0); int z1 = Mth.floor(this.center.z + doubleRadius + 1.0); @@ -60,7 +60,7 @@ if (!entity.ignoreExplosion(this)) { double dist = Math.sqrt(entity.distanceToSqr(this.center)) / doubleRadius; if (!(dist > 1.0)) { -@@ -185,20 +_,56 @@ +@@ -187,20 +_,56 @@ Vec3 direction = entityOrigin.subtract(this.center).normalize(); boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); @@ -121,7 +121,7 @@ this.hitPlayers.put(player, knockback); } -@@ -213,7 +_,56 @@ +@@ -215,7 +_,56 @@ List stacks = new ArrayList<>(); Util.shuffle(targetBlocks, this.level.random); @@ -178,7 +178,7 @@ this.level.getBlockState(pos).onExplosionHit(this.level, pos, this, (stackx, position) -> addOrAppendStack(stacks, stackx, position)); } -@@ -225,7 +_,11 @@ +@@ -227,7 +_,11 @@ private void createFire(final List targetBlocks) { for (BlockPos pos : targetBlocks) { if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(pos).isAir() && this.level.getBlockState(pos.below()).isSolidRender()) { @@ -191,7 +191,7 @@ } } } -@@ -323,4 +_,85 @@ +@@ -325,4 +_,85 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch index 0687c68c610e..d040e7fcec70 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch @@ -9,7 +9,7 @@ } public int getTicketLevelAt(final long key, final boolean simulation) { -@@ -300,7 +_,7 @@ +@@ -302,7 +_,7 @@ } public void deactivateTicketsOnClosing() { @@ -18,7 +18,7 @@ } public void removeTicketIf(final TicketStorage.TicketPredicate predicate, final @Nullable Long2ObjectOpenHashMap> removedTickets) { -@@ -410,4 +_,20 @@ +@@ -412,4 +_,20 @@ public interface TicketPredicate { boolean test(Ticket ticket, long chunkPos); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch index 051186dfaaaf..7586d87f1eff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -63,8 +63,8 @@ @Override @@ -219,4 +_,12 @@ - } - } + : Direction.Plane.HORIZONTAL.getRandomAxis(level.getRandom()); + return PortalShape.findEmptyPortalShape(level, pos, preferredAxis).isPresent(); } + + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index c2808c1ed09f..36289740b667 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch @@ -65,7 +65,7 @@ private @Nullable Item item; private static final int CACHE_SIZE = 256; private static final ThreadLocal> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { -@@ -382,6 +_,27 @@ +@@ -386,6 +_,27 @@ return state.getDrops(params); } @@ -93,7 +93,7 @@ public static void dropResources(final BlockState state, final Level level, final BlockPos pos) { if (level instanceof ServerLevel serverLevel) { getDrops(state, serverLevel, pos, null).forEach(stack -> popResource(level, pos, stack)); -@@ -396,6 +_,12 @@ +@@ -400,6 +_,12 @@ } } @@ -106,7 +106,7 @@ public static void dropResources( final BlockState state, final Level level, -@@ -403,10 +_,11 @@ +@@ -407,10 +_,11 @@ final @Nullable BlockEntity blockEntity, final @Nullable Entity breaker, final ItemStack tool @@ -119,7 +119,7 @@ } } -@@ -439,13 +_,25 @@ +@@ -443,13 +_,25 @@ if (level instanceof ServerLevel serverLevel && !itemStack.isEmpty() && serverLevel.getGameRules().get(GameRules.BLOCK_DROPS)) { ItemEntity entity = entityFactory.get(); entity.setDefaultPickUpDelay(); @@ -147,7 +147,7 @@ } } -@@ -463,6 +_,13 @@ +@@ -467,6 +_,13 @@ return this.defaultBlockState(); } @@ -161,7 +161,7 @@ public void playerDestroy( final Level level, final Player player, -@@ -470,10 +_,13 @@ +@@ -474,10 +_,13 @@ final BlockState state, final @Nullable BlockEntity blockEntity, final ItemStack destroyedWith @@ -177,7 +177,7 @@ } public void setPlacedBy(final Level level, final BlockPos pos, final BlockState state, final @Nullable LivingEntity by, final ItemStack itemStack) { -@@ -613,12 +_,20 @@ +@@ -617,12 +_,20 @@ return this.builtInRegistryHolder; } @@ -201,7 +201,7 @@ private record ShapePairKey(VoxelShape first, VoxelShape second) { @Override -@@ -634,6 +_,7 @@ +@@ -638,6 +_,7 @@ @Retention(RetentionPolicy.CLASS) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CopperBulbBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CopperBulbBlock.java.patch index 7f84dabc8180..48ae25be7fc2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CopperBulbBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CopperBulbBlock.java.patch @@ -11,4 +11,4 @@ + // Paper end - Call BlockRedstoneEvent BlockState newState = state; if (!state.getValue(POWERED)) { - newState = state.cycle(LIT); + newState = newState.cycle(LIT); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch index a87d4990b3e9..b826df878d41 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch @@ -40,7 +40,7 @@ level.setBlock(pos, state.setValue(POWERED, isPowered), Block.UPDATE_ALL); updateBelow(level, pos, state); } -@@ -258,8 +_,7 @@ +@@ -256,8 +_,7 @@ private void openScreen(final Level level, final BlockPos pos, final Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch index cb37ea773907..e9574c2450a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MultifaceSpreader.java +++ b/net/minecraft/world/level/block/MultifaceSpreader.java -@@ -176,14 +_,14 @@ +@@ -178,14 +_,14 @@ level.getChunk(spreadPos.pos()).markPosForPostprocessing(spreadPos.pos()); } @@ -17,7 +17,7 @@ } @FunctionalInterface -@@ -195,19 +_,19 @@ +@@ -197,19 +_,19 @@ SAME_POSITION { @Override public MultifaceSpreader.SpreadPos getSpreadPos(final BlockPos pos, final Direction spreadDirection, final Direction fromFace) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 84d75864eb4d..5fc931aaec80 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -144,6 +_,11 @@ +@@ -146,6 +_,11 @@ && projectile.mayBreak(serverLevel) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6) { @@ -12,7 +12,7 @@ level.destroyBlock(blockPos, true); } } -@@ -152,7 +_,7 @@ +@@ -154,7 +_,7 @@ @Override public void fallOn(final Level level, final BlockState state, final BlockPos pos, final Entity entity, final double fallDistance) { if (state.getValue(TIP_DIRECTION) == Direction.UP && state.getValue(THICKNESS) == DripstoneThickness.TIP) { @@ -21,7 +21,7 @@ } else { super.fallOn(level, state, pos, entity, fallDistance); } -@@ -210,10 +_,11 @@ +@@ -212,10 +_,11 @@ if (stalactiteTipPos != null) { if (fluidInfo.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { BlockState newState = Blocks.CLAY.defaultBlockState(); @@ -34,7 +34,7 @@ } else { BlockPos cauldronPos = findFillableCauldronBelowStalactiteTip(level, stalactiteTipPos, fluid); if (cauldronPos != null) { -@@ -359,17 +_,17 @@ +@@ -361,17 +_,17 @@ if (isUnmergedTipWithDirection(existingStateAtTargetPos, growToDirection.getOpposite())) { createMergedTips(existingStateAtTargetPos, level, targetPos); } else if (existingStateAtTargetPos.isAir() || existingStateAtTargetPos.is(Blocks.WATER)) { @@ -55,7 +55,7 @@ } private static void createMergedTips(final BlockState tipState, final LevelAccessor level, final BlockPos tipPos) { -@@ -383,8 +_,8 @@ +@@ -385,8 +_,8 @@ stalagmitePos = tipPos.below(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 05f413e5026e..9cd98f8eb36f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PoweredRailBlock.java +++ b/net/minecraft/world/level/block/PoweredRailBlock.java -@@ -127,6 +_,11 @@ +@@ -121,6 +_,11 @@ || this.findPoweredRailSignal(level, pos, state, true, 0) || this.findPoweredRailSignal(level, pos, state, false, 0); if (shouldPower != isPowered) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch index c5e80cae49a3..25212078a789 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch @@ -13,7 +13,7 @@ public RailState(final Level level, final BlockPos pos, final BlockState state) { this.level = level; this.pos = pos; -@@ -140,6 +_,11 @@ +@@ -141,6 +_,11 @@ } private void connectTo(final RailState rail) { @@ -25,7 +25,7 @@ this.connections.add(rail.pos); BlockPos north = this.pos.north(); BlockPos south = this.pos.south(); -@@ -330,10 +_,15 @@ +@@ -331,10 +_,15 @@ this.state = this.state.setValue(this.block.getShapeProperty(), shape); if (first || this.level.getBlockState(this.pos) != this.state) { this.level.setBlock(this.pos, this.state, Block.UPDATE_ALL); @@ -42,7 +42,7 @@ neighbor.removeSoftConnections(); if (neighbor.canConnectTo(this)) { neighbor.connectTo(this); -@@ -346,6 +_,6 @@ +@@ -347,6 +_,6 @@ } public BlockState getState() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch index 674f031b2fca..f875da9113c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -37,9 +37,9 @@ + interact(state, level, pos, player); // CraftBukkit - add player } - return (InteractionResult)(itemStack.getItem() instanceof BlockItem && new BlockPlaceContext(player, hand, itemStack, hitResult).canPlace() + return itemStack.getItem() instanceof BlockItem && new BlockPlaceContext(player, hand, itemStack, hitResult).canPlace() @@ -71,9 +_,14 @@ - : InteractionResult.SUCCESS); + : InteractionResult.SUCCESS; } - private static void interact(final BlockState state, final Level level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch index 47ecdbed28b0..240f6670469a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkVeinBlock.java +++ b/net/minecraft/world/level/block/SculkVeinBlock.java -@@ -96,14 +_,14 @@ +@@ -95,14 +_,14 @@ final SculkSpreader spreader, final boolean spreadVeins ) { @@ -17,7 +17,7 @@ BlockState state = level.getBlockState(pos); TagKey replaceTag = spreader.replaceableBlocks(); -@@ -113,7 +_,11 @@ +@@ -112,7 +_,11 @@ BlockState supportState = level.getBlockState(supportPos); if (supportState.is(replaceTag)) { BlockState defaultSculk = Blocks.SCULK.defaultBlockState(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyBlock.java.patch index 1390b4a5cede..59d1d57ee655 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpreadingSnowyBlock.java +++ b/net/minecraft/world/level/block/SpreadingSnowyBlock.java -@@ -46,10 +_,16 @@ +@@ -48,10 +_,16 @@ @Override protected void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) { @@ -17,7 +17,7 @@ level.setBlockAndUpdate(pos, baseBlock.get().defaultBlockState()); } else { if (level.getMaxLocalRawBrightness(pos.above()) >= 9) { -@@ -58,7 +_,7 @@ +@@ -60,7 +_,7 @@ for (int i = 0; i < 4; i++) { BlockPos testPos = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); if (level.getBlockState(testPos).is(baseBlock.get()) && canPropagate(defaultBlockState, level, testPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index ff448a23dfea..f218455abdfa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -29,7 +29,7 @@ } } } -@@ -125,6 +_,7 @@ +@@ -123,6 +_,7 @@ ) { if (state.getValue(AGE) > 1) { if (level instanceof ServerLevel serverLevel) { @@ -37,7 +37,7 @@ Block.dropFromBlockInteractLootTable( serverLevel, BuiltInLootTables.HARVEST_SWEET_BERRY_BUSH, -@@ -132,8 +_,17 @@ +@@ -130,8 +_,17 @@ level.getBlockEntity(pos), null, player, diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch index 104fc06cc92d..929b8a555a62 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/VineBlock.java +++ b/net/minecraft/world/level/block/VineBlock.java -@@ -166,7 +_,7 @@ +@@ -168,7 +_,7 @@ @Override protected void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) { if (level.getGameRules().get(GameRules.SPREAD_VINES)) { @@ -9,7 +9,7 @@ Direction testDirection = Direction.getRandom(random); BlockPos abovePos = pos.above(); if (testDirection.getAxis().isHorizontal() && !state.getValue(getPropertyForFace(testDirection))) { -@@ -180,30 +_,33 @@ +@@ -182,30 +_,33 @@ boolean ccwHasConnectingFace = state.getValue(getPropertyForFace(ccwDirection)); BlockPos cwTestPos = testPos.relative(cwDirection); BlockPos ccwTestPos = testPos.relative(ccwDirection); @@ -50,7 +50,7 @@ return; } -@@ -221,7 +_,7 @@ +@@ -223,7 +_,7 @@ } if (this.hasHorizontalConnection(aboveState)) { @@ -59,7 +59,7 @@ } return; -@@ -235,7 +_,7 @@ +@@ -237,7 +_,7 @@ BlockState before = belowState.isAir() ? this.defaultBlockState() : belowState; BlockState after = this.copyRandomFaces(state, before, random); if (before != after && this.hasHorizontalConnection(after)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 6157f3afddab..d0b8a8ffef3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -109,13 +_,51 @@ +@@ -104,13 +_,51 @@ }; public final Reference2IntOpenHashMap>> recipesUsed = new Reference2IntOpenHashMap<>(); private final RecipeManager.CachedCheck quickCheck; @@ -53,7 +53,7 @@ @Override protected void loadAdditional(final ValueInput input) { -@@ -128,6 +_,7 @@ +@@ -123,6 +_,7 @@ this.litTotalTime = input.getShortOr("lit_total_time", (short)0); this.recipesUsed.clear(); this.recipesUsed.putAll(input.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of())); @@ -61,7 +61,7 @@ } @Override -@@ -137,6 +_,7 @@ +@@ -132,6 +_,7 @@ output.putShort("cooking_total_time", (short)this.cookingTotalTime); output.putShort("lit_time_remaining", (short)this.litTimeRemaining); output.putShort("lit_total_time", (short)this.litTotalTime); @@ -69,7 +69,7 @@ ContainerHelper.saveAllItems(output, this.items); output.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed); } -@@ -166,24 +_,48 @@ +@@ -161,24 +_,48 @@ int maxStackSize = entity.getMaxStackSize(); ItemStack burnResult = recipe.value().assemble(input); if (!burnResult.isEmpty() && canBurn(entity.items, maxStackSize, burnResult)) { @@ -123,8 +123,8 @@ changed = true; } } else { -@@ -233,28 +_,63 @@ - } +@@ -230,28 +_,63 @@ + return resultCount <= maxResultCount; } - private static void burn(final NonNullList items, final ItemStack inputItemStack, final ItemStack result) { @@ -190,7 +190,7 @@ } @Override -@@ -298,7 +_,7 @@ +@@ -295,7 +_,7 @@ this.items.set(slot, itemStack); itemStack.limitSize(this.getMaxStackSize(itemStack)); if (slot == 0 && !same && this.level instanceof ServerLevel serverLevel) { @@ -199,7 +199,7 @@ this.cookingTimer = 0; this.setChanged(); } -@@ -333,8 +_,8 @@ +@@ -332,8 +_,8 @@ public void awardUsedRecipes(final Player player, final List itemStacks) { } @@ -210,7 +210,7 @@ player.awardRecipes(recipesToAward); for (RecipeHolder recipe : recipesToAward) { -@@ -345,30 +_,60 @@ +@@ -344,30 +_,60 @@ } public List> getRecipesToAwardAndPopExperience(final ServerLevel level, final Vec3 position) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch index c0cf3395c308..262672ce2551 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -25,6 +_,40 @@ +@@ -24,6 +_,40 @@ import net.minecraft.world.level.storage.ValueOutput; public class BarrelBlockEntity extends RandomizableContainerBlockEntity { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index e15d7d61fc34..2a9b6fa87339 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -111,6 +_,51 @@ +@@ -107,6 +_,51 @@ return 3; } }; @@ -52,7 +52,7 @@ private static @Nullable Holder filterEffect(final @Nullable Holder effect) { return VALID_EFFECTS.contains(effect) ? effect : null; -@@ -174,10 +_,19 @@ +@@ -170,10 +_,19 @@ } if (entity.levels > 0 && !entity.beamSections.isEmpty()) { @@ -73,7 +73,7 @@ if (entity.lastCheckY >= lastSetBlock) { entity.lastCheckY = level.getMinY() - 1; -@@ -228,7 +_,15 @@ +@@ -224,7 +_,15 @@ @Override public void setRemoved() { @@ -89,7 +89,7 @@ super.setRemoved(); } -@@ -238,29 +_,78 @@ +@@ -234,29 +_,78 @@ final int levels, final @Nullable Holder primaryPower, final @Nullable Holder secondaryPower @@ -186,7 +186,7 @@ public static void playSound(final Level level, final BlockPos worldPosition, final SoundEvent event) { level.playSound(null, worldPosition, event, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -288,7 +_,7 @@ +@@ -284,7 +_,7 @@ } private static @Nullable Holder loadEffect(final ValueInput input, final String field) { @@ -195,7 +195,7 @@ } @Override -@@ -296,8 +_,10 @@ +@@ -292,8 +_,10 @@ super.loadAdditional(input); this.primaryPower = loadEffect(input, "primary_effect"); this.secondaryPower = loadEffect(input, "secondary_effect"); @@ -206,7 +206,7 @@ } @Override -@@ -308,6 +_,7 @@ +@@ -304,6 +_,7 @@ output.putInt("Levels", this.levels); output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name); this.lockKey.addToTag(output); @@ -214,12 +214,12 @@ } public void setCustomName(final @Nullable Component name) { -@@ -321,7 +_,7 @@ +@@ -317,7 +_,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { - if (this.lockKey.canUnlock(player)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player)) { // Paper - Call BlockLockCheckEvent return new BeaconMenu(containerId, inventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())); - } else { - BaseContainerBlockEntity.sendChestLockedNotifications(this.getBlockPos().getCenter(), player, this.getDisplayName()); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch index 1d32cbf29e53..f2535a9d05e5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -40,6 +_,10 @@ +@@ -39,6 +_,10 @@ import org.slf4j.Logger; public abstract class BlockEntity implements DebugValueSource, TypedInstance> { @@ -11,7 +11,7 @@ private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; -@@ -54,6 +_,7 @@ +@@ -53,6 +_,7 @@ this.worldPosition = worldPosition.immutable(); this.validateBlockState(blockState); this.blockState = blockState; @@ -19,7 +19,7 @@ } private void validateBlockState(final BlockState blockState) { -@@ -66,10 +_,11 @@ +@@ -65,10 +_,11 @@ return this.type.isValid(blockState); } @@ -32,7 +32,7 @@ int sectionX = SectionPos.blockToSectionCoord(x); int sectionZ = SectionPos.blockToSectionCoord(z); if (sectionX != base.x() || sectionZ != base.z()) { -@@ -77,6 +_,7 @@ +@@ -76,6 +_,7 @@ x = base.getBlockX(SectionPos.sectionRelative(x)); z = base.getBlockZ(SectionPos.sectionRelative(z)); } @@ -40,7 +40,7 @@ return new BlockPos(x, y, z); } -@@ -94,6 +_,12 @@ +@@ -93,6 +_,12 @@ } protected void loadAdditional(final ValueInput input) { @@ -53,7 +53,7 @@ } public final void loadWithComponents(final ValueInput input) { -@@ -143,6 +_,11 @@ +@@ -136,6 +_,11 @@ public void saveWithoutMetadata(final ValueOutput output) { this.saveAdditional(output); output.store("components", DataComponentMap.CODEC, this.components); @@ -65,7 +65,7 @@ } public final CompoundTag saveCustomOnly(final HolderLookup.Provider registries) { -@@ -158,6 +_,11 @@ +@@ -148,6 +_,11 @@ public void saveCustomOnly(final ValueOutput output) { this.saveAdditional(output); @@ -77,7 +77,7 @@ } public void saveId(final ValueOutput output) { -@@ -293,6 +_,12 @@ +@@ -278,6 +_,12 @@ } public final void applyComponents(final DataComponentMap prototype, final DataComponentPatch patch) { @@ -90,7 +90,7 @@ final Set> implicitComponents = new HashSet<>(); implicitComponents.add(DataComponents.BLOCK_ENTITY_DATA); implicitComponents.add(DataComponents.BLOCK_STATE); -@@ -316,6 +_,10 @@ +@@ -297,6 +_,10 @@ }); DataComponentPatch newPatch = patch.forget(implicitComponents::contains); this.components = newPatch.split().added(); @@ -101,7 +101,7 @@ } protected void collectImplicitComponents(final DataComponentMap.Builder components) { -@@ -351,6 +_,27 @@ +@@ -332,6 +_,27 @@ @Override public void registerDebugValues(final ServerLevel level, final DebugValueSource.Registration registration) { } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index 266d51acd6f3..dfa24016506b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -43,6 +_,7 @@ +@@ -42,6 +_,7 @@ private static final Component DEFAULT_NAME = Component.translatable("container.brewing"); private NonNullList items = NonNullList.withSize(5, ItemStack.EMPTY); public int brewTime; @@ -8,7 +8,7 @@ private boolean[] lastPotionCount; private Item ingredient; public int fuel; -@@ -56,6 +_,7 @@ +@@ -51,6 +_,7 @@ return switch (dataId) { case 0 -> BrewingStandBlockEntity.this.brewTime; case 1 -> BrewingStandBlockEntity.this.fuel; @@ -16,7 +16,7 @@ default -> 0; }; } -@@ -68,14 +_,54 @@ +@@ -63,14 +_,54 @@ break; case 1: BrewingStandBlockEntity.this.fuel = value; @@ -72,7 +72,7 @@ public BrewingStandBlockEntity(final BlockPos worldPosition, final BlockState blockState) { super(BlockEntityType.BREWING_STAND, worldPosition, blockState); -@@ -104,8 +_,21 @@ +@@ -99,8 +_,21 @@ public static void serverTick(final Level level, final BlockPos pos, final BlockState selfState, final BrewingStandBlockEntity entity) { ItemStack fuel = entity.items.get(4); if (entity.fuel <= 0 && fuel.is(ItemTags.BREWING_FUEL)) { @@ -96,7 +96,7 @@ setChanged(level, pos, selfState); } -@@ -116,7 +_,7 @@ +@@ -111,7 +_,7 @@ entity.brewTime--; boolean isDoneBrewing = entity.brewTime == 0; if (isDoneBrewing && brewable) { @@ -105,7 +105,7 @@ } else if (!brewable || !ingredient.is(entity.ingredient)) { entity.brewTime = 0; } -@@ -124,7 +_,14 @@ +@@ -119,7 +_,14 @@ setChanged(level, pos, selfState); } else if (brewable && entity.fuel > 0) { entity.fuel--; @@ -121,8 +121,8 @@ entity.ingredient = ingredient.getItem(); setChanged(level, pos, selfState); } -@@ -175,13 +_,37 @@ - } +@@ -172,13 +_,37 @@ + return false; } - private static void doBrew(final Level level, final BlockPos pos, final NonNullList items) { @@ -162,7 +162,7 @@ ingredient.shrink(1); ItemStackTemplate remainder = ingredient.getItem().getCraftingRemainder(); -@@ -220,13 +_,13 @@ +@@ -217,13 +_,13 @@ @Override public boolean canPlaceItem(final int slot, final ItemStack itemStack) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java.patch index 991f89beb316..f478236fe4c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CalibratedSculkSensorBlockEntity.java -@@ -21,6 +_,12 @@ +@@ -20,6 +_,12 @@ public VibrationSystem.User createVibrationUser() { return new CalibratedSculkSensorBlockEntity.VibrationUser(this.getBlockPos()); } @@ -13,7 +13,7 @@ protected class VibrationUser extends SculkSensorBlockEntity.VibrationUser { public VibrationUser(final BlockPos blockPos) { -@@ -30,6 +_,7 @@ +@@ -28,6 +_,7 @@ @Override public int getListenerRadius() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch index b22ba8ff3bdf..b690fe965c48 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch @@ -84,7 +84,7 @@ } @Override -@@ -179,7 +_,15 @@ +@@ -176,7 +_,15 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch index 5a386c38181c..e5c42fe9bcde 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -67,6 +_,40 @@ +@@ -62,6 +_,40 @@ }; private final ChestLidController chestLidController = new ChestLidController(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index f10559537eed..9b2488d45631 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -164,8 +_,20 @@ +@@ -165,8 +_,20 @@ } private static void applyEffects(final Level level, final BlockPos worldPosition, final List effectBlocks) { @@ -21,7 +21,7 @@ int x = worldPosition.getX(); int y = worldPosition.getY(); int z = worldPosition.getZ(); -@@ -174,7 +_,7 @@ +@@ -175,7 +_,7 @@ if (!players.isEmpty()) { for (Player player : players) { if (worldPosition.closerThan(player.blockPosition(), effectRange) && player.isInWaterOrRain()) { @@ -30,7 +30,7 @@ } } } -@@ -183,13 +_,19 @@ +@@ -184,13 +_,19 @@ private static void updateAndAttackTarget( final ServerLevel level, final BlockPos worldPosition, final BlockState blockState, final ConduitBlockEntity entity, final boolean isActive ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch index a312097f3c11..bc4d881c4e5c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -@@ -67,6 +_,47 @@ +@@ -60,6 +_,47 @@ } }; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch index cbe5a9a1731f..e8611b4ad6e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java -@@ -22,6 +_,7 @@ +@@ -21,6 +_,7 @@ private final VibrationSystem.Listener vibrationListener; private final VibrationSystem.User vibrationUser; public int lastVibrationFrequency = 0; @@ -8,7 +8,7 @@ protected SculkSensorBlockEntity(final BlockEntityType type, final BlockPos worldPosition, final BlockState blockState) { super(type, worldPosition, blockState); -@@ -43,14 +_,22 @@ +@@ -42,14 +_,22 @@ super.loadAdditional(input); this.lastVibrationFrequency = input.getIntOr("last_vibration_frequency", 0); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -32,7 +32,7 @@ @Override public VibrationSystem.Data getVibrationData() { -@@ -89,6 +_,7 @@ +@@ -86,6 +_,7 @@ @Override public int getListenerRadius() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch index 8bdd7e75a099..c208f2289dd0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -89,6 +_,13 @@ +@@ -88,6 +_,13 @@ } public static @Nullable ServerPlayer tryGetPlayer(final @Nullable Entity sourceEntity) { @@ -14,7 +14,7 @@ if (sourceEntity instanceof ServerPlayer player) { return player; } else if (sourceEntity != null && sourceEntity.getControllingPassenger() instanceof ServerPlayer player) { -@@ -165,7 +_,7 @@ +@@ -164,7 +_,7 @@ private boolean trySummonWarden(final ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index 97ff70e7bc79..5be334619020 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -219,7 +_,14 @@ +@@ -218,7 +_,14 @@ nextSpawnData.getEquipment().ifPresent(mob::equip); } @@ -16,7 +16,7 @@ return Optional.empty(); } -@@ -238,6 +_,20 @@ +@@ -235,6 +_,20 @@ LootParams params = new LootParams.Builder(level).create(LootContextParamSets.EMPTY); ObjectArrayList lootDrops = lootTable.getRandomItems(params); if (!lootDrops.isEmpty()) { @@ -37,7 +37,7 @@ for (ItemStack item : lootDrops) { DefaultDispenseItemBehavior.spawnItem(level, item, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2)); } -@@ -401,6 +_,35 @@ +@@ -398,6 +_,35 @@ this.requiredPlayerRange ); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch index 923e9d99c960..b03601bd1c54 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch @@ -24,7 +24,7 @@ public long stateUpdatingResumesAt() { @@ -127,4 +_,15 @@ public float ejectionProgress() { - return this.totalEjectionsNeeded == 1 ? 1.0F : 1.0F - Mth.inverseLerp((float)this.getItemsToEject().size(), 1.0F, (float)this.totalEjectionsNeeded); + return this.totalEjectionsNeeded == 1 ? 1.0F : 1.0F - Mth.inverseLerp(this.getItemsToEject().size(), 1.0F, this.totalEjectionsNeeded); } + + // Paper start - Vault API diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index ac55e4ac835f..a7ddf93cc18d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -62,8 +62,8 @@ private boolean calculateSolid() { if (this.owner.properties.forceSolidOn) { -@@ -503,12 +_,14 @@ - } +@@ -507,12 +_,14 @@ + return bounds.getSize() >= 0.7291666666666666 || bounds.getYsize() >= 1.0; } + protected boolean shapeExceedsCube = true; // Paper - moved from actual method to here @@ -77,7 +77,7 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? this.owner.getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -548,6 +_,11 @@ +@@ -552,6 +_,11 @@ public boolean isSolid() { return this.legacySolid; } @@ -89,7 +89,7 @@ public boolean isValidSpawn(final BlockGetter level, final BlockPos pos, final EntityType type) { return this.getBlock().properties.isValidSpawn.test(this.asState(), level, pos, type); -@@ -569,19 +_,19 @@ +@@ -573,19 +_,19 @@ return this.occlusionShape; } @@ -114,7 +114,7 @@ return this.isAir; } -@@ -595,7 +_,7 @@ +@@ -599,7 +_,7 @@ } public MapColor getMapColor(final BlockGetter level, final BlockPos pos) { @@ -123,7 +123,7 @@ } public BlockState rotate(final Rotation rotation) { -@@ -651,14 +_,14 @@ +@@ -655,14 +_,14 @@ } public PushReaction getPistonPushReaction() { @@ -140,7 +140,7 @@ return this.canOcclude; } -@@ -749,7 +_,13 @@ +@@ -753,7 +_,13 @@ } public void onPlace(final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) { @@ -155,7 +155,7 @@ } public void affectNeighborsAfterRemoval(final ServerLevel level, final BlockPos pos, final boolean movedByPiston) { -@@ -776,6 +_,7 @@ +@@ -780,6 +_,7 @@ public void spawnAfterBreak(final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) { this.getBlock().spawnAfterBreak(this.asState(), level, pos, tool, dropExperience); @@ -163,7 +163,7 @@ } public List getDrops(final LootParams.Builder params) { -@@ -860,11 +_,11 @@ +@@ -864,11 +_,11 @@ return this.getBlock() instanceof EntityBlock ? ((EntityBlock)this.getBlock()).getTicker(level, this.asState(), type) : null; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/StateHolder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/StateHolder.java.patch index 7770ed3eef7b..49ecb7933a4f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/StateHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/StateHolder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/StateHolder.java +++ b/net/minecraft/world/level/block/state/StateHolder.java -@@ -142,7 +_,7 @@ +@@ -141,7 +_,7 @@ return length == 0 ? Stream.empty() : IntStream.range(0, length).mapToObj(i -> createValue(this.propertyKeys[i], this.propertyValues[i])); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch index 93d336613a43..7265148334e7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/IntegerProperty.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/properties/IntegerProperty.java +++ b/net/minecraft/world/level/block/state/properties/IntegerProperty.java -@@ -28,8 +_,7 @@ +@@ -30,8 +_,7 @@ return this.values; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 5d3e1faf88bf..9ee8636b937d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -15,12 +_,12 @@ +@@ -14,12 +_,12 @@ public static final int SECTION_HEIGHT = 16; public static final int SECTION_SIZE = 4096; public static final int BIOME_CONTAINER_BITS = 2; @@ -15,7 +15,7 @@ private LevelChunkSection(final LevelChunkSection source) { this.nonEmptyBlockCount = source.nonEmptyBlockCount; -@@ -31,7 +_,7 @@ +@@ -30,7 +_,7 @@ this.biomes = source.biomes.copy(); } @@ -24,7 +24,7 @@ this.states = states; this.biomes = biomes; this.recalcBlockCounts(); -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ } public FluidState getFluidState(final int sectionX, final int sectionY, final int sectionZ) { @@ -33,7 +33,7 @@ } public void acquire() { -@@ -203,6 +_,12 @@ +@@ -197,6 +_,12 @@ public Holder getNoiseBiome(final int quartX, final int quartY, final int quartZ) { return this.biomes.get(quartX, quartY, quartZ); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/PalettedContainer.java.patch index 072c43a99a1a..44cc80cd256d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -35,8 +35,8 @@ + public synchronized T getAndSet(final int x, final int y, final int z, final T value) { // Paper - synchronize this.acquire(); - Object var5; -@@ -125,7 +_,7 @@ + try { +@@ -122,7 +_,7 @@ return this.data.palette.valueFor(oldId); } @@ -45,7 +45,7 @@ this.acquire(); try { -@@ -158,7 +_,7 @@ +@@ -155,7 +_,7 @@ allExistingEntries.forEach(state -> consumer.accept(palette.valueFor(state))); } @@ -54,7 +54,7 @@ this.acquire(); try { -@@ -173,7 +_,7 @@ +@@ -170,7 +_,7 @@ } @Override @@ -63,7 +63,7 @@ this.acquire(); try { -@@ -227,7 +_,7 @@ +@@ -224,7 +_,7 @@ } @Override @@ -71,4 +71,4 @@ + public synchronized PalettedContainerRO.PackedData pack(final Strategy strategy) { // Paper - synchronize this.acquire(); - PalettedContainerRO.PackedData var14; + try { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch index fa848bf4d8da..d5b22b6c9239 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch @@ -80,7 +80,7 @@ + boolean shouldGenerate(long seed, final int salt, final int sourceX, final int sourceZ, float probability, final @org.jspecify.annotations.Nullable Integer saltOverride); // Paper - Add missing structure set seed configs } - public static enum FrequencyReductionMethod implements StringRepresentable { + public enum FrequencyReductionMethod implements StringRepresentable { @@ -167,8 +_,8 @@ this.reducer = reducer; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java.patch index c687c69a4d8c..087141d8c5ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java -@@ -410,7 +_,10 @@ +@@ -411,7 +_,10 @@ if (markerId.startsWith("Chest")) { BlockPos chestPosition = position.below(); if (chunkBB.isInside(chestPosition)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch index 07f0395eff24..67381ccb62dc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -427,10 +_,13 @@ +@@ -429,10 +_,13 @@ BlockPos pos = this.getWorldPos(1, 0, newZ); if (chunkBB.isInside(pos) && this.isInterior(level, 1, 0, newZ, chunkBB)) { this.hasPlacedSpider = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch index 0b5accdd428d..760e4631e435 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -1194,10 +_,13 @@ +@@ -1174,10 +_,13 @@ BlockPos pos = this.getWorldPos(3, 5, 5); if (chunkBB.isInside(pos)) { this.hasPlacedSpawner = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch index 0c701f0b2de2..5c5114538c68 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java -@@ -898,10 +_,13 @@ +@@ -900,10 +_,13 @@ BlockPos pos = this.getWorldPos(5, 3, 6); if (chunkBB.isInside(pos)) { this.hasPlacedSpawner = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index 14d2fd86288a..599a7aee8a91 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -504,7 +_,12 @@ +@@ -514,7 +_,12 @@ } protected static PathType getPathTypeFromState(final BlockGetter level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch index 0a014f3cb6c1..418f1511929b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch @@ -119,7 +119,7 @@ this.bannerMarkers.put(banner.getId(), banner); this.addDecoration(banner.getDecoration(), level, banner.getId(), xPos, zPos, 180.0, banner.name().orElse(null)); this.setDirty(); -@@ -524,7 +_,7 @@ +@@ -518,7 +_,7 @@ this.player = player; } @@ -128,7 +128,7 @@ int startX = this.minDirtyX; int startY = this.minDirtyY; int width = this.maxDirtyX + 1 - this.minDirtyX; -@@ -533,7 +_,7 @@ +@@ -527,7 +_,7 @@ for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { @@ -137,7 +137,7 @@ } } -@@ -542,17 +_,38 @@ +@@ -536,17 +_,38 @@ private @Nullable Packet nextUpdatePacket(final MapId id) { MapItemSavedData.MapPatch patch; @@ -179,7 +179,7 @@ } else { decorations = null; } -@@ -580,6 +_,23 @@ +@@ -574,6 +_,23 @@ private void markDecorationsDirty() { this.dirtyDecorations = true; } @@ -203,7 +203,7 @@ } private record MapDecorationLocation(Holder type, byte x, byte y, byte rot) { -@@ -624,4 +_,71 @@ +@@ -618,4 +_,71 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index 0cf05db6e101..ef7802d8b004 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -74,4 +74,4 @@ + // CraftBukkit end @Deprecated - public static enum SpecialWorldProperty { + public enum SpecialWorldProperty { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java.patch index 6124d48cb417..af31b0db81a6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java +++ b/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java -@@ -39,6 +_,10 @@ +@@ -34,6 +_,10 @@ ); } }; @@ -11,8 +11,8 @@ protected LootPoolSingletonContainer(final int weight, final int quality, final List conditions, final List functions) { super(conditions); -@@ -135,7 +_,31 @@ - +@@ -125,7 +_,31 @@ + protected abstract class EntryBase implements LootPoolEntry { @Override public int getWeight(final float luck) { - return Math.max(Mth.floor(LootPoolSingletonContainer.this.weight + LootPoolSingletonContainer.this.quality * luck), 0); diff --git a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch index e6118569b330..f2793f732a9b 100644 --- a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/scores/Scoreboard.java +++ b/net/minecraft/world/scores/Scoreboard.java -@@ -377,7 +_,7 @@ +@@ -373,7 +_,7 @@ } protected List packPlayerTeams() { From b9f96282e33c6fb90c0261108f7d0a42059f1f8a Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 17:48:27 +0100 Subject: [PATCH 02/16] 10 --- .../level/block/ComparatorBlock.java.patch | 38 ---------- .../block/DoubleBlockCombiner.java.patch | 24 ------ .../level/block/EndPortalBlock.java.patch | 73 ------------------- .../level/block/EnderChestBlock.java.patch | 32 -------- .../level/block/FlowerPotBlock.java.patch | 48 ------------ .../world/level/block/ButtonBlock.java.patch | 34 ++++----- .../world/level/block/ChestBlock.java.patch | 28 +++---- .../level/block/ComparatorBlock.java.patch | 30 ++++++++ .../level/block/ComposterBlock.java.patch | 57 +++++++-------- .../block/DoubleBlockCombiner.java.patch | 16 ++++ .../level/block/EndPortalBlock.java.patch | 65 +++++++++++++++++ .../level/block/EnderChestBlock.java.patch | 23 ++++++ .../level/block/FlowerPotBlock.java.patch | 41 +++++++++++ .../level/block/NetherPortalBlock.java.patch | 69 ++++++++---------- .../world/level/block/TntBlock.java.patch | 33 ++++----- 15 files changed, 267 insertions(+), 344 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/ButtonBlock.java.patch (66%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/ChestBlock.java.patch (66%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/ComposterBlock.java.patch (75%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/NetherPortalBlock.java.patch (67%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/TntBlock.java.patch (76%) diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch deleted file mode 100644 index fa1eaa35fe8f..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/ComparatorBlock.java b/net/minecraft/world/level/block/ComparatorBlock.java -index efdf488c97567ee62e0da2b6aaff3a08d0bec8c9..45e11737bc2558a4ebfffe133d43111f45dd7d16 100644 ---- a/net/minecraft/world/level/block/ComparatorBlock.java -+++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -137,7 +137,7 @@ public class ComparatorBlock extends DiodeBlock implements EntityBlock { - float pitch = state.getValue(MODE) == ComparatorMode.SUBTRACT ? 0.55F : 0.5F; - level.playSound(player, pos, SoundEvents.COMPARATOR_CLICK, SoundSource.BLOCKS, 0.3F, pitch); - level.setBlock(pos, state, Block.UPDATE_CLIENTS); -- this.refreshOutputState(level, pos, state); -+ if (level.getBlockState(pos).is(this)) { this.refreshOutputState(level, pos, state); } // Paper - Fix blockstate validation issues - return InteractionResult.SUCCESS; - } - } -@@ -168,8 +168,18 @@ public class ComparatorBlock extends DiodeBlock implements EntityBlock { - boolean sourceOn = this.shouldTurnOn(level, pos, state); - boolean isOn = state.getValue(POWERED); - if (isOn && !sourceOn) { -+ // Paper start - Call BlockRedstoneEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, false)) { -+ return; -+ } -+ // Paper end - Call BlockRedstoneEvent - level.setBlock(pos, state.setValue(POWERED, false), Block.UPDATE_CLIENTS); - } else if (!isOn && sourceOn) { -+ // Paper start - Call BlockRedstoneEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, true)) { -+ return; -+ } -+ // Paper end - Call BlockRedstoneEvent - level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch deleted file mode 100644 index e866340ea1af..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/DoubleBlockCombiner.java b/net/minecraft/world/level/block/DoubleBlockCombiner.java -index fe08e68f9bd0cafdaf74afdeb685e755e57d65a2..865b239095aca8672af3f33a6b3720cbaf6df577 100644 ---- a/net/minecraft/world/level/block/DoubleBlockCombiner.java -+++ b/net/minecraft/world/level/block/DoubleBlockCombiner.java -@@ -34,7 +34,12 @@ public class DoubleBlockCombiner { - return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); - } else { - BlockPos neighborPos = pos.relative(connectionResolver.apply(state)); -- BlockState neighbourState = level.getBlockState(neighborPos); -+ // Paper start - Don't load Chunks from Hoppers and other things -+ BlockState neighbourState = level.getBlockStateIfLoaded(neighborPos); -+ if (neighbourState == null) { -+ return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); -+ } -+ // Paper end - Don't load Chunks from Hoppers and other things - if (neighbourState.is(state.getBlock())) { - DoubleBlockCombiner.BlockType neighbourType = typeResolver.apply(neighbourState); - if (neighbourType != DoubleBlockCombiner.BlockType.SINGLE diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch deleted file mode 100644 index 32438fab8e00..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/EndPortalBlock.java.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java -index fb97cf764616da14ef33fd4a7c442aa9420dac1a..fcf0f6cf9211a5453353d2fb44e0f94d72efc2e5 100644 ---- a/net/minecraft/world/level/block/EndPortalBlock.java -+++ b/net/minecraft/world/level/block/EndPortalBlock.java -@@ -66,8 +66,14 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { - final InsideBlockEffectApplier effectApplier, - final boolean isPrecise - ) { -+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent - if (entity.canUsePortal(false)) { -+ // CraftBukkit start - Entity in portal -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), org.bukkit.PortalType.ENDER); // Paper - add portal type -+ if (!event.callEvent()) return; // Paper - make cancellable -+ // CraftBukkit end - if (!level.isClientSide() && level.dimension() == Level.END && entity instanceof ServerPlayer player && !player.seenCredits) { -+ if (level.paperConfig().misc.disableEndCredits) {player.seenCredits = true; return;} // Paper - Option to disable end credits - player.showEndCredits(); - } else { - entity.setAsInsidePortal(this, pos); -@@ -78,8 +84,7 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { - @Override - public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { - LevelData.RespawnData respawnData = currentLevel.getRespawnData(); -- ResourceKey currentDimension = currentLevel.dimension(); -- boolean fromEnd = currentDimension == Level.END; -+ boolean fromEnd = currentLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends - ResourceKey newDimension = fromEnd ? respawnData.dimension() : Level.END; - BlockPos spawnBlockPos = fromEnd ? respawnData.pos() : ServerLevel.END_SPAWN_POINT; - ServerLevel newLevel = currentLevel.getServer().getLevel(newDimension); -@@ -91,7 +96,7 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { - float xRot; - Set relatives; - if (!fromEnd) { -- EndPlatformFeature.createEndPlatform(newLevel, BlockPos.containing(spawnPos).below(), true); -+ EndPlatformFeature.createEndPlatform(newLevel, BlockPos.containing(spawnPos).below(), true, entity); // CraftBukkit - yRot = Direction.WEST.toYRot(); - xRot = 0.0F; - relatives = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); -@@ -103,15 +108,26 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { - xRot = respawnData.pitch(); - relatives = Relative.union(Relative.DELTA, Relative.ROTATION); - if (entity instanceof ServerPlayer serverPlayer) { -- return serverPlayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING); -+ return serverPlayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit - } - - spawnPos = entity.adjustSpawnLocation(newLevel, spawnBlockPos).getBottomCenter(); - } - -+ // CraftBukkit start -+ relatives.removeAll(Relative.ROTATION); // remove relative rotation flags to simplify event mutation -+ float absoluteYaw = !fromEnd ? yRot : entity.getYRot() + yRot; -+ float absolutePitch = entity.getXRot() + xRot; -+ org.bukkit.craftbukkit.event.PortalEventResult result = org.bukkit.craftbukkit.event.CraftEventFactory.handlePortalEvents(entity, org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPos, newLevel, absoluteYaw, absolutePitch), org.bukkit.PortalType.ENDER, 0, 0); -+ if (result == null) { -+ return null; -+ } -+ org.bukkit.Location to = result.to(); -+ - return new TeleportTransition( -- newLevel, spawnPos, Vec3.ZERO, yRot, xRot, relatives, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET) -+ ((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), relatives, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL - ); -+ // CraftBukkit end - } - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch deleted file mode 100644 index 35aef5628693..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/EnderChestBlock.java.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java -index 97fdb6cef743606d3e86f0e7e19367afa3de0b09..24a2c411da0ebbb7f97d621bb76ff686621f9aae 100644 ---- a/net/minecraft/world/level/block/EnderChestBlock.java -+++ b/net/minecraft/world/level/block/EnderChestBlock.java -@@ -82,14 +82,15 @@ public class EnderChestBlock extends AbstractChestBlock i - PlayerEnderChestContainer container = player.getEnderChestInventory(); - if (container != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChest) { - BlockPos above = pos.above(); -- if (level.getBlockState(above).isRedstoneConductor(level, above)) { -+ if (level.getBlockState(above).isRedstoneConductor(level, above)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic - return InteractionResult.SUCCESS; - } else { -- if (level instanceof ServerLevel serverLevel) { -- container.setActiveChest(enderChest); -- player.openMenu( -- new SimpleMenuProvider((containerId, inventory, p) -> ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE) -- ); -+ // Paper start - Fix InventoryOpenEvent cancellation - moved up; -+ container.setActiveChest(enderChest); // Needs to happen before ChestMenu.threeRows as it is required for opening animations -+ if (level instanceof ServerLevel serverLevel && player.openMenu( -+ new SimpleMenuProvider((containerId, inventory, p) -> ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE) -+ ).isPresent()) { -+ // Paper end - Fix InventoryOpenEvent cancellation - moved up; - player.awardStat(Stats.OPEN_ENDERCHEST); - PiglinAi.angerNearbyPiglins(serverLevel, player, true); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch deleted file mode 100644 index 776189e4dc2e..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/FlowerPotBlock.java b/net/minecraft/world/level/block/FlowerPotBlock.java -index 54641a7a672be8fd46256593e6c3c37b1bbda56f..784ae26280d939c27a0946dd6d880489c79f1334 100644 ---- a/net/minecraft/world/level/block/FlowerPotBlock.java -+++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -72,6 +72,18 @@ public class FlowerPotBlock extends Block { - } else if (!this.isEmpty()) { - return InteractionResult.CONSUME; - } else { -+ // Paper start - Add PlayerFlowerPotManipulateEvent -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ org.bukkit.inventory.ItemStack placedStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack); -+ -+ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent((org.bukkit.entity.Player) player.getBukkitEntity(), block, placedStack, true); -+ if (!event.callEvent()) { -+ // Update client -+ player.containerMenu.forceHeldSlot(hand); -+ -+ return InteractionResult.CONSUME; -+ } -+ // Paper end - Add PlayerFlowerPotManipulateEvent - level.setBlock(pos, newContents, Block.UPDATE_ALL); - level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); - player.awardStat(Stats.POT_FLOWER); -@@ -88,6 +100,18 @@ public class FlowerPotBlock extends Block { - return InteractionResult.CONSUME; - } else { - ItemStack plant = new ItemStack(this.potted); -+ // Paper start - Add PlayerFlowerPotManipulateEvent -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ org.bukkit.inventory.ItemStack pottedStack = new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.block.CraftBlockType.minecraftToBukkit(this.potted)); -+ -+ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent((org.bukkit.entity.Player) player.getBukkitEntity(), block, pottedStack, false); -+ if (!event.callEvent()) { -+ // Update client -+ player.containerMenu.sendAllDataToRemote(); -+ -+ return InteractionResult.PASS; -+ } -+ // Paper end - Add PlayerFlowerPotManipulateEvent - if (!player.addItem(plant)) { - player.drop(plant, false); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch similarity index 66% rename from paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch index afaa75a543bb..3525f3f703f4 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/ButtonBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch @@ -1,26 +1,18 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/ButtonBlock.java b/net/minecraft/world/level/block/ButtonBlock.java -index ae7ad024d194698c233777032602c980780df6cd..86f4dcd959bb83247c6d2c5e947c79230aed3189 100644 --- a/net/minecraft/world/level/block/ButtonBlock.java +++ b/net/minecraft/world/level/block/ButtonBlock.java -@@ -92,6 +92,11 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { - if (state.getValue(POWERED)) { +@@ -93,6 +_,11 @@ return InteractionResult.CONSUME; - } else { -+ // Paper start - Call BlockRedstoneEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, true)) { -+ return InteractionResult.SUCCESS; -+ } -+ // Paper end - Call BlockRedstoneEvent - this.press(state, level, pos, player); - return InteractionResult.SUCCESS; } -@@ -102,7 +107,9 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { + ++ // Paper start - Call BlockRedstoneEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, true)) { ++ return InteractionResult.SUCCESS; ++ } ++ // Paper end - Call BlockRedstoneEvent + this.press(state, level, pos, player); + return InteractionResult.SUCCESS; + } +@@ -102,7 +_,9 @@ final BlockState state, final ServerLevel level, final BlockPos pos, final Explosion explosion, final BiConsumer onHit ) { if (explosion.canTriggerBlocks() && !state.getValue(POWERED)) { @@ -30,7 +22,7 @@ index ae7ad024d194698c233777032602c980780df6cd..86f4dcd959bb83247c6d2c5e947c7923 } super.onExplosionHit(state, level, pos, explosion, onHit); -@@ -162,6 +169,7 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { +@@ -162,6 +_,7 @@ final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -38,7 +30,7 @@ index ae7ad024d194698c233777032602c980780df6cd..86f4dcd959bb83247c6d2c5e947c7923 if (!level.isClientSide() && this.type.canButtonBeActivatedByArrows() && !state.getValue(POWERED)) { this.checkPressed(state, level, pos); } -@@ -173,7 +181,21 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { +@@ -173,7 +_,21 @@ : null; boolean shouldBePressed = firstArrow != null; boolean wasPressed = state.getValue(POWERED); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch similarity index 66% rename from paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch index da4c66cdc77f..2f76a675854e 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,28 +1,20 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/ChestBlock.java b/net/minecraft/world/level/block/ChestBlock.java -index 676b3f41a136e036dcaea719bd72a8f4da4b381c..d3f0680d59ec87990b54dc3dbce27706bfadf5f1 100644 --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -97,7 +97,7 @@ public class ChestBlock extends AbstractChestBlock implements +@@ -96,7 +_,7 @@ @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); - return Optional.of(new MenuProvider() { + return Optional.of(org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest.Provider.wrap(new MenuProvider() { // CraftBukkit - wrap for identification - { - Objects.requireNonNull(container); - } -@@ -122,10 +122,10 @@ public class ChestBlock extends AbstractChestBlock implements + @Override + public @Nullable AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { + if (first.canOpen(player) && second.canOpen(player)) { +@@ -117,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { -- return (Component)(second.hasCustomName() ? second.getDisplayName() : Component.translatable("container.chestDouble")); -+ return (Component)(second.hasCustomName() ? second.getDisplayName() : Component.translatable("container.chestDouble")); // Paper - diff on change - CraftDoubleChestInventoryViewBuilder.defaultTitle +- return second.hasCustomName() ? second.getDisplayName() : Component.translatable("container.chestDouble"); ++ return second.hasCustomName() ? second.getDisplayName() : Component.translatable("container.chestDouble"); // Paper - diff on change - CraftDoubleChestInventoryViewBuilder.defaultTitle } } - }); @@ -30,7 +22,7 @@ index 676b3f41a136e036dcaea719bd72a8f4da4b381c..d3f0680d59ec87990b54dc3dbce27706 } @Override -@@ -268,8 +268,7 @@ public class ChestBlock extends AbstractChestBlock implements +@@ -263,8 +_,7 @@ ) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -40,7 +32,7 @@ index 676b3f41a136e036dcaea719bd72a8f4da4b381c..d3f0680d59ec87990b54dc3dbce27706 player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -310,7 +309,13 @@ public class ChestBlock extends AbstractChestBlock implements +@@ -305,7 +_,13 @@ @Override public @Nullable MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) { @@ -55,7 +47,7 @@ index 676b3f41a136e036dcaea719bd72a8f4da4b381c..d3f0680d59ec87990b54dc3dbce27706 } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity entity) { -@@ -352,6 +357,11 @@ public class ChestBlock extends AbstractChestBlock implements +@@ -347,6 +_,11 @@ } private static boolean isCatSittingOnChest(final LevelAccessor level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch new file mode 100644 index 000000000000..02b1fb8e6e41 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/level/block/ComparatorBlock.java ++++ b/net/minecraft/world/level/block/ComparatorBlock.java +@@ -138,7 +_,7 @@ + float pitch = state.getValue(MODE) == ComparatorMode.SUBTRACT ? 0.55F : 0.5F; + level.playSound(player, pos, SoundEvents.COMPARATOR_CLICK, SoundSource.BLOCKS, 0.3F, pitch); + level.setBlock(pos, state, Block.UPDATE_CLIENTS); +- this.refreshOutputState(level, pos, state); ++ if (level.getBlockState(pos).is(this)) { this.refreshOutputState(level, pos, state); } // Paper - Fix blockstate validation issues + return InteractionResult.SUCCESS; + } + +@@ -168,8 +_,18 @@ + boolean sourceOn = this.shouldTurnOn(level, pos, state); + boolean isOn = state.getValue(POWERED); + if (isOn && !sourceOn) { ++ // Paper start - Call BlockRedstoneEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, false)) { ++ return; ++ } ++ // Paper end - Call BlockRedstoneEvent + level.setBlock(pos, state.setValue(POWERED, false), Block.UPDATE_CLIENTS); + } else if (!isOn && sourceOn) { ++ // Paper start - Call BlockRedstoneEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, true)) { ++ return; ++ } ++ // Paper end - Call BlockRedstoneEvent + level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch similarity index 75% rename from paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch index 324cb9d56d95..2879bcbc8cc9 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java -index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e294d4b48e7 100644 --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -258,6 +258,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -258,6 +_,11 @@ if (fillLevel < 8 && COMPOSTABLES.containsKey(itemStack.getItem())) { if (fillLevel < 7 && !level.isClientSide()) { BlockState newState = addItem(player, state, level, pos, itemStack); @@ -20,7 +12,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 level.levelEvent(LevelEvent.COMPOSTER_FILL, pos, state != newState ? 1 : 0); player.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); itemStack.consume(1, player); -@@ -287,7 +292,19 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -287,7 +_,19 @@ ) { int fillLevel = state.getValue(LEVEL); if (fillLevel < 7 && COMPOSTABLES.containsKey(itemStack.getItem())) { @@ -41,7 +33,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 itemStack.shrink(1); return newState; } else { -@@ -296,6 +313,14 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -296,6 +_,14 @@ } public static BlockState extractProduce(final Entity sourceEntity, final BlockState state, final Level level, final BlockPos pos) { @@ -56,14 +48,14 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 if (!level.isClientSide()) { Vec3 itemPos = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandomXZ(level.getRandom(), 0.7F); ItemEntity entity = new ItemEntity(level, itemPos.x(), itemPos.y(), itemPos.z(), new ItemStack(Items.BONE_MEAL)); -@@ -315,16 +340,44 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -315,17 +_,45 @@ return newState; } + @Nullable // Paper private static BlockState addItem( final @Nullable Entity sourceEntity, final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack itemStack -+ ) { + ) { + // CraftBukkit start + return ComposterBlock.addItem(sourceEntity, state, level, pos, itemStack, level.getRandom().nextDouble()); + } @@ -71,7 +63,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 + private static BlockState addItem( + final @Nullable Entity sourceEntity, final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack itemStack, final double rand + // CraftBukkit end - ) { ++ ) { int fillLevel = state.getValue(LEVEL); float chance = COMPOSTABLES.getFloat(itemStack.getItem()); - if ((fillLevel != 0 || !(chance > 0.0F)) && !(level.getRandom().nextDouble() < chance)) { @@ -91,23 +83,24 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 + if (!willRaiseLevel) { + // Paper end - Add CompostItemEvent and EntityCompostItemEvent return state; - } else { - int newLevel = fillLevel + 1; - BlockState newState = state.setValue(LEVEL, newLevel); -+ // Paper start - move the EntityChangeBlockEvent here to avoid conflict later for the compost events -+ if (sourceEntity != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(sourceEntity, pos, newState)) { -+ return null; -+ } -+ // Paper end - level.setBlock(pos, newState, Block.UPDATE_ALL); - level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(sourceEntity, newState)); - if (newLevel == 7) { -@@ -369,13 +422,14 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { + } + + int newLevel = fillLevel + 1; + BlockState newState = state.setValue(LEVEL, newLevel); ++ // Paper start - move the EntityChangeBlockEvent here to avoid conflict later for the compost events ++ if (sourceEntity != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(sourceEntity, pos, newState)) { ++ return null; ++ } ++ // Paper end + level.setBlock(pos, newState, Block.UPDATE_ALL); + level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(sourceEntity, newState)); + if (newLevel == 7) { +@@ -369,13 +_,14 @@ if (contentLevel == 8) { return new ComposterBlock.OutputContainer(state, level, pos, new ItemStack(Items.BONE_MEAL)); } else { -- return (WorldlyContainer)(contentLevel < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer()); -+ return (WorldlyContainer)(contentLevel < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer(level, pos)); // CraftBukkit - empty levelAccessor, blockPos +- return contentLevel < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer(); ++ return contentLevel < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer(level, pos); // CraftBukkit - empty levelAccessor, blockPos } } @@ -119,7 +112,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 } @Override -@@ -402,6 +456,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -402,6 +_,7 @@ public InputContainer(final BlockState state, final LevelAccessor level, final BlockPos pos) { super(1); @@ -127,7 +120,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 this.state = state; this.level = level; this.pos = pos; -@@ -433,6 +488,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -433,6 +_,11 @@ if (!contents.isEmpty()) { this.changed = true; BlockState newState = ComposterBlock.addItem(null, this.state, this.level, this.pos, contents); @@ -139,7 +132,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 this.level.levelEvent(LevelEvent.COMPOSTER_FILL, this.pos, newState != this.state ? 1 : 0); this.removeItemNoUpdate(0); } -@@ -447,6 +507,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -447,6 +_,7 @@ public OutputContainer(final BlockState state, final LevelAccessor level, final BlockPos pos, final ItemStack contents) { super(contents); @@ -147,7 +140,7 @@ index dd416accfb0f535b2d472914339836e16d071c3d..3eb65e5ed0241330ebde3e05f7865e29 this.state = state; this.level = level; this.pos = pos; -@@ -474,8 +535,15 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -474,8 +_,15 @@ @Override public void setChanged() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch new file mode 100644 index 000000000000..3313289a5e9b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoubleBlockCombiner.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/block/DoubleBlockCombiner.java ++++ b/net/minecraft/world/level/block/DoubleBlockCombiner.java +@@ -38,7 +_,12 @@ + } + + BlockPos neighborPos = pos.relative(connectionResolver.apply(state)); +- BlockState neighbourState = level.getBlockState(neighborPos); ++ // Paper start - Don't load Chunks from Hoppers and other things ++ BlockState neighbourState = level.getBlockStateIfLoaded(neighborPos); ++ if (neighbourState == null) { ++ return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); ++ } ++ // Paper end - Don't load Chunks from Hoppers and other things + if (neighbourState.is(state.getBlock())) { + DoubleBlockCombiner.BlockType neighbourType = typeResolver.apply(neighbourState); + if (neighbourType != DoubleBlockCombiner.BlockType.SINGLE diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch new file mode 100644 index 000000000000..f591d40643d1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/world/level/block/EndPortalBlock.java ++++ b/net/minecraft/world/level/block/EndPortalBlock.java +@@ -66,8 +_,14 @@ + final InsideBlockEffectApplier effectApplier, + final boolean isPrecise + ) { ++ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent + if (entity.canUsePortal(false)) { ++ // CraftBukkit start - Entity in portal ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), org.bukkit.PortalType.ENDER); // Paper - add portal type ++ if (!event.callEvent()) return; // Paper - make cancellable ++ // CraftBukkit end + if (!level.isClientSide() && level.dimension() == Level.END && entity instanceof ServerPlayer player && !player.seenCredits) { ++ if (level.paperConfig().misc.disableEndCredits) {player.seenCredits = true; return;} // Paper - Option to disable end credits + player.showEndCredits(); + } else { + entity.setAsInsidePortal(this, pos); +@@ -78,8 +_,7 @@ + @Override + public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { + LevelData.RespawnData respawnData = currentLevel.getRespawnData(); +- ResourceKey currentDimension = currentLevel.dimension(); +- boolean fromEnd = currentDimension == Level.END; ++ boolean fromEnd = currentLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends + ResourceKey newDimension = fromEnd ? respawnData.dimension() : Level.END; + BlockPos spawnBlockPos = fromEnd ? respawnData.pos() : ServerLevel.END_SPAWN_POINT; + ServerLevel newLevel = currentLevel.getServer().getLevel(newDimension); +@@ -92,7 +_,7 @@ + float xRot; + Set relatives; + if (!fromEnd) { +- EndPlatformFeature.createEndPlatform(newLevel, BlockPos.containing(spawnPos).below(), true); ++ EndPlatformFeature.createEndPlatform(newLevel, BlockPos.containing(spawnPos).below(), true, entity); // CraftBukkit + yRot = Direction.WEST.toYRot(); + xRot = 0.0F; + relatives = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); +@@ -104,15 +_,26 @@ + xRot = respawnData.pitch(); + relatives = Relative.union(Relative.DELTA, Relative.ROTATION); + if (entity instanceof ServerPlayer serverPlayer) { +- return serverPlayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING); ++ return serverPlayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit + } + + spawnPos = entity.adjustSpawnLocation(newLevel, spawnBlockPos).getBottomCenter(); + } + ++ // CraftBukkit start ++ relatives.removeAll(Relative.ROTATION); // remove relative rotation flags to simplify event mutation ++ float absoluteYaw = !fromEnd ? yRot : entity.getYRot() + yRot; ++ float absolutePitch = entity.getXRot() + xRot; ++ org.bukkit.craftbukkit.event.PortalEventResult result = org.bukkit.craftbukkit.event.CraftEventFactory.handlePortalEvents(entity, org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPos, newLevel, absoluteYaw, absolutePitch), org.bukkit.PortalType.ENDER, 0, 0); ++ if (result == null) { ++ return null; ++ } ++ org.bukkit.Location to = result.to(); ++ + return new TeleportTransition( +- newLevel, spawnPos, Vec3.ZERO, yRot, xRot, relatives, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET) ++ ((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), relatives, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL + ); ++ // CraftBukkit end + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch new file mode 100644 index 000000000000..6816771d3bc9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EnderChestBlock.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/level/block/EnderChestBlock.java ++++ b/net/minecraft/world/level/block/EnderChestBlock.java +@@ -82,13 +_,16 @@ + PlayerEnderChestContainer container = player.getEnderChestInventory(); + if (container != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChest) { + BlockPos above = pos.above(); +- if (level.getBlockState(above).isRedstoneConductor(level, above)) { ++ if (level.getBlockState(above).isRedstoneConductor(level, above)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic + return InteractionResult.SUCCESS; + } + +- if (level instanceof ServerLevel serverLevel) { +- container.setActiveChest(enderChest); +- player.openMenu(new SimpleMenuProvider((containerId, inventory, p) -> ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE)); ++ // Paper start - Fix InventoryOpenEvent cancellation - moved up; ++ container.setActiveChest(enderChest); // Needs to happen before ChestMenu.threeRows as it is required for opening animations ++ if (level instanceof ServerLevel serverLevel && player.openMenu( ++ new SimpleMenuProvider((containerId, inventory, p) -> ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE) ++ ).isPresent()) { ++ // Paper end - Fix InventoryOpenEvent cancellation - moved up; + player.awardStat(Stats.OPEN_ENDERCHEST); + PiglinAi.angerNearbyPiglins(serverLevel, player, true); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch new file mode 100644 index 000000000000..5e5a61245d77 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/level/block/FlowerPotBlock.java ++++ b/net/minecraft/world/level/block/FlowerPotBlock.java +@@ -74,7 +_,18 @@ + if (!this.isEmpty()) { + return InteractionResult.CONSUME; + } +- ++ // Paper start - Add PlayerFlowerPotManipulateEvent ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ org.bukkit.inventory.ItemStack placedStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack); ++ ++ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent((org.bukkit.entity.Player) player.getBukkitEntity(), block, placedStack, true); ++ if (!event.callEvent()) { ++ // Update client ++ player.containerMenu.forceHeldSlot(hand); ++ ++ return InteractionResult.CONSUME; ++ } ++ // Paper end - Add PlayerFlowerPotManipulateEvent + level.setBlock(pos, newContents, Block.UPDATE_ALL); + level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); + player.awardStat(Stats.POT_FLOWER); +@@ -91,6 +_,18 @@ + } + + ItemStack plant = new ItemStack(this.potted); ++ // Paper start - Add PlayerFlowerPotManipulateEvent ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ org.bukkit.inventory.ItemStack pottedStack = new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.block.CraftBlockType.minecraftToBukkit(this.potted)); ++ ++ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent((org.bukkit.entity.Player) player.getBukkitEntity(), block, pottedStack, false); ++ if (!event.callEvent()) { ++ // Update client ++ player.containerMenu.sendAllDataToRemote(); ++ ++ return InteractionResult.PASS; ++ } ++ // Paper end - Add PlayerFlowerPotManipulateEvent + if (!player.addItem(plant)) { + player.drop(plant, false); + } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch similarity index 67% rename from paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index 73b446dee086..b71f0beae512 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java -index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be550a8f5e0 100644 --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -66,7 +66,7 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -66,7 +_,7 @@ @Override protected void randomTick(final BlockState state, final ServerLevel level, BlockPos pos, final RandomSource random) { @@ -17,7 +9,7 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 && level.environmentAttributes().getValue(EnvironmentAttributes.NETHER_PORTAL_SPAWNS_PIGLINS, pos) && random.nextInt(2000) < level.getDifficulty().getId() && level.anyPlayerCloseEnoughForSpawning(pos)) { -@@ -75,9 +75,13 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -75,9 +_,13 @@ } if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { @@ -32,7 +24,7 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -115,7 +119,13 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -115,7 +_,13 @@ final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -46,7 +38,7 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 entity.setAsInsidePortal(this, pos); } } -@@ -133,16 +143,39 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -133,17 +_,40 @@ @Override public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { @@ -63,33 +55,34 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 + // Paper end - Add EntityPortalReadyEvent if (newLevel == null) { return null; - } else { -- boolean toNether = newLevel.dimension() == Level.NETHER; -+ boolean toNether = newLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER; // CraftBukkit - WorldBorder newWorldBorder = newLevel.getWorldBorder(); - double teleportationScale = DimensionType.getTeleportationScale(currentLevel.dimensionType(), newLevel.dimensionType()); - BlockPos approximateExitPos = newWorldBorder.clampToBounds(entity.getX() * teleportationScale, entity.getY(), entity.getZ() * teleportationScale); -- return this.getExitPortal(newLevel, entity, portalEntryPos, approximateExitPos, toNether, newWorldBorder); -+ // Paper start - Configurable portal search radius -+ int portalSearchRadius = newLevel.paperConfig().environment.portalSearchRadius; -+ if (entity.level().paperConfig().environment.portalSearchVanillaDimensionScaling && toNether) { -+ portalSearchRadius = (int) (portalSearchRadius / newLevel.dimensionType().coordinateScale()); -+ } -+ // Paper end - Configurable portal search radius -+ // CraftBukkit start -+ org.bukkit.craftbukkit.event.PortalEventResult result = org.bukkit.craftbukkit.event.CraftEventFactory.handlePortalEvents(entity, org.bukkit.craftbukkit.util.CraftLocation.toBukkit(approximateExitPos, newLevel), org.bukkit.PortalType.NETHER, portalSearchRadius, newLevel.paperConfig().environment.portalCreateRadius); // Paper - use custom portal search radius -+ if (result == null) { -+ return null; -+ } -+ newLevel = ((org.bukkit.craftbukkit.CraftWorld) result.to().getWorld()).getHandle(); -+ newWorldBorder = newLevel.getWorldBorder(); -+ approximateExitPos = newWorldBorder.clampToBounds(result.to().getX(), result.to().getY(), result.to().getZ()); -+ return this.getExitPortal(newLevel, entity, portalEntryPos, approximateExitPos, toNether, newWorldBorder, result); -+ // CraftBukkit end } + +- boolean toNether = newLevel.dimension() == Level.NETHER; ++ boolean toNether = newLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER; // CraftBukkit + WorldBorder newWorldBorder = newLevel.getWorldBorder(); + double teleportationScale = DimensionType.getTeleportationScale(currentLevel.dimensionType(), newLevel.dimensionType()); + BlockPos approximateExitPos = newWorldBorder.clampToBounds(entity.getX() * teleportationScale, entity.getY(), entity.getZ() * teleportationScale); +- return this.getExitPortal(newLevel, entity, portalEntryPos, approximateExitPos, toNether, newWorldBorder); ++ // Paper start - Configurable portal search radius ++ int portalSearchRadius = newLevel.paperConfig().environment.portalSearchRadius; ++ if (entity.level().paperConfig().environment.portalSearchVanillaDimensionScaling && toNether) { ++ portalSearchRadius = (int) (portalSearchRadius / newLevel.dimensionType().coordinateScale()); ++ } ++ // Paper end - Configurable portal search radius ++ // CraftBukkit start ++ org.bukkit.craftbukkit.event.PortalEventResult result = org.bukkit.craftbukkit.event.CraftEventFactory.handlePortalEvents(entity, org.bukkit.craftbukkit.util.CraftLocation.toBukkit(approximateExitPos, newLevel), org.bukkit.PortalType.NETHER, portalSearchRadius, newLevel.paperConfig().environment.portalCreateRadius); // Paper - use custom portal search radius ++ if (result == null) { ++ return null; ++ } ++ newLevel = ((org.bukkit.craftbukkit.CraftWorld) result.to().getWorld()).getHandle(); ++ newWorldBorder = newLevel.getWorldBorder(); ++ approximateExitPos = newWorldBorder.clampToBounds(result.to().getX(), result.to().getY(), result.to().getZ()); ++ return this.getExitPortal(newLevel, entity, portalEntryPos, approximateExitPos, toNether, newWorldBorder, result); ++ // CraftBukkit end } -@@ -153,8 +186,9 @@ public class NetherPortalBlock extends Block implements Portal { + private @Nullable TeleportTransition getExitPortal( +@@ -153,8 +_,9 @@ final BlockPos approximateExitPos, final boolean toNether, final WorldBorder worldBorder @@ -100,7 +93,7 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 BlockUtil.FoundRectangle exitPortal; TeleportTransition.PostTeleportTransition post; if (exitPortalPos.isPresent()) { -@@ -169,17 +203,22 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -169,17 +_,22 @@ blockPos -> newLevel.getBlockState(blockPos) == portalState ); post = TeleportTransition.PLAY_PORTAL_SOUND.then(e -> e.placePortalTicket(pos)); @@ -126,7 +119,7 @@ index 6ed3a44d417f4eef3d3041c4ae04a2b0867b8b5f..b66aa14aea47e3b10c3e28cf25a64be5 return getDimensionTransitionFromExit(entity, portalEntryPos, exitPortal, newLevel, post); } -@@ -234,7 +273,7 @@ public class NetherPortalBlock extends Block implements Portal { +@@ -234,7 +_,7 @@ ); Vec3 collisionFreePos = PortalShape.findCollisionFreePosition(targetPos, newLevel, entity, dimensions); return new TeleportTransition( diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index 57fe73d72459..80b2aa7bf557 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/TntBlock.java b/net/minecraft/world/level/block/TntBlock.java -index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f74e4cb41 100644 --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -47,7 +47,7 @@ public class TntBlock extends Block { +@@ -47,7 +_,7 @@ @Override protected void onPlace(final BlockState state, final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) { if (!oldState.is(state.getBlock())) { @@ -17,7 +9,7 @@ index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f level.removeBlock(pos, false); } } -@@ -57,7 +57,7 @@ public class TntBlock extends Block { +@@ -57,7 +_,7 @@ protected void neighborChanged( final BlockState state, final Level level, final BlockPos pos, final Block block, final @Nullable Orientation orientation, final boolean movedByPiston ) { @@ -26,7 +18,7 @@ index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f level.removeBlock(pos, false); } } -@@ -65,7 +65,7 @@ public class TntBlock extends Block { +@@ -65,7 +_,7 @@ @Override public BlockState playerWillDestroy(final Level level, final BlockPos pos, final BlockState state, final Player player) { if (!level.isClientSide() && !player.getAbilities().instabuild && state.getValue(UNSTABLE)) { @@ -35,7 +27,7 @@ index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f } return super.playerWillDestroy(level, pos, state, player); -@@ -82,11 +82,16 @@ public class TntBlock extends Block { +@@ -82,11 +_,16 @@ } public static boolean prime(final Level level, final BlockPos pos) { @@ -55,16 +47,17 @@ index ebe041f055c7c2a5d78c1c295e94e7ddc9049228..58142c276c976b16100e14ee9adb547f PrimedTnt tnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, source); level.addFreshEntity(tnt); level.playSound(null, tnt.getX(), tnt.getY(), tnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -110,7 +115,7 @@ public class TntBlock extends Block { +@@ -110,8 +_,7 @@ if (!itemStack.is(Items.FLINT_AND_STEEL) && !itemStack.is(Items.FIRE_CHARGE)) { return super.useItemOn(itemStack, state, level, pos, player, hand, hitResult); - } else { -- if (prime(level, pos, player)) { -+ if (prime(level, pos, player, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PLAYER, player, null))) { // Paper - level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); - Item item = itemStack.getItem(); - if (itemStack.is(Items.FLINT_AND_STEEL)) { -@@ -136,7 +141,7 @@ public class TntBlock extends Block { + } +- +- if (prime(level, pos, player)) { ++ if (prime(level, pos, player, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PLAYER, player, null))) { // Paper + level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); + Item item = itemStack.getItem(); + if (itemStack.is(Items.FLINT_AND_STEEL)) { +@@ -136,7 +_,7 @@ Entity owner = projectile.getOwner(); if (projectile.isOnFire() && projectile.mayInteract(serverLevel, pos) From c1fe5ed51c965f42571073dcd67dc32bbfaef369 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 17:58:58 +0100 Subject: [PATCH 03/16] 20 --- .../entity/ai/behavior/AcquirePoi.java.patch | 18 ---- .../ai/behavior/StartAttacking.java.patch | 28 ------ ...TransportItemsBetweenContainers.java.patch | 22 ----- .../ai/behavior/VillagerMakeLove.java.patch | 31 ------ .../world/level/block/BedBlock.java.patch | 94 ------------------- .../world/level/block/CakeBlock.java.patch | 54 ----------- .../level/block/RespawnAnchorBlock.java.patch | 45 --------- .../entity/ai/behavior/AcquirePoi.java.patch | 10 ++ .../ai/behavior/StartAttacking.java.patch | 20 ++++ ...TransportItemsBetweenContainers.java.patch | 14 +++ .../ai/behavior/VillagerMakeLove.java.patch | 23 +++++ .../world/level/block/BedBlock.java.patch | 84 +++++++++++++++++ .../world/level/block/CakeBlock.java.patch | 46 +++++++++ .../block/CopperGolemStatueBlock.java.patch | 19 +--- .../level/block/MushroomBlock.java.patch | 30 +++--- .../level/block/RespawnAnchorBlock.java.patch | 37 ++++++++ .../level/block/TripWireHookBlock.java.patch | 35 +++---- 17 files changed, 264 insertions(+), 346 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch (59%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/MushroomBlock.java.patch (51%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/TripWireHookBlock.java.patch (70%) diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch deleted file mode 100644 index 7b0a53382daa..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 3e5c97286971feba437a4736acdf715361d70700..3325e7d4827067a65b176c5ba01aa491abd222a5 100644 ---- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -+++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -74,6 +74,7 @@ public class AcquirePoi { - return false; - } else { - nextScheduledStart.setValue(timestamp + 20L + random.nextInt(20)); -+ if (level.paperConfig().entities.behavior.stuckEntityPoiRetryDelay.enabled() && body.getNavigation().isStuck()) nextScheduledStart.add(level.paperConfig().entities.behavior.stuckEntityPoiRetryDelay.intValue()); // Paper - Next stuck check delay config - PoiManager poiManager = level.getPoiManager(); - batchCache.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(timestamp)); - Predicate cacheTest = pos -> { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch deleted file mode 100644 index ba2086b95c21..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/StartAttacking.java b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -index 4a4d2e87d788ca9deecb27c82791e8fdca24ea33..cd78c8f06b40931aecf08445f8637f2b854aa989 100644 ---- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java -+++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -29,6 +29,17 @@ public class StartAttacking { - if (!body.canAttack(targetEntity)) { - return false; - } else { -+ // CraftBukkit start -+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(body, targetEntity, (targetEntity instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); -+ if (event.isCancelled()) { -+ return false; -+ } -+ if (event.getTarget() == null) { -+ attackTarget.erase(); -+ return true; -+ } -+ targetEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); -+ // CraftBukkit end - attackTarget.set(targetEntity); - cantReachSince.erase(); - return true; diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch deleted file mode 100644 index b888099087ef..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -index 31e5087fcacd1b646e62f8ef0928352f226685f6..683f438676d16bce8b9d7f33aad600a02ed54aa1 100644 ---- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -+++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -@@ -327,7 +327,10 @@ public class TransportItemsBetweenContainers extends Behavior { - } else { - boolean isValidTarget = this.isWantedBlock(body, transportItemTarget.state) - && !this.isPositionAlreadyVisited(visitedPositions, unreachablePositions, transportItemTarget, level) -- && !this.isContainerLocked(transportItemTarget); -+ // Paper start - ItemTransportingEntityValidateTargetEvent -+ && !this.isContainerLocked(transportItemTarget) -+ && org.bukkit.craftbukkit.event.CraftEventFactory.callTransporterValidateTarget(body, level, transportItemTarget.pos); -+ // Paper end - ItemTransportingEntityValidateTargetEvent - return isValidTarget ? transportItemTarget : null; - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch deleted file mode 100644 index 13961b96ad46..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -index cbd5d1aabbe2a2741094fb80bb6de28d1fbfa122..37cf6c4cef5a8885fddd9f637cac024892b498a3 100644 ---- a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -+++ b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -@@ -111,11 +111,17 @@ public class VillagerMakeLove extends Behavior { - if (child == null) { - return Optional.empty(); - } else { -- source.setAge(6000); -- target.setAge(6000); - child.setAge(-24000); -+ // Paper - Move age setting down - child.snapTo(source.getX(), source.getY(), source.getZ(), 0.0F, 0.0F); -- level.addFreshEntityWithPassengers(child); -+ // CraftBukkit start - call EntityBreedEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(child, source, target, null, null, 0).isCancelled()) { -+ return Optional.empty(); -+ } -+ source.setAge(6000); -+ target.setAge(6000); -+ level.addFreshEntityWithPassengers(child, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); -+ // CraftBukkit end - call EntityBreedEvent - level.broadcastEntityEvent(child, EntityEvent.LOVE_HEARTS); - return Optional.of(child); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch deleted file mode 100644 index 3ed0a5b11b1c..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/BedBlock.java.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/BedBlock.java b/net/minecraft/world/level/block/BedBlock.java -index 6096d39488c378271228029d08ef11df7ab82431..fea3df8af41f61e3f91f6cd6bd06dc0a0ced232b 100644 ---- a/net/minecraft/world/level/block/BedBlock.java -+++ b/net/minecraft/world/level/block/BedBlock.java -@@ -91,7 +91,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock - } - - BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); -- if (bedRule.explodes()) { -+ if (false && bedRule.explodes()) { // CraftBukkit - moved world and biome check into Player - bedRule.errorMessage().ifPresent(player::sendOverlayMessage); - level.removeBlock(pos, false); - BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -103,22 +103,61 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock - level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), null, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); - return InteractionResult.SUCCESS_SERVER; - } else if (state.getValue(OCCUPIED)) { -+ if (bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first - if (!this.kickVillagerOutOfBed(level, pos)) { - player.sendOverlayMessage(Component.translatable("block.minecraft.bed.occupied")); - } - - return InteractionResult.SUCCESS_SERVER; - } else { -+ // CraftBukkit start -+ final BlockState finalBlockState = state; -+ final BlockPos finalBlockPos = pos; -+ // CraftBukkit end - player.startSleepInBed(pos).ifLeft(problem -> { -- if (problem.message() != null) { -+ // Paper start - PlayerBedFailEnterEvent -+ if (false && problem.message() != null) { // Moved down - player.sendOverlayMessage(problem.message()); - } -+ if (problem != null) { -+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, problem); -+ if (event.isCancelled()) { -+ return; -+ } -+ // Paper end - PlayerBedFailEnterEvent -+ // CraftBukkit start - handling bed explosion from below here -+ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent -+ this.explodeBed(finalBlockState, level, finalBlockPos); -+ } -+ // CraftBukkit end -+ // Paper start - PlayerBedFailEnterEvent -+ final net.kyori.adventure.text.Component message = event.getMessage(); -+ if (message != null) { -+ player.sendOverlayMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message)); -+ } -+ } -+ // Paper end - PlayerBedFailEnterEvent - }); - return InteractionResult.SUCCESS_SERVER; - } - } - } - -+ // CraftBukkit start - Copied from the above method -+ private InteractionResult explodeBed(BlockState state, Level level, BlockPos pos) { -+ org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos).getState(); // CraftBukkit - capture BlockState before remove block -+ level.removeBlock(pos, false); -+ BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -+ if (level.getBlockState(blockPos).is(this)) { -+ level.removeBlock(blockPos, false); -+ } -+ -+ Vec3 center = pos.getCenter(); -+ level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state -+ return InteractionResult.SUCCESS_SERVER; -+ } -+ // CraftBukkit end -+ - private boolean kickVillagerOutOfBed(final Level level, final BlockPos pos) { - List villagers = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); - if (villagers.isEmpty()) { -@@ -298,6 +337,11 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock - if (!level.isClientSide()) { - BlockPos otherPos = pos.relative(state.getValue(FACING)); - level.setBlock(otherPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); -+ // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states -+ if (level.captureBlockStates) { -+ return; -+ } -+ // CraftBukkit end - level.updateNeighborsAt(pos, Blocks.AIR); - state.updateNeighbourShapes(level, pos, Block.UPDATE_ALL); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch deleted file mode 100644 index e4a632eff2b7..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/CakeBlock.java.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/CakeBlock.java b/net/minecraft/world/level/block/CakeBlock.java -index 72c79ff33d31a8c2e3f46d28f0a4ae42528d9e87..14b3dd17c5fbeea87c3576b88a1fe0a71c9320b3 100644 ---- a/net/minecraft/world/level/block/CakeBlock.java -+++ b/net/minecraft/world/level/block/CakeBlock.java -@@ -63,6 +63,12 @@ public class CakeBlock extends Block { - ) { - Item item = itemStack.getItem(); - if (itemStack.is(ItemTags.CANDLES) && state.getValue(BITES) == 0 && Block.byItem(item) instanceof CandleBlock candleBlock) { -+ // Paper start - call change block event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, CandleCakeBlock.byCandle(candleBlock))) { -+ player.containerMenu.forceHeldSlot(hand); // update inv because candle could decrease -+ return InteractionResult.TRY_WITH_EMPTY_HAND; -+ } -+ // Paper end - call change block event - itemStack.consume(1, player); - level.playSound(null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); - level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(candleBlock)); -@@ -95,9 +101,28 @@ public class CakeBlock extends Block { - if (!player.canEat(false)) { - return InteractionResult.PASS; - } else { -+ // Paper start - call change block event -+ int bites = state.getValue(CakeBlock.BITES); -+ final BlockState newState = bites < MAX_BITES ? state.setValue(CakeBlock.BITES, bites + 1) : level.getFluidState(pos).createLegacyBlock(); -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) { -+ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate(); -+ return InteractionResult.PASS; // return a non-consume result to cake blocks don't drop their candles -+ } -+ // Paper end - call change block event - player.awardStat(Stats.EAT_CAKE_SLICE); -- player.getFoodData().eat(2, 0.1F); -- int bites = state.getValue(BITES); -+ // CraftBukkit start -+ // player.getFoodData().eat(2, 0.1F); -+ // int bites = state.getValue(BITES); // Paper - move up -+ int oldFoodLevel = player.getFoodData().foodLevel; -+ -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel); -+ -+ if (!event.isCancelled()) { -+ player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); -+ } -+ -+ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate(); -+ // CraftBukkit end - level.gameEvent(player, GameEvent.EAT, pos); - if (bites < 6) { - level.setBlock(pos, state.setValue(BITES, bites + 1), Block.UPDATE_ALL); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch deleted file mode 100644 index c6c8d9d0f6a7..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/RespawnAnchorBlock.java b/net/minecraft/world/level/block/RespawnAnchorBlock.java -index a1ea6aff9a0ddb609f0213993564dbbf7c1acfb3..d854f4bbf97d625dd9e775d139e8446b9008c215 100644 ---- a/net/minecraft/world/level/block/RespawnAnchorBlock.java -+++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -115,11 +115,16 @@ public class RespawnAnchorBlock extends Block { - LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false - ); - if (respawnConfig == null || !respawnConfig.isSamePosition(newRespawnConfig)) { -- serverPlayer.setRespawnPosition(newRespawnConfig, true); -+ if (serverPlayer.setRespawnPosition(newRespawnConfig, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent - serverLevel.playSound( - null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F - ); - return InteractionResult.SUCCESS_SERVER; -+ // Paper start - Add PlayerSetSpawnEvent -+ } else { -+ return InteractionResult.FAIL; -+ } -+ // Paper end - Add PlayerSetSpawnEvent - } - } - -@@ -156,6 +161,7 @@ public class RespawnAnchorBlock extends Block { - } - - private void explode(final BlockState state, final ServerLevel level, final BlockPos pos) { -+ org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos).getState(); // CraftBukkit - capture BlockState before remove block - level.removeBlock(pos, false); - boolean anyWaterNeighbors = Direction.Plane.HORIZONTAL.stream().map(pos::relative).anyMatch(neighborPos -> isWaterThatWouldFlow(neighborPos, level)); - final boolean inWater = anyWaterNeighbors || level.getFluidState(pos.above()).is(FluidTags.WATER); -@@ -174,7 +180,7 @@ public class RespawnAnchorBlock extends Block { - } - }; - Vec3 boomPos = pos.getCenter(); -- level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), damageCalculator, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); -+ level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos).causingBlockSnapshot(blockState), damageCalculator, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state - } - - public static boolean canSetSpawn(final ServerLevel level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch new file mode 100644 index 000000000000..1f3d07b60b34 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java ++++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +@@ -78,6 +_,7 @@ + } + + nextScheduledStart.setValue(timestamp + 20L + random.nextInt(20)); ++ if (level.paperConfig().entities.behavior.stuckEntityPoiRetryDelay.enabled() && body.getNavigation().isStuck()) nextScheduledStart.add(level.paperConfig().entities.behavior.stuckEntityPoiRetryDelay.intValue()); // Paper - Next stuck check delay config + PoiManager poiManager = level.getPoiManager(); + batchCache.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(timestamp)); + Predicate cacheTest = pos -> { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch new file mode 100644 index 000000000000..fc02b6e3da3f --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java ++++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java +@@ -32,6 +_,17 @@ + return false; + } + ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(body, targetEntity, (targetEntity instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); ++ if (event.isCancelled()) { ++ return false; ++ } ++ if (event.getTarget() == null) { ++ attackTarget.erase(); ++ return true; ++ } ++ targetEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); ++ // CraftBukkit end + attackTarget.set(targetEntity); + cantReachSince.erase(); + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch new file mode 100644 index 000000000000..daad4f2a12d8 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java ++++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java +@@ -329,7 +_,10 @@ + + boolean isValidTarget = this.isWantedBlock(body, transportItemTarget.state) + && !this.isPositionAlreadyVisited(visitedPositions, unreachablePositions, transportItemTarget, level) +- && !this.isContainerLocked(transportItemTarget); ++ // Paper start - ItemTransportingEntityValidateTargetEvent ++ && !this.isContainerLocked(transportItemTarget) ++ && org.bukkit.craftbukkit.event.CraftEventFactory.callTransporterValidateTarget(body, level, transportItemTarget.pos); ++ // Paper end - ItemTransportingEntityValidateTargetEvent + return isValidTarget ? transportItemTarget : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch new file mode 100644 index 000000000000..ff6ac4f071d5 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java ++++ b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java +@@ -112,11 +_,17 @@ + return Optional.empty(); + } + +- source.setAge(6000); +- target.setAge(6000); + child.setAge(-24000); ++ // Paper - Move age setting down + child.snapTo(source.getX(), source.getY(), source.getZ(), 0.0F, 0.0F); +- level.addFreshEntityWithPassengers(child); ++ // CraftBukkit start - call EntityBreedEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(child, source, target, null, null, 0).isCancelled()) { ++ return Optional.empty(); ++ } ++ source.setAge(6000); ++ target.setAge(6000); ++ level.addFreshEntityWithPassengers(child, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); ++ // CraftBukkit end - call EntityBreedEvent + level.broadcastEntityEvent(child, EntityEvent.LOVE_HEARTS); + return Optional.of(child); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch new file mode 100644 index 000000000000..45c3575962ca --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -0,0 +1,84 @@ +--- a/net/minecraft/world/level/block/BedBlock.java ++++ b/net/minecraft/world/level/block/BedBlock.java +@@ -92,7 +_,7 @@ + } + + BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); +- if (bedRule.explodes()) { ++ if (false && bedRule.explodes()) { // CraftBukkit - moved world and biome check into Player + bedRule.errorMessage().ifPresent(player::sendOverlayMessage); + level.removeBlock(pos, false); + BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); +@@ -104,20 +_,59 @@ + level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), null, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); + return InteractionResult.SUCCESS_SERVER; + } else if (state.getValue(OCCUPIED)) { ++ if (bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first + if (!this.kickVillagerOutOfBed(level, pos)) { + player.sendOverlayMessage(Component.translatable("block.minecraft.bed.occupied")); + } + + return InteractionResult.SUCCESS_SERVER; + } else { ++ // CraftBukkit start ++ final BlockState finalBlockState = state; ++ final BlockPos finalBlockPos = pos; ++ // CraftBukkit end + player.startSleepInBed(pos).ifLeft(problem -> { +- if (problem.message() != null) { ++ // Paper start - PlayerBedFailEnterEvent ++ if (false && problem.message() != null) { // Moved down + player.sendOverlayMessage(problem.message()); + } ++ if (problem != null) { ++ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, problem); ++ if (event.isCancelled()) { ++ return; ++ } ++ // Paper end - PlayerBedFailEnterEvent ++ // CraftBukkit start - handling bed explosion from below here ++ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent ++ this.explodeBed(finalBlockState, level, finalBlockPos); ++ } ++ // CraftBukkit end ++ // Paper start - PlayerBedFailEnterEvent ++ final net.kyori.adventure.text.Component message = event.getMessage(); ++ if (message != null) { ++ player.sendOverlayMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message)); ++ } ++ } ++ // Paper end - PlayerBedFailEnterEvent + }); + return InteractionResult.SUCCESS_SERVER; ++ } ++ } ++ ++ // CraftBukkit start - Copied from the above method ++ private InteractionResult explodeBed(BlockState state, Level level, BlockPos pos) { ++ org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos).getState(); // CraftBukkit - capture BlockState before remove block ++ level.removeBlock(pos, false); ++ BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); ++ if (level.getBlockState(blockPos).is(this)) { ++ level.removeBlock(blockPos, false); + } ++ ++ Vec3 center = pos.getCenter(); ++ level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ return InteractionResult.SUCCESS_SERVER; + } ++ // CraftBukkit end + + private boolean kickVillagerOutOfBed(final Level level, final BlockPos pos) { + List villagers = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); +@@ -298,6 +_,11 @@ + if (!level.isClientSide()) { + BlockPos otherPos = pos.relative(state.getValue(FACING)); + level.setBlock(otherPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); ++ // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states ++ if (level.captureBlockStates) { ++ return; ++ } ++ // CraftBukkit end + level.updateNeighborsAt(pos, Blocks.AIR); + state.updateNeighbourShapes(level, pos, Block.UPDATE_ALL); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch new file mode 100644 index 000000000000..0ccf56fb4699 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/level/block/CakeBlock.java ++++ b/net/minecraft/world/level/block/CakeBlock.java +@@ -63,6 +_,12 @@ + ) { + Item item = itemStack.getItem(); + if (itemStack.is(ItemTags.CANDLES) && state.getValue(BITES) == 0 && Block.byItem(item) instanceof CandleBlock candleBlock) { ++ // Paper start - call change block event ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, CandleCakeBlock.byCandle(candleBlock))) { ++ player.containerMenu.forceHeldSlot(hand); // update inv because candle could decrease ++ return InteractionResult.TRY_WITH_EMPTY_HAND; ++ } ++ // Paper end - call change block event + itemStack.consume(1, player); + level.playSound(null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); + level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(candleBlock)); +@@ -96,9 +_,28 @@ + return InteractionResult.PASS; + } + ++ // Paper start - call change block event ++ int bites = state.getValue(CakeBlock.BITES); ++ final BlockState newState = bites < MAX_BITES ? state.setValue(CakeBlock.BITES, bites + 1) : level.getFluidState(pos).createLegacyBlock(); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) { ++ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate(); ++ return InteractionResult.PASS; // return a non-consume result to cake blocks don't drop their candles ++ } ++ // Paper end - call change block event + player.awardStat(Stats.EAT_CAKE_SLICE); +- player.getFoodData().eat(2, 0.1F); +- int bites = state.getValue(BITES); ++ // CraftBukkit start ++ // player.getFoodData().eat(2, 0.1F); ++ // int bites = state.getValue(BITES); // Paper - move up ++ int oldFoodLevel = player.getFoodData().foodLevel; ++ ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel); ++ ++ if (!event.isCancelled()) { ++ player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); ++ } ++ ++ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate(); ++ // CraftBukkit end + level.gameEvent(player, GameEvent.EAT, pos); + if (bites < 6) { + level.setBlock(pos, state.setValue(BITES, bites + 1), Block.UPDATE_ALL); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch similarity index 59% rename from paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch index 936135243418..e73773c04e7a 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch @@ -1,21 +1,12 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/CopperGolemStatueBlock.java b/net/minecraft/world/level/block/CopperGolemStatueBlock.java -index 61549c4877a857411f49cdb0254711421dbf0b35..9c36eee7798f0a9a60041ac7691e50001c9f42ea 100644 --- a/net/minecraft/world/level/block/CopperGolemStatueBlock.java +++ b/net/minecraft/world/level/block/CopperGolemStatueBlock.java -@@ -111,15 +111,21 @@ public class CopperGolemStatueBlock extends BaseEntityBlock implements SimpleWat - if (itemStack.is(ItemTags.AXES)) { +@@ -112,14 +_,20 @@ return InteractionResult.PASS; - } else { -- this.updatePose(level, state, pos, player); -- return InteractionResult.SUCCESS; -+ return this.updatePose(level, state, pos, player); // Paper - call EntityChangeBlockEvent } + +- this.updatePose(level, state, pos, player); +- return InteractionResult.SUCCESS; ++ return this.updatePose(level, state, pos, player); // Paper - call EntityChangeBlockEvent } - void updatePose(final Level level, final BlockState state, final BlockPos pos, final Player player) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch similarity index 51% rename from paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch index 50355c315828..534608725b49 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/MushroomBlock.java b/net/minecraft/world/level/block/MushroomBlock.java -index 5d482a8df571566f8f46731db81185dba51af608..dd736330ddb1457172774dbcdcffd101f60903ce 100644 --- a/net/minecraft/world/level/block/MushroomBlock.java +++ b/net/minecraft/world/level/block/MushroomBlock.java -@@ -46,7 +46,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock +@@ -46,7 +_,7 @@ @Override protected void randomTick(final BlockState state, final ServerLevel level, BlockPos pos, final RandomSource random) { @@ -17,7 +9,7 @@ index 5d482a8df571566f8f46731db81185dba51af608..dd736330ddb1457172774dbcdcffd101 int max = 5; int r = 4; -@@ -59,6 +59,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock +@@ -59,6 +_,7 @@ } BlockPos offset = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); @@ -25,7 +17,7 @@ index 5d482a8df571566f8f46731db81185dba51af608..dd736330ddb1457172774dbcdcffd101 for (int i = 0; i < 4; i++) { if (level.isEmptyBlock(offset) && state.canSurvive(level, offset)) { -@@ -69,7 +70,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock +@@ -69,7 +_,7 @@ } if (level.isEmptyBlock(offset) && state.canSurvive(level, offset)) { @@ -34,11 +26,11 @@ index 5d482a8df571566f8f46731db81185dba51af608..dd736330ddb1457172774dbcdcffd101 } } } -@@ -92,6 +93,7 @@ public class MushroomBlock extends VegetationBlock implements BonemealableBlock - return false; - } else { - level.removeBlock(pos, false); -+ SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? org.bukkit.TreeType.BROWN_MUSHROOM : org.bukkit.TreeType.RED_MUSHROOM; // CraftBukkit - if (feature.get().value().place(level, level.getChunkSource().getGenerator(), random, pos)) { - return true; - } else { +@@ -93,6 +_,7 @@ + } + + level.removeBlock(pos, false); ++ SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? org.bukkit.TreeType.BROWN_MUSHROOM : org.bukkit.TreeType.RED_MUSHROOM; // CraftBukkit + if (feature.get().value().place(level, level.getChunkSource().getGenerator(), random, pos)) { + return true; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch new file mode 100644 index 000000000000..5841077127de --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/level/block/RespawnAnchorBlock.java ++++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java +@@ -115,11 +_,16 @@ + LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false + ); + if (respawnConfig == null || !respawnConfig.isSamePosition(newRespawnConfig)) { +- serverPlayer.setRespawnPosition(newRespawnConfig, true); ++ if (serverPlayer.setRespawnPosition(newRespawnConfig, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent + serverLevel.playSound( + null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F + ); + return InteractionResult.SUCCESS_SERVER; ++ // Paper start - Add PlayerSetSpawnEvent ++ } else { ++ return InteractionResult.FAIL; ++ } ++ // Paper end - Add PlayerSetSpawnEvent + } + } + +@@ -157,6 +_,7 @@ + } + + private void explode(final BlockState state, final ServerLevel level, final BlockPos pos) { ++ org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos).getState(); // CraftBukkit - capture BlockState before remove block + level.removeBlock(pos, false); + boolean anyWaterNeighbors = Direction.Plane.HORIZONTAL.stream().map(pos::relative).anyMatch(neighborPos -> isWaterThatWouldFlow(neighborPos, level)); + final boolean inWater = anyWaterNeighbors || level.getFluidState(pos.above()).is(FluidTags.WATER); +@@ -171,7 +_,7 @@ + } + }; + Vec3 boomPos = pos.getCenter(); +- level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), damageCalculator, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); ++ level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos).causingBlockSnapshot(blockState), damageCalculator, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state + } + + public static boolean canSetSpawn(final ServerLevel level, final BlockPos pos) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch similarity index 70% rename from paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch index 05375b93ee74..31bbdbc5a6b0 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java -index 2d902d97fbbc9b18faea9a31c8093fbc659a7983..31f8b7225ae5804ed66e7b17862ee56ac6ae5237 100644 --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -119,10 +119,10 @@ public class TripWireHookBlock extends Block { +@@ -119,10 +_,10 @@ if (facingOptional.isPresent()) { Direction direction = facingOptional.get(); boolean wasAttached = state.getOptionalValue(ATTACHED).orElse(false); @@ -21,32 +13,33 @@ index 2d902d97fbbc9b18faea9a31c8093fbc659a7983..31f8b7225ae5804ed66e7b17862ee56a int receiverPos = 0; BlockState[] wireStates = new BlockState[42]; -@@ -158,8 +158,15 @@ public class TripWireHookBlock extends Block { +@@ -158,8 +_,15 @@ attached &= receiverPos > 1; powered &= attached; BlockState newState = block.defaultBlockState().trySetValue(ATTACHED, attached).trySetValue(POWERED, powered); + boolean cancelledEmitterHook = false, cancelledReceiverHook = false; // Paper - Call BlockRedstoneEvent if (receiverPos > 0) { - BlockPos testPosx = pos.relative(direction, receiverPos); + BlockPos testPos = pos.relative(direction, receiverPos); + // Paper start - Call BlockRedstoneEvent + if (wasPowered != powered) { -+ cancelledReceiverHook = !org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, testPosx, powered); ++ cancelledReceiverHook = !org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, testPos, powered); + } + if (!cancelledReceiverHook) { // always trigger two events even when the first hook current change is cancelled + // Paper end - Call BlockRedstoneEvent Direction opposite = direction.getOpposite(); - level.setBlock(testPosx, newState.setValue(FACING, opposite), Block.UPDATE_ALL); - notifyNeighbors(block, level, testPosx, opposite); -@@ -169,15 +176,24 @@ public class TripWireHookBlock extends Block { + level.setBlock(testPos, newState.setValue(FACING, opposite), Block.UPDATE_ALL); + notifyNeighbors(block, level, testPos, opposite); +@@ -169,15 +_,24 @@ } - emitState(level, testPosx, attached, powered, wasAttached, wasPowered); + emitState(level, testPos, attached, powered, wasAttached, wasPowered); +- } + } // Paper - Call BlockRedstoneEvent + } + // Paper start - Call BlockRedstoneEvent + if (wasPowered != powered) { + cancelledEmitterHook = !org.bukkit.craftbukkit.event.CraftEventFactory.callBinaryRedstoneChange(level, pos, powered); - } ++ } + // Paper end - Call BlockRedstoneEvent + if (!cancelledEmitterHook) { // Paper - Call BlockRedstoneEvent @@ -62,12 +55,12 @@ index 2d902d97fbbc9b18faea9a31c8093fbc659a7983..31f8b7225ae5804ed66e7b17862ee56a if (wasAttached != attached) { for (int i = 1; i < receiverPos; i++) { -@@ -186,7 +202,7 @@ public class TripWireHookBlock extends Block { +@@ -186,7 +_,7 @@ if (wireData != null) { - BlockState testPosState = level.getBlockState(testPosx); + BlockState testPosState = level.getBlockState(testPos); if (testPosState.is(Blocks.TRIPWIRE) || testPosState.is(Blocks.TRIPWIRE_HOOK)) { -- level.setBlock(testPosx, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !testPosState.is(Blocks.TRIPWIRE)) level.setBlock(testPosx, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); // Paper - prevent tripwire from updating +- level.setBlock(testPos, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !testPosState.is(Blocks.TRIPWIRE)) level.setBlock(testPos, wireData.trySetValue(ATTACHED, attached), Block.UPDATE_ALL); // Paper - prevent tripwire from updating } } } From 5325be7629c8f5682be67f0799cb110e0f1bfcea Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 19:07:49 +0100 Subject: [PATCH 04/16] 30 --- .../AssignProfessionFromJobSite.java.patch | 26 -- .../entity/ai/behavior/SleepInBed.java.patch | 20 -- .../world/item/ArmorStandItem.java.patch | 23 -- .../minecraft/world/item/BoatItem.java.patch | 50 --- .../minecraft/world/item/BowItem.java.patch | 19 -- .../world/item/EndCrystalItem.java.patch | 29 -- .../world/item/MinecartItem.java.patch | 25 -- .../AssignProfessionFromJobSite.java.patch | 18 ++ .../entity/ai/behavior/SleepInBed.java.patch | 12 + .../StopAttackingIfTargetInvalid.java.patch | 20 +- .../world/item/ArmorStandItem.java.patch | 15 + .../minecraft/world/item/BoatItem.java.patch | 42 +++ .../minecraft/world/item/BowItem.java.patch | 11 + .../world/item/CrossbowItem.java.patch | 22 +- .../world/item/EndCrystalItem.java.patch | 21 ++ .../minecraft/world/item/ItemStack.java.patch | 302 +++++++++--------- .../world/item/MinecartItem.java.patch | 17 + 17 files changed, 296 insertions(+), 376 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch (72%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/CrossbowItem.java.patch (79%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/ItemStack.java.patch (51%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch deleted file mode 100644 index 9345c31c1dfb..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java -index e807ef4a68dfca790fdede2d01d42d0510901852..d09583a108727f84a680f60ce511f8575b9a6be8 100644 ---- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java -+++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java -@@ -39,7 +39,14 @@ public class AssignProfessionFromJobSite { - .findFirst() - ) - .ifPresent(profession -> { -- body.setVillagerData(body.getVillagerData().withProfession(profession)); -+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed -+ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(body, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftHolderToBukkit(profession), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.EMPLOYED); -+ if (event.isCancelled()) { -+ return; -+ } -+ -+ body.setVillagerData(body.getVillagerData().withProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); -+ // CraftBukkit end - body.refreshBrain(level); - }); - return true; diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch deleted file mode 100644 index 9e720a86fd1c..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/SleepInBed.java b/net/minecraft/world/entity/ai/behavior/SleepInBed.java -index 1af1fedbf75741c0d4b2ead49fa7837f1d47ebdb..112572f5a6813abd3cf3bd26e2b087b7edb48f41 100644 ---- a/net/minecraft/world/entity/ai/behavior/SleepInBed.java -+++ b/net/minecraft/world/entity/ai/behavior/SleepInBed.java -@@ -55,7 +55,8 @@ public class SleepInBed extends Behavior { - } - } - -- BlockState blockState = level.getBlockState(target.pos()); -+ BlockState blockState = level.getBlockStateIfLoaded(target.pos()); // Paper - Prevent sync chunk loads when villagers try to find beds -+ if (blockState == null) { return false; } // Paper - Prevent sync chunk loads when villagers try to find beds - return target.pos().closerToCenterThan(body.position(), 2.0) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED); - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch deleted file mode 100644 index c5f7697237fb..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/ArmorStandItem.java.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java -index d671a17f3b76aa7fdf0b1f0d0640b74cd6868ff2..4b4cc75640cc567a74c99ec8653436b2f2a50df6 100644 ---- a/net/minecraft/world/item/ArmorStandItem.java -+++ b/net/minecraft/world/item/ArmorStandItem.java -@@ -45,6 +45,12 @@ public class ArmorStandItem extends Item { - - float yRot = Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; - entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), yRot, 0.0F); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, entity).isCancelled()) { -+ if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - serverLevel.addFreshEntityWithPassengers(entity); - level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); - entity.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer()); diff --git a/paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch deleted file mode 100644 index c1ea337e483a..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/BoatItem.java.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java -index 3147e06c79fdaecf444574eb7b52b407012a437d..cd7f38ab2553062dcd003bd6f758e4aba77051ea 100644 ---- a/net/minecraft/world/item/BoatItem.java -+++ b/net/minecraft/world/item/BoatItem.java -@@ -30,7 +30,7 @@ public class BoatItem extends Item { - @Override - public InteractionResult use(final Level level, final Player player, final InteractionHand hand) { - ItemStack itemStack = player.getItemInHand(hand); -- HitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); -+ net.minecraft.world.phys.BlockHitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); // Paper - if (hitResult.getType() == HitResult.Type.MISS) { - return InteractionResult.PASS; - } else { -@@ -51,6 +51,13 @@ public class BoatItem extends Item { - } - - if (hitResult.getType() == HitResult.Type.BLOCK) { -+ // CraftBukkit start - Boat placement -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, hitResult.getBlockPos(), hitResult.getDirection(), itemStack, false, hand, hitResult.getLocation()); -+ -+ if (event.isCancelled()) { -+ return InteractionResult.PASS; -+ } -+ // CraftBukkit end - AbstractBoat boat = this.getBoat(level, hitResult, itemStack, player); - if (boat == null) { - return InteractionResult.FAIL; -@@ -60,7 +67,15 @@ public class BoatItem extends Item { - return InteractionResult.FAIL; - } else { - if (!level.isClientSide()) { -- level.addFreshEntity(boat); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(level, hitResult.getBlockPos(), player.getDirection(), player, boat, hand).isCancelled()) { -+ return InteractionResult.FAIL; -+ } -+ -+ if (!level.addFreshEntity(boat)) { -+ return InteractionResult.PASS; -+ } -+ // CraftBukkit end - level.gameEvent(player, GameEvent.ENTITY_PLACE, hitResult.getLocation()); - itemStack.consume(1, player); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch deleted file mode 100644 index 8a8ce83c6b4a..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/BowItem.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/BowItem.java b/net/minecraft/world/item/BowItem.java -index bdc5303cbc2b22f6e32e4122edb5058ef4d5609b..f158f8f372b14066c4bc252611a01c276982c7ac 100644 ---- a/net/minecraft/world/item/BowItem.java -+++ b/net/minecraft/world/item/BowItem.java -@@ -38,7 +38,7 @@ public class BowItem extends ProjectileWeaponItem { - } else { - List firedProjectiles = draw(itemStack, projectile, player); - if (level instanceof ServerLevel serverLevel && !firedProjectiles.isEmpty()) { -- this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null); -+ this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null, pow); // Paper - Pass draw strength - } - - level.playSound( diff --git a/paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch deleted file mode 100644 index 4716a826a7a5..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/EndCrystalItem.java.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/EndCrystalItem.java b/net/minecraft/world/item/EndCrystalItem.java -index 3024444b2df4dfcc37d260fdbdc12757dd0533e3..1eca60c5a3e1eeb6f44edbb81fe1af011edd8732 100644 ---- a/net/minecraft/world/item/EndCrystalItem.java -+++ b/net/minecraft/world/item/EndCrystalItem.java -@@ -41,11 +41,17 @@ public class EndCrystalItem extends Item { - if (level instanceof ServerLevel) { - EndCrystal crystal = new EndCrystal(level, x + 0.5, y, z + 0.5); - crystal.setShowBottom(false); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, crystal).isCancelled()) { -+ if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - level.addFreshEntity(crystal); - level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, above); - EnderDragonFight fight = ((ServerLevel)level).getDragonFight(); - if (fight != null) { -- fight.tryRespawn(); -+ fight.tryRespawn(above); // Paper - Perf: Do crystal-portal proximity check before entity lookup - } - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch deleted file mode 100644 index a3be182714ae..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/MinecartItem.java.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/MinecartItem.java b/net/minecraft/world/item/MinecartItem.java -index 47fc97b7949016e54111bca6ee4be7c8d28bf935..7464dbde8cc3348748d2a3733624bd2274f9c735 100644 ---- a/net/minecraft/world/item/MinecartItem.java -+++ b/net/minecraft/world/item/MinecartItem.java -@@ -57,7 +57,13 @@ public class MinecartItem extends Item { - } - - if (level instanceof ServerLevel serverLevel) { -- serverLevel.addFreshEntity(cart); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, cart).isCancelled()) { -+ if (context.getPlayer() != null) context.getPlayer().containerMenu.forceHeldSlot(context.getHand()); // Paper - Fix inventory desync -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end -+ if (!serverLevel.addFreshEntity(cart)) return InteractionResult.PASS; // CraftBukkit - serverLevel.gameEvent(GameEvent.ENTITY_PLACE, pos, GameEvent.Context.of(context.getPlayer(), serverLevel.getBlockState(pos.below()))); - } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch new file mode 100644 index 000000000000..481256ff5b4f --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java ++++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java +@@ -41,7 +_,14 @@ + .findFirst() + ) + .ifPresent(profession -> { +- body.setVillagerData(body.getVillagerData().withProfession(profession)); ++ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed ++ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(body, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftHolderToBukkit(profession), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.EMPLOYED); ++ if (event.isCancelled()) { ++ return; ++ } ++ ++ body.setVillagerData(body.getVillagerData().withProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); ++ // CraftBukkit end + body.refreshBrain(level); + }); + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch new file mode 100644 index 000000000000..f5a503d39e59 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/entity/ai/behavior/SleepInBed.java ++++ b/net/minecraft/world/entity/ai/behavior/SleepInBed.java +@@ -57,7 +_,8 @@ + } + } + +- BlockState blockState = level.getBlockState(target.pos()); ++ BlockState blockState = level.getBlockStateIfLoaded(target.pos()); // Paper - Prevent sync chunk loads when villagers try to find beds ++ if (blockState == null) { return false; } // Paper - Prevent sync chunk loads when villagers try to find beds + return target.pos().closerToCenterThan(body.position(), 2.0) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED); + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch similarity index 72% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch index 6ae47f4c5b7c..8b6e1cb9e9ad 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java.patch @@ -1,17 +1,9 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java b/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java -index 1dde3a2dd288b038107814900305d37434392a3f..f21e21a6a70b1f7409d350d157c457b06b17a00e 100644 --- a/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java +++ b/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java -@@ -40,6 +40,30 @@ public class StopAttackingIfTargetInvalid { - && !stopAttackingWhen.test(level, target)) { +@@ -41,6 +_,30 @@ return true; - } else { + } + + // Paper start - better track target change reason + final org.bukkit.event.entity.EntityTargetEvent.TargetReason reason; + if (!body.canAttack(target)) { @@ -36,6 +28,6 @@ index 1dde3a2dd288b038107814900305d37434392a3f..f21e21a6a70b1f7409d350d157c457b0 + return true; + } + // CraftBukkit end - onTargetErased.accept(level, body, target); - attackTarget.erase(); - return true; + onTargetErased.accept(level, body, target); + attackTarget.erase(); + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch new file mode 100644 index 000000000000..88f4f50a083c --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/item/ArmorStandItem.java ++++ b/net/minecraft/world/item/ArmorStandItem.java +@@ -46,6 +_,12 @@ + + float yRot = Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; + entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), yRot, 0.0F); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, entity).isCancelled()) { ++ if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end + serverLevel.addFreshEntityWithPassengers(entity); + level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); + entity.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer()); diff --git a/paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch new file mode 100644 index 000000000000..755218427a59 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/BoatItem.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/world/item/BoatItem.java ++++ b/net/minecraft/world/item/BoatItem.java +@@ -30,7 +_,7 @@ + @Override + public InteractionResult use(final Level level, final Player player, final InteractionHand hand) { + ItemStack itemStack = player.getItemInHand(hand); +- HitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); ++ net.minecraft.world.phys.BlockHitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); // Paper + if (hitResult.getType() == HitResult.Type.MISS) { + return InteractionResult.PASS; + } +@@ -52,6 +_,13 @@ + } + + if (hitResult.getType() == HitResult.Type.BLOCK) { ++ // CraftBukkit start - Boat placement ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, hitResult.getBlockPos(), hitResult.getDirection(), itemStack, false, hand, hitResult.getLocation()); ++ ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; ++ } ++ // CraftBukkit end + AbstractBoat boat = this.getBoat(level, hitResult, itemStack, player); + if (boat == null) { + return InteractionResult.FAIL; +@@ -63,7 +_,15 @@ + } + + if (!level.isClientSide()) { +- level.addFreshEntity(boat); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(level, hitResult.getBlockPos(), player.getDirection(), player, boat, hand).isCancelled()) { ++ return InteractionResult.FAIL; ++ } ++ ++ if (!level.addFreshEntity(boat)) { ++ return InteractionResult.PASS; ++ } ++ // CraftBukkit end + level.gameEvent(player, GameEvent.ENTITY_PLACE, hitResult.getLocation()); + itemStack.consume(1, player); + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch new file mode 100644 index 000000000000..739a4d4d0079 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/BowItem.java ++++ b/net/minecraft/world/item/BowItem.java +@@ -40,7 +_,7 @@ + + List firedProjectiles = draw(itemStack, projectile, player); + if (level instanceof ServerLevel serverLevel && !firedProjectiles.isEmpty()) { +- this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null); ++ this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null, pow); // Paper - Pass draw strength + } + + level.playSound( diff --git a/paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch index b69d834479e6..96811e2e44cd 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/CrossbowItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/CrossbowItem.java b/net/minecraft/world/item/CrossbowItem.java -index 7a9348c84e5ef8824dfe94f3f64d3f9c2181e800..aee675f9e2bf71ad768c000da477558588b04292 100644 --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -88,8 +88,15 @@ public class CrossbowItem extends ProjectileWeaponItem { +@@ -88,8 +_,15 @@ return getPowerForTime(timeHeld, itemStack, entity) >= 1.0F && isCharged(itemStack); } @@ -25,7 +17,7 @@ index 7a9348c84e5ef8824dfe94f3f64d3f9c2181e800..aee675f9e2bf71ad768c000da4775585 if (!drawn.isEmpty()) { heldItem.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.ofNonEmpty(drawn)); return true; -@@ -159,7 +166,11 @@ public class CrossbowItem extends ProjectileWeaponItem { +@@ -159,7 +_,11 @@ final Level level, final LivingEntity shooter, final ItemStack heldItem, final ItemStack projectile, final boolean isCrit ) { if (projectile.is(Items.FIREWORK_ROCKET)) { @@ -35,10 +27,10 @@ index 7a9348c84e5ef8824dfe94f3f64d3f9c2181e800..aee675f9e2bf71ad768c000da4775585 + entity.spawningEntity = shooter.getUUID(); // Paper + return entity; + // Paper end - } else { - Projectile projectileEntity = super.createProjectile(level, shooter, heldItem, projectile, isCrit); - if (projectileEntity instanceof AbstractArrow arrow) { -@@ -187,7 +198,7 @@ public class CrossbowItem extends ProjectileWeaponItem { + } + + Projectile projectileEntity = super.createProjectile(level, shooter, heldItem, projectile, isCrit); +@@ -187,7 +_,7 @@ if (level instanceof ServerLevel serverLevel) { ChargedProjectiles charged = weapon.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.EMPTY); if (charged != null && !charged.isEmpty()) { @@ -47,7 +39,7 @@ index 7a9348c84e5ef8824dfe94f3f64d3f9c2181e800..aee675f9e2bf71ad768c000da4775585 if (shooter instanceof ServerPlayer player) { CriteriaTriggers.SHOT_CROSSBOW.trigger(player, weapon); player.awardStat(Stats.ITEM_USED.get(weapon.getItem())); -@@ -227,7 +238,13 @@ public class CrossbowItem extends ProjectileWeaponItem { +@@ -227,7 +_,13 @@ .ifPresent(sound -> level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound.value(), SoundSource.PLAYERS, 0.5F, 1.0F)); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch new file mode 100644 index 000000000000..b26965ea3b7d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/item/EndCrystalItem.java ++++ b/net/minecraft/world/item/EndCrystalItem.java +@@ -44,11 +_,17 @@ + if (level instanceof ServerLevel) { + EndCrystal crystal = new EndCrystal(level, x + 0.5, y, z + 0.5); + crystal.setShowBottom(false); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, crystal).isCancelled()) { ++ if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end + level.addFreshEntity(crystal); + level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, above); + EnderDragonFight fight = ((ServerLevel)level).getDragonFight(); + if (fight != null) { +- fight.tryRespawn(); ++ fight.tryRespawn(above); // Paper - Perf: Do crystal-portal proximity check before entity lookup + } + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch similarity index 51% rename from paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index 0a1de049b227..e3f537d542d7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a2ac968f0 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -187,12 +187,20 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -187,12 +_,20 @@ @Override public void encode(final RegistryFriendlyByteBuf output, final ItemStack itemStack) { @@ -31,7 +23,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a } } }; -@@ -204,7 +212,7 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -204,7 +_,7 @@ public ItemStack decode(final RegistryFriendlyByteBuf input) { ItemStack itemStack = codec.decode(input); if (!itemStack.isEmpty()) { @@ -40,175 +32,175 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -368,10 +376,165 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { - return InteractionResult.PASS; - } else { - Item usedItem = this.getItem(); -- InteractionResult result = usedItem.useOn(context); -+ // CraftBukkit start - handle all block place event logic here -+ DataComponentPatch previousPatch = this.components.asPatch(); -+ int previousCount = this.getCount(); -+ ServerLevel level = (ServerLevel) context.getLevel(); -+ boolean isBonemeal = usedItem == Items.BONE_MEAL; +@@ -369,10 +_,165 @@ + } + + Item usedItem = this.getItem(); +- InteractionResult result = usedItem.useOn(context); ++ // CraftBukkit start - handle all block place event logic here ++ DataComponentPatch previousPatch = this.components.asPatch(); ++ int previousCount = this.getCount(); ++ ServerLevel level = (ServerLevel) context.getLevel(); ++ boolean isBonemeal = usedItem == Items.BONE_MEAL; + -+ if (!(usedItem instanceof BucketItem)) { -+ level.captureBlockStates = true; -+ if (isBonemeal) { -+ level.captureTreeGeneration = true; -+ } ++ if (!(usedItem instanceof BucketItem)) { ++ level.captureBlockStates = true; ++ if (isBonemeal) { ++ level.captureTreeGeneration = true; + } -+ InteractionResult result; -+ try { -+ result = usedItem.useOn(context); -+ } finally { -+ level.captureBlockStates = false; ++ } ++ InteractionResult result; ++ try { ++ result = usedItem.useOn(context); ++ } finally { ++ level.captureBlockStates = false; ++ } ++ DataComponentPatch newPatch = this.components.asPatch(); ++ int newCount = this.getCount(); ++ this.setCount(previousCount); ++ this.restorePatch(previousPatch); ++ if (result.consumesAction() && level.captureTreeGeneration && !level.capturedBlockStates.isEmpty()) { ++ level.captureTreeGeneration = false; ++ org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); ++ org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; ++ net.minecraft.world.level.block.SaplingBlock.treeType = null; ++ List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ level.capturedBlockStates.clear(); ++ org.bukkit.event.world.StructureGrowEvent structureEvent = null; ++ if (treeType != null) { ++ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, isBonemeal, (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + } -+ DataComponentPatch newPatch = this.components.asPatch(); -+ int newCount = this.getCount(); -+ this.setCount(previousCount); -+ this.restorePatch(previousPatch); -+ if (result.consumesAction() && level.captureTreeGeneration && !level.capturedBlockStates.isEmpty()) { -+ level.captureTreeGeneration = false; -+ org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); -+ org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; -+ net.minecraft.world.level.block.SaplingBlock.treeType = null; -+ List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); -+ level.capturedBlockStates.clear(); -+ org.bukkit.event.world.StructureGrowEvent structureEvent = null; -+ if (treeType != null) { -+ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, isBonemeal, (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) blocks); -+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); ++ ++ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) blocks); ++ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); ++ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); ++ ++ if (!fertilizeEvent.isCancelled()) { ++ // Change the stack to its new contents if it hasn't been tampered with. ++ if (this.getCount() == previousCount && Objects.equals(this.components.asPatch(), previousPatch)) { ++ this.restorePatch(newPatch); ++ this.setCount(newCount); ++ } ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : blocks) { ++ // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest ++ snapshot.place(snapshot.getFlags()); ++ level.checkCapturedTreeStateForObserverNotify(pos, snapshot); // Paper - notify observers even if grow failed + } ++ player.awardStat(Stats.ITEM_USED.get(usedItem)); // SPIGOT-7236 - award stat ++ } + -+ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) blocks); -+ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); -+ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); ++ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return ++ return result; ++ } ++ level.captureTreeGeneration = false; + if (player != null && result instanceof InteractionResult.Success success && success.wasItemInteraction()) { +- player.awardStat(Stats.ITEM_USED.get(usedItem)); ++ InteractionHand hand = context.getHand(); ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; ++ List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ level.capturedBlockStates.clear(); ++ if (blocks.size() > 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(level, player, hand, blocks, pos); ++ } else if (blocks.size() == 1 && usedItem != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(level, player, hand, blocks.getFirst(), pos); ++ } + -+ if (!fertilizeEvent.isCancelled()) { -+ // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.getCount() == previousCount && Objects.equals(this.components.asPatch(), previousPatch)) { -+ this.restorePatch(newPatch); -+ this.setCount(newCount); -+ } -+ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : blocks) { -+ // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest -+ snapshot.place(snapshot.getFlags()); -+ level.checkCapturedTreeStateForObserverNotify(pos, snapshot); // Paper - notify observers even if grow failed -+ } -+ player.awardStat(Stats.ITEM_USED.get(usedItem)); // SPIGOT-7236 - award stat ++ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { ++ result = InteractionResult.FAIL; // cancel placement ++ // PAIL: Remove this when MC-99075 fixed ++ player.containerMenu.forceHeldSlot(hand); ++ level.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot ++ // revert back all captured blocks ++ for (org.bukkit.block.BlockState blockstate : blocks) { ++ ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).revertPlace(); + } + + SignItem.openSign = null; // SPIGOT-6758 - Reset on early return -+ return result; -+ } -+ level.captureTreeGeneration = false; - if (player != null && result instanceof InteractionResult.Success success && success.wasItemInteraction()) { -- player.awardStat(Stats.ITEM_USED.get(usedItem)); -+ InteractionHand hand = context.getHand(); -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; -+ List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); -+ level.capturedBlockStates.clear(); -+ if (blocks.size() > 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(level, player, hand, blocks, pos); -+ } else if (blocks.size() == 1 && usedItem != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(level, player, hand, blocks.getFirst(), pos); ++ } else { ++ // Change the stack to its new contents if it hasn't been tampered with. ++ if (this.getCount() == previousCount && Objects.equals(this.components.asPatch(), previousPatch)) { ++ this.restorePatch(newPatch); ++ this.setCount(newCount); + } + -+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { -+ result = InteractionResult.FAIL; // cancel placement -+ // PAIL: Remove this when MC-99075 fixed -+ player.containerMenu.forceHeldSlot(hand); -+ level.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot -+ // revert back all captured blocks -+ for (org.bukkit.block.BlockState blockstate : blocks) { -+ ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).revertPlace(); -+ } ++ for (java.util.Map.Entry e : level.capturedTileEntities.entrySet()) { ++ level.setBlockEntity(e.getValue()); ++ } + -+ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return -+ } else { -+ // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.getCount() == previousCount && Objects.equals(this.components.asPatch(), previousPatch)) { -+ this.restorePatch(newPatch); -+ this.setCount(newCount); -+ } ++ for (org.bukkit.block.BlockState blockstate : blocks) { ++ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlags(); ++ net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getHandle(); ++ BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getPosition(); ++ net.minecraft.world.level.block.state.BlockState block = level.getBlockState(newPos); + -+ for (java.util.Map.Entry e : level.capturedTileEntities.entrySet()) { -+ level.setBlockEntity(e.getValue()); ++ if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically ++ block.onPlace(level, newPos, oldBlock, true, context); + } + -+ for (org.bukkit.block.BlockState blockstate : blocks) { -+ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlags(); -+ net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getHandle(); -+ BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getPosition(); -+ net.minecraft.world.level.block.state.BlockState block = level.getBlockState(newPos); ++ level.notifyAndUpdatePhysics(newPos, null, oldBlock, block, level.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point ++ } + -+ if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically -+ block.onPlace(level, newPos, oldBlock, true, context); ++ if (usedItem == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled ++ BlockPos bp = pos; ++ if (!level.getBlockState(pos).canBeReplaced()) { ++ if (!level.getBlockState(pos).isSolid()) { ++ bp = null; ++ } else { ++ bp = bp.relative(context.getClickedFace()); + } -+ -+ level.notifyAndUpdatePhysics(newPos, null, oldBlock, block, level.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point + } -+ -+ if (usedItem == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled -+ BlockPos bp = pos; -+ if (!level.getBlockState(pos).canBeReplaced()) { -+ if (!level.getBlockState(pos).isSolid()) { -+ bp = null; -+ } else { -+ bp = bp.relative(context.getClickedFace()); -+ } -+ } -+ if (bp != null) { -+ net.minecraft.world.level.block.entity.BlockEntity te = level.getBlockEntity(bp); -+ if (te instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { -+ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(level, bp, (net.minecraft.world.level.block.entity.SkullBlockEntity) te); -+ } ++ if (bp != null) { ++ net.minecraft.world.level.block.entity.BlockEntity te = level.getBlockEntity(bp); ++ if (te instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { ++ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(level, bp, (net.minecraft.world.level.block.entity.SkullBlockEntity) te); + } + } ++ } + -+ // SPIGOT-4678 -+ if (usedItem instanceof SignItem && SignItem.openSign != null) { -+ try { -+ if (level.getBlockEntity(SignItem.openSign) instanceof net.minecraft.world.level.block.entity.SignBlockEntity blockEntity) { -+ if (level.getBlockState(SignItem.openSign).getBlock() instanceof net.minecraft.world.level.block.SignBlock signBlock) { -+ signBlock.openTextEdit(player, blockEntity, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent -+ } ++ // SPIGOT-4678 ++ if (usedItem instanceof SignItem && SignItem.openSign != null) { ++ try { ++ if (level.getBlockEntity(SignItem.openSign) instanceof net.minecraft.world.level.block.entity.SignBlockEntity blockEntity) { ++ if (level.getBlockState(SignItem.openSign).getBlock() instanceof net.minecraft.world.level.block.SignBlock signBlock) { ++ signBlock.openTextEdit(player, blockEntity, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent + } -+ } finally { -+ SignItem.openSign = null; + } ++ } finally { ++ SignItem.openSign = null; + } ++ } + -+ // SPIGOT-7315: Moved from BedBlock#setPlacedBy -+ if (placeEvent != null && usedItem instanceof BedItem) { -+ BlockPos bedPos = ((org.bukkit.craftbukkit.block.CraftBlock) placeEvent.getBlock()).getPosition(); -+ net.minecraft.world.level.block.state.BlockState state = level.getBlockState(bedPos); -+ -+ if (state.getBlock() instanceof net.minecraft.world.level.block.BedBlock) { -+ level.updateNeighborsAt(bedPos, net.minecraft.world.level.block.Blocks.AIR); -+ state.updateNeighbourShapes(level, bedPos, net.minecraft.world.level.block.Block.UPDATE_ALL); -+ } -+ } ++ // SPIGOT-7315: Moved from BedBlock#setPlacedBy ++ if (placeEvent != null && usedItem instanceof BedItem) { ++ BlockPos bedPos = ((org.bukkit.craftbukkit.block.CraftBlock) placeEvent.getBlock()).getPosition(); ++ net.minecraft.world.level.block.state.BlockState state = level.getBlockState(bedPos); + -+ // SPIGOT-1288 - play sound stripped from BlockItem -+ if (usedItem instanceof BlockItem && success.paperSuccessContext().placedPos() != null) { -+ // Paper start - Fix spigot sound playing for BlockItem ItemStacks -+ net.minecraft.world.level.block.state.BlockState state = level.getBlockState(success.paperSuccessContext().placedPos()); -+ net.minecraft.world.level.block.SoundType soundType = state.getSoundType(); -+ // Paper end - Fix spigot sound playing for BlockItem ItemStacks -+ level.playSound(player, pos, soundType.getPlaceSound(), net.minecraft.sounds.SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); ++ if (state.getBlock() instanceof net.minecraft.world.level.block.BedBlock) { ++ level.updateNeighborsAt(bedPos, net.minecraft.world.level.block.Blocks.AIR); ++ state.updateNeighbourShapes(level, bedPos, net.minecraft.world.level.block.Block.UPDATE_ALL); + } ++ } + -+ player.awardStat(Stats.ITEM_USED.get(usedItem)); ++ // SPIGOT-1288 - play sound stripped from BlockItem ++ if (usedItem instanceof BlockItem && success.paperSuccessContext().placedPos() != null) { ++ // Paper start - Fix spigot sound playing for BlockItem ItemStacks ++ net.minecraft.world.level.block.state.BlockState state = level.getBlockState(success.paperSuccessContext().placedPos()); ++ net.minecraft.world.level.block.SoundType soundType = state.getSoundType(); ++ // Paper end - Fix spigot sound playing for BlockItem ItemStacks ++ level.playSound(player, pos, soundType.getPlaceSound(), net.minecraft.sounds.SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); + } - } -+ level.capturedTileEntities.clear(); -+ level.capturedBlockStates.clear(); -+ // CraftBukkit end - - return result; ++ ++ player.awardStat(Stats.ITEM_USED.get(usedItem)); ++ } } -@@ -448,31 +611,67 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { ++ level.capturedTileEntities.clear(); ++ level.capturedBlockStates.clear(); ++ // CraftBukkit end + + return result; + } +@@ -448,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -284,7 +276,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a this.shrink(1); onBreak.accept(item); } -@@ -485,7 +684,26 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -485,7 +_,26 @@ return; } @@ -312,7 +304,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a this.applyDamage(newDamage, serverPlayer, i -> {}); } } -@@ -495,9 +713,14 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -495,9 +_,14 @@ } public void hurtAndBreak(final int amount, final LivingEntity owner, final EquipmentSlot slot) { @@ -328,7 +320,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a ); } } -@@ -748,6 +971,12 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -756,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -341,7 +333,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a public @Nullable T set(final DataComponentType type, final @Nullable T value) { return this.components.set(type, value); } -@@ -791,6 +1020,28 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -799,6 +_,28 @@ this.components.setAll(components); } @@ -370,7 +362,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -1006,6 +1257,19 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -1014,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, slot, consumer); } @@ -390,7 +382,7 @@ index 80f8e43af6b8c06cdf6eec5d3041a51f18174bfc..9a07508097bbcf2fe22454823ce1655a public Component getDisplayName() { MutableComponent hoverName = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1070,7 +1334,7 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -1078,7 +_,7 @@ } public void consume(final int amount, final @Nullable LivingEntity owner) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch new file mode 100644 index 000000000000..490be6f004e7 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/MinecartItem.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/item/MinecartItem.java ++++ b/net/minecraft/world/item/MinecartItem.java +@@ -59,7 +_,13 @@ + } + + if (level instanceof ServerLevel serverLevel) { +- serverLevel.addFreshEntity(cart); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, cart).isCancelled()) { ++ if (context.getPlayer() != null) context.getPlayer().containerMenu.forceHeldSlot(context.getHand()); // Paper - Fix inventory desync ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end ++ if (!serverLevel.addFreshEntity(cart)) return InteractionResult.PASS; // CraftBukkit + serverLevel.gameEvent(GameEvent.ENTITY_PLACE, pos, GameEvent.Context.of(context.getPlayer(), serverLevel.getBlockState(pos.below()))); + } + From 26d6c3266e0c064876076359a3ff6e2cc0e96b02 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 19:27:36 +0100 Subject: [PATCH 05/16] 40 --- .../minecraft/world/item/AxeItem.java.patch | 22 ----- .../minecraft/world/item/BlockItem.java.patch | 97 ------------------ .../world/item/BucketItem.java.patch | 98 ------------------- .../world/item/EnderEyeItem.java.patch | 64 ------------ .../world/item/FireworkRocketItem.java.patch | 67 ------------- .../world/item/HangingEntityItem.java.patch | 31 ------ .../minecraft/world/item/LeadItem.java.patch | 61 ------------ .../world/item/ShovelItem.java.patch | 41 -------- .../world/item/SpawnEggItem.java.patch | 36 ------- .../minecraft/world/item/AxeItem.java.patch | 14 +++ .../minecraft/world/item/BlockItem.java.patch | 87 ++++++++++++++++ .../world/item/BucketItem.java.patch | 90 +++++++++++++++++ .../world/item/EnderEyeItem.java.patch | 56 +++++++++++ .../world/item/FireworkRocketItem.java.patch | 59 +++++++++++ .../world/item/HangingEntityItem.java.patch | 23 +++++ .../minecraft/world/item/LeadItem.java.patch | 54 ++++++++++ .../item/ProjectileWeaponItem.java.patch | 32 +++--- .../world/item/ShovelItem.java.patch | 33 +++++++ .../world/item/SpawnEggItem.java.patch | 28 ++++++ 19 files changed, 456 insertions(+), 537 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/ProjectileWeaponItem.java.patch (69%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch deleted file mode 100644 index 744e07733e84..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/AxeItem.java.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/AxeItem.java b/net/minecraft/world/item/AxeItem.java -index 8d5fbffd9fbb8be137ec70c34263f879bbf1a17c..8fef4d23fdc70471055b389f80aa5bee4a63ff60 100644 ---- a/net/minecraft/world/item/AxeItem.java -+++ b/net/minecraft/world/item/AxeItem.java -@@ -70,6 +70,11 @@ public class AxeItem extends Item { - return InteractionResult.PASS; - } else { - ItemStack itemInHand = context.getItemInHand(); -+ // Paper start - EntityChangeBlockEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newBlock.get())) { -+ return InteractionResult.PASS; -+ } -+ // Paper end - if (player instanceof ServerPlayer) { - CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, pos, itemInHand); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch deleted file mode 100644 index f128bae41332..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/BlockItem.java.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index acaf4d183b3a358d906ce87918cfdd2df19efaab..3167be4b7c2c61ef725af4a832d759ab6e061af0 100644 ---- a/net/minecraft/world/item/BlockItem.java -+++ b/net/minecraft/world/item/BlockItem.java -@@ -56,6 +56,7 @@ public class BlockItem extends Item { - return InteractionResult.FAIL; - } else { - BlockState placementState = this.getPlacementState(updatedPlaceContext); -+ final org.bukkit.block.BlockState previousState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(updatedPlaceContext.getLevel(), updatedPlaceContext.getClickedPos()); // Paper - Reset placed block on exception - if (placementState == null) { - return InteractionResult.FAIL; - } else if (!this.placeBlock(updatedPlaceContext, placementState)) { -@@ -68,21 +69,45 @@ public class BlockItem extends Item { - BlockState placedState = level.getBlockState(pos); - if (placedState.is(placementState.getBlock())) { - placedState = this.updateBlockStateFromTag(pos, level, itemStack, placedState); -+ // Paper start - Reset placed block on exception -+ try { - this.updateCustomBlockEntityTag(pos, level, player, itemStack, placedState); - updateBlockEntityComponents(level, pos, itemStack); -+ } catch (Exception ex) { -+ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(); -+ if (player instanceof ServerPlayer serverPlayer) { -+ net.minecraft.server.MinecraftServer.LOGGER.warn("Player {} tried placing invalid block", player.getScoreboardName(), ex); -+ serverPlayer.connection.disconnect(net.minecraft.network.chat.Component.literal("Packet processing error")); -+ return InteractionResult.FAIL; -+ } -+ throw ex; // Rethrow exception if not placed by a player -+ } -+ // Paper end - Reset placed block on exception - placedState.getBlock().setPlacedBy(level, pos, placedState, player, itemStack); -+ // CraftBukkit start - special case for handling block placement with water lilies, frog spawn and snow buckets -+ if (player != null && (this instanceof PlaceOnWaterBlockItem || this instanceof SolidBucketItem)) { -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, updatedPlaceContext.getHand(), previousState, pos); -+ if (placeEvent.isCancelled() || !placeEvent.canBuild()) { -+ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(); -+ -+ player.containerMenu.forceHeldSlot(updatedPlaceContext.getHand()); -+ return InteractionResult.FAIL; -+ } -+ } -+ // CraftBukkit end - if (player instanceof ServerPlayer) { - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, pos, itemStack); - } - } - - SoundType soundType = placedState.getSoundType(); -+ if (player == null) // Paper - Fix block place logic; reintroduce this for the dispenser (i.e the shulker) - level.playSound( - player, pos, this.getPlaceSound(placedState), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F - ); - level.gameEvent(GameEvent.BLOCK_PLACE, pos, GameEvent.Context.of(player, placedState)); - itemStack.consume(1, player); -- return InteractionResult.SUCCESS; -+ return InteractionResult.SUCCESS.configurePaper(e -> e.placedBlockAt(pos.immutable())); // Paper - track placed block position from block item - } - } - } -@@ -131,8 +156,20 @@ public class BlockItem extends Item { - - protected boolean canPlace(final BlockPlaceContext context, final BlockState stateForPlacement) { - Player player = context.getPlayer(); -- return (!this.mustSurvive() || stateForPlacement.canSurvive(context.getLevel(), context.getClickedPos())) -- && context.getLevel().isUnobstructed(stateForPlacement, context.getClickedPos(), CollisionContext.placementContext(player)); -+ // CraftBukkit start -+ Level world = context.getLevel(); // Paper - Cancel hit for vanished players -+ boolean canBuild = (!this.mustSurvive() || stateForPlacement.canSurvive(world, context.getClickedPos())) -+ && world.checkEntityCollision(stateForPlacement, player, CollisionContext.placementContext(player), context.getClickedPos(), true); // Paper - Cancel hit for vanished players -+ org.bukkit.entity.Player bukkitPlayer = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null; -+ -+ org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent( -+ org.bukkit.craftbukkit.block.CraftBlock.at(world, context.getClickedPos()), bukkitPlayer, -+ stateForPlacement.asBlockData(), canBuild, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()) -+ ); -+ world.getCraftServer().getPluginManager().callEvent(event); -+ -+ return event.isBuildable(); -+ // CraftBukkit end - } - - protected boolean mustSurvive() { -@@ -156,7 +193,7 @@ public class BlockItem extends Item { - return false; - } - -- if (!type.onlyOpCanSetNbt() || player != null && player.canUseGameMasterBlocks()) { -+ if (!type.onlyOpCanSetNbt() || player != null && (player.canUseGameMasterBlocks() || (player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.nbt.place")))) { // Spigot - add permission - return customData.loadInto(blockEntity, level.registryAccess()); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch deleted file mode 100644 index 81d80a730ad9..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/BucketItem.java.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/BucketItem.java b/net/minecraft/world/item/BucketItem.java -index 08c4e98fc4509afd1df06f36b3bfb5e8fb5d00c3..fbd666f3861a2a45b6ac55961543b1419c16ab9c 100644 ---- a/net/minecraft/world/item/BucketItem.java -+++ b/net/minecraft/world/item/BucketItem.java -@@ -32,6 +32,7 @@ import net.minecraft.world.phys.HitResult; - import org.jspecify.annotations.Nullable; - - public class BucketItem extends Item implements DispensibleContainerItem { -+ private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack - public final Fluid content; - - public BucketItem(final Fluid content, final Item.Properties properties) { -@@ -56,12 +57,22 @@ public class BucketItem extends Item implements DispensibleContainerItem { - } else if (this.content == Fluids.EMPTY) { - BlockState blockState = level.getBlockState(pos); - if (blockState.getBlock() instanceof BucketPickup bucketPickupBlock) { -+ // CraftBukkit start -+ ItemStack dummyFluid = bucketPickupBlock.pickupBlock(player, org.bukkit.craftbukkit.util.DummyLevelAccessor.INSTANCE, pos, blockState); -+ if (dummyFluid.isEmpty()) return InteractionResult.FAIL; // Don't fire event if the bucket won't be filled. -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, pos, pos, hitResult.getDirection(), itemStack, dummyFluid.getItem(), hand); -+ -+ if (event.isCancelled()) { -+ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - ItemStack taken = bucketPickupBlock.pickupBlock(player, level, pos, blockState); - if (!taken.isEmpty()) { - player.awardStat(Stats.ITEM_USED.get(this)); - bucketPickupBlock.getPickupSound().ifPresent(soundEvent -> player.playSound(soundEvent, 1.0F, 1.0F)); - level.gameEvent(player, GameEvent.FLUID_PICKUP, pos); -- ItemStack result = ItemUtils.createFilledResult(itemStack, player, taken); -+ ItemStack result = ItemUtils.createFilledResult(itemStack, player, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - if (!level.isClientSide()) { - CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, taken); - } -@@ -74,7 +85,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { - } else { - BlockState clicked = level.getBlockState(pos); - BlockPos placePos = clicked.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? pos : directionOffsetPos; -- if (this.emptyContents(player, level, placePos, hitResult)) { -+ if (this.emptyContents(player, level, placePos, hitResult, hitResult.getDirection(), pos, itemStack, hand)) { // CraftBukkit - this.checkExtraContent(player, level, itemStack, placePos); - if (player instanceof ServerPlayer) { - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, placePos, itemStack); -@@ -91,6 +102,13 @@ public class BucketItem extends Item implements DispensibleContainerItem { - } - - public static ItemStack getEmptySuccessItem(final ItemStack itemStack, final Player player) { -+ // Paper start - Fix PlayerBucketEmptyEvent result itemstack -+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) { -+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent; -+ itemLeftInHandAfterPlayerBucketEmptyEvent = null; -+ return itemInHand; -+ } -+ // Paper end - Fix PlayerBucketEmptyEvent result itemstack - return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : itemStack; - } - -@@ -100,6 +118,12 @@ public class BucketItem extends Item implements DispensibleContainerItem { - - @Override - public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { -+ // CraftBukkit start -+ return this.emptyContents(user, level, pos, hitResult, null, null, null, InteractionHand.MAIN_HAND); -+ } -+ -+ public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult, final Direction direction, final BlockPos clicked, final ItemStack itemStack, final InteractionHand hand) { -+ // CraftBukkit end - if (!(this.content instanceof FlowingFluid flowingFluid)) { - return false; - } else { -@@ -110,8 +134,18 @@ public class BucketItem extends Item implements DispensibleContainerItem { - boolean placeLiquid = mayReplace - || block instanceof LiquidBlockContainer container && container.canPlaceLiquid(user, level, pos, blockState, this.content); - boolean canPlaceFluidInsideBlock = blockState.isAir() || placeLiquid && (!shiftKeyDown || hitResult == null); -+ // CraftBukkit start -+ if (canPlaceFluidInsideBlock && user instanceof Player player) { -+ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent(level, player, pos, clicked, direction, itemStack, hand); -+ if (event.isCancelled()) { -+ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 -+ return false; -+ } -+ itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack() != null ? event.getItemStack().equals(org.bukkit.craftbukkit.inventory.CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; // Paper - Fix PlayerBucketEmptyEvent result itemstack -+ } -+ // CraftBukkit end - if (!canPlaceFluidInsideBlock) { -- return hitResult != null && this.emptyContents(user, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null); -+ return hitResult != null && this.emptyContents(user, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemStack, hand); // CraftBukkit - } else if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) { - int x = pos.getX(); - int y = pos.getY(); diff --git a/paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch deleted file mode 100644 index fc46fe615f8d..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/EnderEyeItem.java.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/EnderEyeItem.java b/net/minecraft/world/item/EnderEyeItem.java -index b8a091a417c0433cf85f4a556e1899e17be359fc..7f0486bfe2d8d82ec853b96868f72e32771c7e36 100644 ---- a/net/minecraft/world/item/EnderEyeItem.java -+++ b/net/minecraft/world/item/EnderEyeItem.java -@@ -44,6 +44,11 @@ public class EnderEyeItem extends Item { - return InteractionResult.SUCCESS; - } else { - BlockState newState = targetState.setValue(EndPortalFrameBlock.HAS_EYE, true); -+ // Paper start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), pos, newState)) { -+ return InteractionResult.PASS; -+ } -+ // Paper end - Block.pushEntitiesUp(targetState, newState, level, pos); - level.setBlock(pos, newState, Block.UPDATE_CLIENTS); - level.updateNeighbourForOutputSignal(pos, Blocks.END_PORTAL_FRAME); -@@ -61,7 +66,27 @@ public class EnderEyeItem extends Item { - } - } - -- level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); -+ // CraftBukkit start - Use relative location for far away sounds -+ // level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); -+ int viewDistance = level.getCraftServer().getViewDistance() * 16; -+ BlockPos soundPos = blockPos.offset(1, 0, 1); -+ final net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) level; // Paper - respect global sound events gamerule - ensured by isClientSide check above -+ for (ServerPlayer player : serverLevel.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule -+ double deltaX = soundPos.getX() - player.getX(); -+ double deltaZ = soundPos.getZ() - player.getZ(); -+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -+ final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule -+ if (!serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule -+ if (distanceSquared > viewDistance * viewDistance) { -+ double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; -+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(LevelEvent.SOUND_END_PORTAL_SPAWN, new BlockPos((int) relativeX, (int) soundPos.getY(), (int) relativeZ), 0, true)); -+ } else { -+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(LevelEvent.SOUND_END_PORTAL_SPAWN, soundPos, 0, true)); -+ } -+ } -+ // CraftBukkit end - } - - return InteractionResult.SUCCESS; -@@ -91,7 +116,11 @@ public class EnderEyeItem extends Item { - eyeOfEnder.setItem(itemStack); - eyeOfEnder.signalTo(Vec3.atLowerCornerOf(nearestMapFeature)); - level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); -- level.addFreshEntity(eyeOfEnder); -+ // CraftBukkit start -+ if (!level.addFreshEntity(eyeOfEnder)) { -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - if (player instanceof ServerPlayer serverPlayer) { - CriteriaTriggers.USED_ENDER_EYE.trigger(serverPlayer, nearestMapFeature); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch deleted file mode 100644 index 3813da901c7d..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/FireworkRocketItem.java.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/FireworkRocketItem.java b/net/minecraft/world/item/FireworkRocketItem.java -index b76e31894758d0fc6a24555886f5099608a40b72..0afc0916e358d4b9c9c360358a6c1aebe1ac723b 100644 ---- a/net/minecraft/world/item/FireworkRocketItem.java -+++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -36,7 +36,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem { - ItemStack itemStack = context.getItemInHand(); - Vec3 clickLocation = context.getClickLocation(); - Direction direction = context.getClickedFace(); -- Projectile.spawnProjectile( -+ final Projectile.Delayed fireworkRocketEntity = Projectile.spawnProjectileDelayed( // Paper - PlayerLaunchProjectileEvent - new FireworkRocketEntity( - level, - context.getPlayer(), -@@ -46,9 +46,14 @@ public class FireworkRocketItem extends Item implements ProjectileItem { - itemStack - ), - serverLevel, -- itemStack -+ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid - ); -- itemStack.shrink(1); -+ // Paper start - PlayerLaunchProjectileEvent -+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.projectile().getBukkitEntity()); -+ if (!event.callEvent() || !fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS; -+ if (event.shouldConsume() && !context.getPlayer().hasInfiniteMaterials()) itemStack.shrink(1); -+ else context.getPlayer().containerMenu.forceHeldSlot(context.getHand()); -+ // Paper end - PlayerLaunchProjectileEvent - } - - return InteractionResult.SUCCESS; -@@ -60,13 +65,24 @@ public class FireworkRocketItem extends Item implements ProjectileItem { - if (player.isFallFlying()) { - ItemStack itemStack = player.getItemInHand(hand); - if (level instanceof ServerLevel serverLevel) { -- if (player.dropAllLeashConnections(null)) { -- level.playSound(null, player, SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F); -+ // Paper start - PlayerElytraBoostEvent -+ final Projectile.Delayed delayed = Projectile.spawnProjectileDelayed(new FireworkRocketEntity(level, itemStack, player), serverLevel, itemStack, f -> f.spawningEntity = player.getUUID()); // Paper - firework api - assign spawning entity uuid -+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand)); -+ if (event.callEvent() && delayed.attemptSpawn()) { -+ player.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below -+ if (player.dropAllLeashConnections(player, hand)) { // Paper - PlayerUnleashEntityEvent -+ level.playSound(null, player, SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F); -+ } -+ if (event.shouldConsume() && !player.hasInfiniteMaterials()) { -+ itemStack.shrink(1); // Moved up from below -+ } else { -+ player.containerMenu.forceHeldSlot(hand); -+ } -+ } else { -+ player.containerMenu.forceHeldSlot(hand); - } -- -- Projectile.spawnProjectile(new FireworkRocketEntity(level, itemStack, player), serverLevel, itemStack); -- itemStack.consume(1, player); -- player.awardStat(Stats.ITEM_USED.get(this)); -+ // Moved up consume and changed consume to shrink -+ // Paper end - PlayerElytraBoostEvent - } - - return InteractionResult.SUCCESS; diff --git a/paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch deleted file mode 100644 index b1a2768ce2c0..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/HangingEntityItem.java.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java -index 17574ae594c802d4c5ddc84397a5951b3a131191..1e30fe428914c8ae4f6caf3cb5a05ced4e183393 100644 ---- a/net/minecraft/world/item/HangingEntityItem.java -+++ b/net/minecraft/world/item/HangingEntityItem.java -@@ -62,6 +62,20 @@ public class HangingEntityItem extends Item { - EntityType.createDefaultStackConfig(level, itemInHand, player).accept(entity); - if (entity.survives()) { - if (!level.isClientSide()) { -+ // CraftBukkit start - fire HangingPlaceEvent -+ org.bukkit.entity.Player bukkitPlayer = player == null ? null : (org.bukkit.entity.Player) player.getBukkitEntity(); -+ org.bukkit.block.Block blockClicked = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos); -+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace); -+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()); -+ -+ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) entity.getBukkitEntity(), bukkitPlayer, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemInHand)); -+ level.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ if (player != null) player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - entity.playPlacementSound(); - level.gameEvent(player, GameEvent.ENTITY_PLACE, entity.position()); - level.addFreshEntity(entity); diff --git a/paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch deleted file mode 100644 index 5de4f289d262..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/LeadItem.java.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/LeadItem.java b/net/minecraft/world/item/LeadItem.java -index 863cab9e42b794524f2b13a8d70921c47778b376..a95075d63500625578c8628e0437165a1e83eaed 100644 ---- a/net/minecraft/world/item/LeadItem.java -+++ b/net/minecraft/world/item/LeadItem.java -@@ -27,24 +27,36 @@ public class LeadItem extends Item { - if (state.is(BlockTags.FENCES)) { - Player player = context.getPlayer(); - if (!level.isClientSide() && player != null) { -- return bindPlayerMobs(player, level, pos); -+ return bindPlayerMobs(player, level, pos, context.getHand()); // CraftBukkit - Pass hand - } - } - - return InteractionResult.PASS; - } - -- public static InteractionResult bindPlayerMobs(final Player player, final Level level, final BlockPos pos) { -+ public static InteractionResult bindPlayerMobs(final Player player, final Level level, final BlockPos pos, final net.minecraft.world.InteractionHand hand) { // CraftBukkit - Add InteractionHand - List entitiesToLeash = Leashable.leashableInArea(level, Vec3.atCenterOf(pos), l -> l.getLeashHolder() == player); - if (entitiesToLeash.isEmpty()) { - return InteractionResult.PASS; - } else { - Optional existingKnot = LeashFenceKnotEntity.getKnot(level, pos); - LeashFenceKnotEntity activeKnot = existingKnot.orElseGet(() -> LeashFenceKnotEntity.createKnot(level, pos)); -+ // CraftBukkit start - fire HangingPlaceEvent -+ if (existingKnot.isEmpty()) { -+ org.bukkit.inventory.EquipmentSlot handSlot = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand); -+ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) activeKnot.getBukkitEntity(), player != null ? (org.bukkit.entity.Player) player.getBukkitEntity() : null, org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), org.bukkit.block.BlockFace.SELF, handSlot); -+ level.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ activeKnot.discard(); -+ return InteractionResult.PASS; -+ } -+ } -+ // CraftBukkit end - boolean anyLeashed = false; - - for (Leashable leashable : entitiesToLeash) { -- if (leashable.canHaveALeashAttachedTo(activeKnot)) { -+ if (leashable.canHaveALeashAttachedTo(activeKnot) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(leashable, activeKnot, player, hand)) { // Paper - leash event - leashable.setLeashedTo(activeKnot, true); - anyLeashed = true; - } -@@ -63,4 +75,10 @@ public class LeadItem extends Item { - } - } - } -+ -+ // CraftBukkit start -+ public static InteractionResult bindPlayerMobs(Player player, Level world, BlockPos pos) { -+ return LeadItem.bindPlayerMobs(player, world, pos, net.minecraft.world.InteractionHand.MAIN_HAND); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch deleted file mode 100644 index d17e2fbd2a46..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/ShovelItem.java.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/ShovelItem.java b/net/minecraft/world/item/ShovelItem.java -index b0a4b124bfd5abc8c287a2f502d7935bc8ee0365..97c09033fb49156ff8743511bcfe65a54afe50c7 100644 ---- a/net/minecraft/world/item/ShovelItem.java -+++ b/net/minecraft/world/item/ShovelItem.java -@@ -45,20 +45,29 @@ public class ShovelItem extends Item { - Player player = context.getPlayer(); - BlockState newState = FLATTENABLES.get(blockState.getBlock()); - BlockState updatedState = null; -+ Runnable afterAction = null; // Paper - if (newState != null && level.getBlockState(pos.above()).isAir()) { -- level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); -+ afterAction = () -> level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper - updatedState = newState; - } else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) { -+ afterAction = () -> { // Paper - if (!level.isClientSide()) { - level.levelEvent(null, LevelEvent.SOUND_EXTINGUISH_FIRE, pos, 0); - } - - CampfireBlock.dowse(context.getPlayer(), level, pos, blockState); -+ }; // Paper - updatedState = blockState.setValue(CampfireBlock.LIT, false); - } - - if (updatedState != null) { - if (!level.isClientSide()) { -+ // Paper start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), pos, updatedState)) { -+ return InteractionResult.PASS; -+ } -+ afterAction.run(); -+ // Paper end - level.setBlock(pos, updatedState, Block.UPDATE_ALL_IMMEDIATE); - level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, updatedState)); - if (player != null) { diff --git a/paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch deleted file mode 100644 index eb7d7d4a4931..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/SpawnEggItem.java.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/SpawnEggItem.java b/net/minecraft/world/item/SpawnEggItem.java -index 03087f5ea22c01376a7855556f471dcb9be7308a..d78965a0adebeb0172447bdec3fd019fdacc1a5d 100644 ---- a/net/minecraft/world/item/SpawnEggItem.java -+++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -61,6 +61,7 @@ public class SpawnEggItem extends Item { - - return InteractionResult.FAIL; - } else { -+ if (level.paperConfig().entities.spawning.disableMobSpawnerSpawnEggTransformation) return InteractionResult.FAIL; // Paper - Allow disabling mob spawner spawn egg transformation - spawnerHolder.setEntityId(type, level.getRandom()); - level.sendBlockUpdated(pos, blockState, blockState, Block.UPDATE_ALL); - level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, pos); -@@ -91,7 +92,7 @@ public class SpawnEggItem extends Item { - EntityType type = getType(itemStack); - if (type == null) { - return InteractionResult.FAIL; -- } else if (!type.isAllowedInPeaceful() && level.getDifficulty() == Difficulty.PEACEFUL) { -+ } else if (!type.isAllowedInPeaceful(itemStack.get(DataComponents.ENTITY_DATA).getUnsafe()) && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - check peaceful override - return InteractionResult.FAIL; - } else { - if (type.spawn((ServerLevel)level, itemStack, user, spawnPos, EntitySpawnReason.SPAWN_ITEM_USE, tryMoveDown, movedUp) != null) { -@@ -163,7 +164,7 @@ public class SpawnEggItem extends Item { - } else { - offspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); - offspring.applyComponentsFromItemStack(spawnEggStack); -- level.addFreshEntityWithPassengers(offspring); -+ level.addFreshEntityWithPassengers(offspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - spawnEggStack.consume(1, player); - return Optional.of(offspring); - } diff --git a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch new file mode 100644 index 000000000000..832a16a44bcf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/item/AxeItem.java ++++ b/net/minecraft/world/item/AxeItem.java +@@ -72,6 +_,11 @@ + } + + ItemStack itemInHand = context.getItemInHand(); ++ // Paper start - EntityChangeBlockEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newBlock.get())) { ++ return InteractionResult.PASS; ++ } ++ // Paper end + if (player instanceof ServerPlayer) { + CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, pos, itemInHand); + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch new file mode 100644 index 000000000000..23859e38c217 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -0,0 +1,87 @@ +--- a/net/minecraft/world/item/BlockItem.java ++++ b/net/minecraft/world/item/BlockItem.java +@@ -60,6 +_,7 @@ + } + + BlockState placementState = this.getPlacementState(updatedPlaceContext); ++ final org.bukkit.block.BlockState previousState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(updatedPlaceContext.getLevel(), updatedPlaceContext.getClickedPos()); // Paper - Reset placed block on exception + if (placementState == null) { + return InteractionResult.FAIL; + } +@@ -75,19 +_,43 @@ + BlockState placedState = level.getBlockState(pos); + if (placedState.is(placementState.getBlock())) { + placedState = this.updateBlockStateFromTag(pos, level, itemStack, placedState); ++ // Paper start - Reset placed block on exception ++ try { + this.updateCustomBlockEntityTag(pos, level, player, itemStack, placedState); + updateBlockEntityComponents(level, pos, itemStack); ++ } catch (Exception ex) { ++ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(); ++ if (player instanceof ServerPlayer serverPlayer) { ++ net.minecraft.server.MinecraftServer.LOGGER.warn("Player {} tried placing invalid block", player.getScoreboardName(), ex); ++ serverPlayer.connection.disconnect(net.minecraft.network.chat.Component.literal("Packet processing error")); ++ return InteractionResult.FAIL; ++ } ++ throw ex; // Rethrow exception if not placed by a player ++ } ++ // Paper end - Reset placed block on exception + placedState.getBlock().setPlacedBy(level, pos, placedState, player, itemStack); ++ // CraftBukkit start - special case for handling block placement with water lilies, frog spawn and snow buckets ++ if (player != null && (this instanceof PlaceOnWaterBlockItem || this instanceof SolidBucketItem)) { ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, updatedPlaceContext.getHand(), previousState, pos); ++ if (placeEvent.isCancelled() || !placeEvent.canBuild()) { ++ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(); ++ ++ player.containerMenu.forceHeldSlot(updatedPlaceContext.getHand()); ++ return InteractionResult.FAIL; ++ } ++ } ++ // CraftBukkit end + if (player instanceof ServerPlayer) { + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, pos, itemStack); + } + } + + SoundType soundType = placedState.getSoundType(); ++ if (player == null) // Paper - Fix block place logic; reintroduce this for the dispenser (i.e the shulker) + level.playSound(player, pos, this.getPlaceSound(placedState), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); + level.gameEvent(GameEvent.BLOCK_PLACE, pos, GameEvent.Context.of(player, placedState)); + itemStack.consume(1, player); +- return InteractionResult.SUCCESS; ++ return InteractionResult.SUCCESS.configurePaper(e -> e.placedBlockAt(pos.immutable())); // Paper - track placed block position from block item + } + + protected SoundEvent getPlaceSound(final BlockState blockState) { +@@ -133,8 +_,20 @@ + + protected boolean canPlace(final BlockPlaceContext context, final BlockState stateForPlacement) { + Player player = context.getPlayer(); +- return (!this.mustSurvive() || stateForPlacement.canSurvive(context.getLevel(), context.getClickedPos())) +- && context.getLevel().isUnobstructed(stateForPlacement, context.getClickedPos(), CollisionContext.placementContext(player)); ++ // CraftBukkit start ++ Level world = context.getLevel(); // Paper - Cancel hit for vanished players ++ boolean canBuild = (!this.mustSurvive() || stateForPlacement.canSurvive(world, context.getClickedPos())) ++ && world.checkEntityCollision(stateForPlacement, player, CollisionContext.placementContext(player), context.getClickedPos(), true); // Paper - Cancel hit for vanished players ++ org.bukkit.entity.Player bukkitPlayer = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null; ++ ++ org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent( ++ org.bukkit.craftbukkit.block.CraftBlock.at(world, context.getClickedPos()), bukkitPlayer, ++ stateForPlacement.asBlockData(), canBuild, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()) ++ ); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ return event.isBuildable(); ++ // CraftBukkit end + } + + protected boolean mustSurvive() { +@@ -159,7 +_,7 @@ + return false; + } + +- if (!type.onlyOpCanSetNbt() || player != null && player.canUseGameMasterBlocks()) { ++ if (!type.onlyOpCanSetNbt() || player != null && (player.canUseGameMasterBlocks() || (player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.nbt.place")))) { // Spigot - add permission + return customData.loadInto(blockEntity, level.registryAccess()); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch new file mode 100644 index 000000000000..511dda21445b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -0,0 +1,90 @@ +--- a/net/minecraft/world/item/BucketItem.java ++++ b/net/minecraft/world/item/BucketItem.java +@@ -32,6 +_,7 @@ + import org.jspecify.annotations.Nullable; + + public class BucketItem extends Item implements DispensibleContainerItem { ++ private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack + public final Fluid content; + + public BucketItem(final Fluid content, final Item.Properties properties) { +@@ -61,12 +_,22 @@ + if (this.content == Fluids.EMPTY) { + BlockState blockState = level.getBlockState(pos); + if (blockState.getBlock() instanceof BucketPickup bucketPickupBlock) { ++ // CraftBukkit start ++ ItemStack dummyFluid = bucketPickupBlock.pickupBlock(player, org.bukkit.craftbukkit.util.DummyLevelAccessor.INSTANCE, pos, blockState); ++ if (dummyFluid.isEmpty()) return InteractionResult.FAIL; // Don't fire event if the bucket won't be filled. ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, pos, pos, hitResult.getDirection(), itemStack, dummyFluid.getItem(), hand); ++ ++ if (event.isCancelled()) { ++ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end + ItemStack taken = bucketPickupBlock.pickupBlock(player, level, pos, blockState); + if (!taken.isEmpty()) { + player.awardStat(Stats.ITEM_USED.get(this)); + bucketPickupBlock.getPickupSound().ifPresent(soundEvent -> player.playSound(soundEvent, 1.0F, 1.0F)); + level.gameEvent(player, GameEvent.FLUID_PICKUP, pos); +- ItemStack result = ItemUtils.createFilledResult(itemStack, player, taken); ++ ItemStack result = ItemUtils.createFilledResult(itemStack, player, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + if (!level.isClientSide()) { + CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, taken); + } +@@ -79,7 +_,7 @@ + } else { + BlockState clicked = level.getBlockState(pos); + BlockPos placePos = clicked.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? pos : directionOffsetPos; +- if (this.emptyContents(player, level, placePos, hitResult)) { ++ if (this.emptyContents(player, level, placePos, hitResult, hitResult.getDirection(), pos, itemStack, hand)) { // CraftBukkit + this.checkExtraContent(player, level, itemStack, placePos); + if (player instanceof ServerPlayer) { + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, placePos, itemStack); +@@ -95,6 +_,13 @@ + } + + public static ItemStack getEmptySuccessItem(final ItemStack itemStack, final Player player) { ++ // Paper start - Fix PlayerBucketEmptyEvent result itemstack ++ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) { ++ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent; ++ itemLeftInHandAfterPlayerBucketEmptyEvent = null; ++ return itemInHand; ++ } ++ // Paper end - Fix PlayerBucketEmptyEvent result itemstack + return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : itemStack; + } + +@@ -104,6 +_,12 @@ + + @Override + public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { ++ // CraftBukkit start ++ return this.emptyContents(user, level, pos, hitResult, null, null, null, InteractionHand.MAIN_HAND); ++ } ++ ++ public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult, final Direction direction, final BlockPos clicked, final ItemStack itemStack, final InteractionHand hand) { ++ // CraftBukkit end + if (!(this.content instanceof FlowingFluid flowingFluid)) { + return false; + } else { +@@ -114,8 +_,18 @@ + boolean placeLiquid = mayReplace + || block instanceof LiquidBlockContainer container && container.canPlaceLiquid(user, level, pos, blockState, this.content); + boolean canPlaceFluidInsideBlock = blockState.isAir() || placeLiquid && (!shiftKeyDown || hitResult == null); ++ // CraftBukkit start ++ if (canPlaceFluidInsideBlock && user instanceof Player player) { ++ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent(level, player, pos, clicked, direction, itemStack, hand); ++ if (event.isCancelled()) { ++ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 ++ return false; ++ } ++ itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack() != null ? event.getItemStack().equals(org.bukkit.craftbukkit.inventory.CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; // Paper - Fix PlayerBucketEmptyEvent result itemstack ++ } ++ // CraftBukkit end + if (!canPlaceFluidInsideBlock) { +- return hitResult != null && this.emptyContents(user, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null); ++ return hitResult != null && this.emptyContents(user, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemStack, hand); // CraftBukkit + } + + if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch new file mode 100644 index 000000000000..fcf926ca2336 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -0,0 +1,56 @@ +--- a/net/minecraft/world/item/EnderEyeItem.java ++++ b/net/minecraft/world/item/EnderEyeItem.java +@@ -47,6 +_,11 @@ + } + + BlockState newState = targetState.setValue(EndPortalFrameBlock.HAS_EYE, true); ++ // Paper start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), pos, newState)) { ++ return InteractionResult.PASS; ++ } ++ // Paper end + Block.pushEntitiesUp(targetState, newState, level, pos); + level.setBlock(pos, newState, Block.UPDATE_CLIENTS); + level.updateNeighbourForOutputSignal(pos, Blocks.END_PORTAL_FRAME); +@@ -64,7 +_,27 @@ + } + } + +- level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); ++ // CraftBukkit start - Use relative location for far away sounds ++ // level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); ++ int viewDistance = level.getCraftServer().getViewDistance() * 16; ++ BlockPos soundPos = blockPos.offset(1, 0, 1); ++ final net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) level; // Paper - respect global sound events gamerule - ensured by isClientSide check above ++ for (ServerPlayer player : serverLevel.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule ++ double deltaX = soundPos.getX() - player.getX(); ++ double deltaZ = soundPos.getZ() - player.getZ(); ++ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; ++ final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule ++ if (!serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule ++ if (distanceSquared > viewDistance * viewDistance) { ++ double deltaLength = Math.sqrt(distanceSquared); ++ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(LevelEvent.SOUND_END_PORTAL_SPAWN, new BlockPos((int) relativeX, (int) soundPos.getY(), (int) relativeZ), 0, true)); ++ } else { ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(LevelEvent.SOUND_END_PORTAL_SPAWN, soundPos, 0, true)); ++ } ++ } ++ // CraftBukkit end + } + + return InteractionResult.SUCCESS; +@@ -94,7 +_,11 @@ + eyeOfEnder.setItem(itemStack); + eyeOfEnder.signalTo(Vec3.atLowerCornerOf(nearestMapFeature)); + level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); +- level.addFreshEntity(eyeOfEnder); ++ // CraftBukkit start ++ if (!level.addFreshEntity(eyeOfEnder)) { ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end + if (player instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.USED_ENDER_EYE.trigger(serverPlayer, nearestMapFeature); + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch new file mode 100644 index 000000000000..d6ddb9b13546 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/world/item/FireworkRocketItem.java ++++ b/net/minecraft/world/item/FireworkRocketItem.java +@@ -37,7 +_,7 @@ + ItemStack itemStack = context.getItemInHand(); + Vec3 clickLocation = context.getClickLocation(); + Direction direction = context.getClickedFace(); +- Projectile.spawnProjectile( ++ final Projectile.Delayed fireworkRocketEntity = Projectile.spawnProjectileDelayed( // Paper - PlayerLaunchProjectileEvent + new FireworkRocketEntity( + level, + context.getPlayer(), +@@ -47,9 +_,14 @@ + itemStack + ), + serverLevel, +- itemStack ++ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid + ); +- itemStack.shrink(1); ++ // Paper start - PlayerLaunchProjectileEvent ++ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.projectile().getBukkitEntity()); ++ if (!event.callEvent() || !fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS; ++ if (event.shouldConsume() && !context.getPlayer().hasInfiniteMaterials()) itemStack.shrink(1); ++ else context.getPlayer().containerMenu.forceHeldSlot(context.getHand()); ++ // Paper end - PlayerLaunchProjectileEvent + } + + return InteractionResult.SUCCESS; +@@ -60,13 +_,24 @@ + if (player.isFallFlying()) { + ItemStack itemStack = player.getItemInHand(hand); + if (level instanceof ServerLevel serverLevel) { +- if (player.dropAllLeashConnections(null)) { +- level.playSound(null, player, SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F); ++ // Paper start - PlayerElytraBoostEvent ++ final Projectile.Delayed delayed = Projectile.spawnProjectileDelayed(new FireworkRocketEntity(level, itemStack, player), serverLevel, itemStack, f -> f.spawningEntity = player.getUUID()); // Paper - firework api - assign spawning entity uuid ++ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand)); ++ if (event.callEvent() && delayed.attemptSpawn()) { ++ player.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below ++ if (player.dropAllLeashConnections(player, hand)) { // Paper - PlayerUnleashEntityEvent ++ level.playSound(null, player, SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F); ++ } ++ if (event.shouldConsume() && !player.hasInfiniteMaterials()) { ++ itemStack.shrink(1); // Moved up from below ++ } else { ++ player.containerMenu.forceHeldSlot(hand); ++ } ++ } else { ++ player.containerMenu.forceHeldSlot(hand); + } +- +- Projectile.spawnProjectile(new FireworkRocketEntity(level, itemStack, player), serverLevel, itemStack); +- itemStack.consume(1, player); +- player.awardStat(Stats.ITEM_USED.get(this)); ++ // Moved up consume and changed consume to shrink ++ // Paper end - PlayerElytraBoostEvent + } + + return InteractionResult.SUCCESS; diff --git a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch new file mode 100644 index 000000000000..208052922fe2 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/item/HangingEntityItem.java ++++ b/net/minecraft/world/item/HangingEntityItem.java +@@ -63,6 +_,20 @@ + EntityType.createDefaultStackConfig(level, itemInHand, player).accept(entity); + if (entity.survives()) { + if (!level.isClientSide()) { ++ // CraftBukkit start - fire HangingPlaceEvent ++ org.bukkit.entity.Player bukkitPlayer = player == null ? null : (org.bukkit.entity.Player) player.getBukkitEntity(); ++ org.bukkit.block.Block blockClicked = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos); ++ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace); ++ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()); ++ ++ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) entity.getBukkitEntity(), bukkitPlayer, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemInHand)); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ if (player != null) player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end + entity.playPlacementSound(); + level.gameEvent(player, GameEvent.ENTITY_PLACE, entity.position()); + level.addFreshEntity(entity); diff --git a/paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch new file mode 100644 index 000000000000..2fdedb1b5b33 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/LeadItem.java.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/world/item/LeadItem.java ++++ b/net/minecraft/world/item/LeadItem.java +@@ -27,14 +_,14 @@ + if (state.is(BlockTags.FENCES)) { + Player player = context.getPlayer(); + if (!level.isClientSide() && player != null) { +- return bindPlayerMobs(player, level, pos); ++ return bindPlayerMobs(player, level, pos, context.getHand()); // CraftBukkit - Pass hand + } + } + + return InteractionResult.PASS; + } + +- public static InteractionResult bindPlayerMobs(final Player player, final Level level, final BlockPos pos) { ++ public static InteractionResult bindPlayerMobs(final Player player, final Level level, final BlockPos pos, final net.minecraft.world.InteractionHand hand) { // CraftBukkit - Add InteractionHand + List entitiesToLeash = Leashable.leashableInArea(level, Vec3.atCenterOf(pos), l -> l.getLeashHolder() == player); + if (entitiesToLeash.isEmpty()) { + return InteractionResult.PASS; +@@ -42,10 +_,22 @@ + + Optional existingKnot = LeashFenceKnotEntity.getKnot(level, pos); + LeashFenceKnotEntity activeKnot = existingKnot.orElseGet(() -> LeashFenceKnotEntity.createKnot(level, pos)); ++ // CraftBukkit start - fire HangingPlaceEvent ++ if (existingKnot.isEmpty()) { ++ org.bukkit.inventory.EquipmentSlot handSlot = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand); ++ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) activeKnot.getBukkitEntity(), player != null ? (org.bukkit.entity.Player) player.getBukkitEntity() : null, org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), org.bukkit.block.BlockFace.SELF, handSlot); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ activeKnot.discard(); ++ return InteractionResult.PASS; ++ } ++ } ++ // CraftBukkit end + boolean anyLeashed = false; + + for (Leashable leashable : entitiesToLeash) { +- if (leashable.canHaveALeashAttachedTo(activeKnot)) { ++ if (leashable.canHaveALeashAttachedTo(activeKnot) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(leashable, activeKnot, player, hand)) { // Paper - leash event + leashable.setLeashedTo(activeKnot, true); + anyLeashed = true; + } +@@ -63,4 +_,10 @@ + + return InteractionResult.PASS; + } ++ ++ // CraftBukkit start ++ public static InteractionResult bindPlayerMobs(Player player, Level world, BlockPos pos) { ++ return LeadItem.bindPlayerMobs(player, world, pos, net.minecraft.world.InteractionHand.MAIN_HAND); ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch index fdbbd6a8ff84..92137878f706 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/ProjectileWeaponItem.java b/net/minecraft/world/item/ProjectileWeaponItem.java -index 84e108fe5520e3d44f916e981f7a5f4805751898..9abc52c653f8416c62ca8b14c4794233d84ead59 100644 --- a/net/minecraft/world/item/ProjectileWeaponItem.java +++ b/net/minecraft/world/item/ProjectileWeaponItem.java -@@ -50,6 +50,7 @@ public abstract class ProjectileWeaponItem extends Item { +@@ -50,6 +_,7 @@ final float uncertainty, final boolean isCrit, final @Nullable LivingEntity targetOverride @@ -16,7 +8,7 @@ index 84e108fe5520e3d44f916e981f7a5f4805751898..9abc52c653f8416c62ca8b14c4794233 ) { float maxAngle = EnchantmentHelper.processProjectileSpread(level, weapon, shooter, 0.0F); float angleStep = projectiles.size() == 1 ? 0.0F : 2.0F * maxAngle / (projectiles.size() - 1); -@@ -62,12 +63,26 @@ public abstract class ProjectileWeaponItem extends Item { +@@ -62,12 +_,26 @@ float angle = angleOffset + direction * ((i + 1) / 2) * angleStep; direction = -direction; int index = i; @@ -49,7 +41,7 @@ index 84e108fe5520e3d44f916e981f7a5f4805751898..9abc52c653f8416c62ca8b14c4794233 weapon.hurtAndBreak(this.getDurabilityUse(projectile), shooter, hand.asEquipmentSlot()); if (weapon.isEmpty()) { break; -@@ -103,6 +118,12 @@ public abstract class ProjectileWeaponItem extends Item { +@@ -103,6 +_,12 @@ } protected static List draw(final ItemStack weapon, final ItemStack projectile, final LivingEntity shooter) { @@ -61,13 +53,13 @@ index 84e108fe5520e3d44f916e981f7a5f4805751898..9abc52c653f8416c62ca8b14c4794233 + // Paper end if (projectile.isEmpty()) { return List.of(); - } else { -@@ -113,7 +134,7 @@ public abstract class ProjectileWeaponItem extends Item { - ItemStack projectileCopy = projectile.copy(); + } +@@ -112,7 +_,7 @@ + ItemStack projectileCopy = projectile.copy(); - for (int i = 0; i < numProjectiles; i++) { -- ItemStack drawnStack = useAmmo(weapon, i == 0 ? projectile : projectileCopy, shooter, i > 0); -+ ItemStack drawnStack = useAmmo(weapon, i == 0 ? projectile : projectileCopy, shooter, i > 0 || !consume); // Paper - if (!drawnStack.isEmpty()) { - drawn.add(drawnStack); - } + for (int i = 0; i < numProjectiles; i++) { +- ItemStack drawnStack = useAmmo(weapon, i == 0 ? projectile : projectileCopy, shooter, i > 0); ++ ItemStack drawnStack = useAmmo(weapon, i == 0 ? projectile : projectileCopy, shooter, i > 0 || !consume); // Paper + if (!drawnStack.isEmpty()) { + drawn.add(drawnStack); + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch new file mode 100644 index 000000000000..088edba8dd0b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/item/ShovelItem.java ++++ b/net/minecraft/world/item/ShovelItem.java +@@ -46,20 +_,29 @@ + Player player = context.getPlayer(); + BlockState newState = FLATTENABLES.get(blockState.getBlock()); + BlockState updatedState = null; ++ Runnable afterAction = null; // Paper + if (newState != null && level.getBlockState(pos.above()).isAir()) { +- level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); ++ afterAction = () -> level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper + updatedState = newState; + } else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) { ++ afterAction = () -> { // Paper + if (!level.isClientSide()) { + level.levelEvent(null, LevelEvent.SOUND_EXTINGUISH_FIRE, pos, 0); + } + + CampfireBlock.dowse(context.getPlayer(), level, pos, blockState); ++ }; // Paper + updatedState = blockState.setValue(CampfireBlock.LIT, false); + } + + if (updatedState != null) { + if (!level.isClientSide()) { ++ // Paper start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), pos, updatedState)) { ++ return InteractionResult.PASS; ++ } ++ afterAction.run(); ++ // Paper end + level.setBlock(pos, updatedState, Block.UPDATE_ALL_IMMEDIATE); + level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, updatedState)); + if (player != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch new file mode 100644 index 000000000000..274ee7f95a33 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/item/SpawnEggItem.java ++++ b/net/minecraft/world/item/SpawnEggItem.java +@@ -63,6 +_,7 @@ + + return InteractionResult.FAIL; + } else { ++ if (level.paperConfig().entities.spawning.disableMobSpawnerSpawnEggTransformation) return InteractionResult.FAIL; // Paper - Allow disabling mob spawner spawn egg transformation + spawnerHolder.setEntityId(type, level.getRandom()); + level.sendBlockUpdated(pos, blockState, blockState, Block.UPDATE_ALL); + level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, pos); +@@ -95,7 +_,7 @@ + return InteractionResult.FAIL; + } + +- if (!type.isAllowedInPeaceful() && level.getDifficulty() == Difficulty.PEACEFUL) { ++ if (!type.isAllowedInPeaceful(itemStack.get(DataComponents.ENTITY_DATA).getUnsafe()) && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - check peaceful override + return InteractionResult.FAIL; + } + +@@ -174,7 +_,7 @@ + + offspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); + offspring.applyComponentsFromItemStack(spawnEggStack); +- level.addFreshEntityWithPassengers(offspring); ++ level.addFreshEntityWithPassengers(offspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit + spawnEggStack.consume(1, player); + return Optional.of(offspring); + } From 886f8bb5e75e171cbe8e1be1b370dbf2853773fc Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 19:37:20 +0100 Subject: [PATCH 06/16] 50 --- .../commands/DifficultyCommand.java.patch | 23 ------- .../server/commands/GiveCommand.java.patch | 37 ----------- .../server/commands/KickCommand.java.patch | 19 ------ .../server/commands/PlaceCommand.java.patch | 18 ----- .../server/commands/RideCommand.java.patch | 19 ------ .../commands/ScheduleCommand.java.patch | 37 ----------- .../server/commands/SummonCommand.java.patch | 36 ---------- .../commands/TeleportCommand.java.patch | 19 ------ .../world/item/TridentItem.java.patch | 60 ----------------- .../commands/DifficultyCommand.java.patch | 16 +++++ .../server/commands/GiveCommand.java.patch | 29 ++++++++ .../server/commands/KickCommand.java.patch | 11 ++++ .../server/commands/PlaceCommand.java.patch | 10 +++ .../server/commands/RideCommand.java.patch | 11 ++++ .../commands/ScheduleCommand.java.patch | 29 ++++++++ .../server/commands/SummonCommand.java.patch | 28 ++++++++ .../commands/TeleportCommand.java.patch | 11 ++++ .../server/commands/TimeCommand.java.patch | 66 ++++++++----------- .../world/item/TridentItem.java.patch | 52 +++++++++++++++ 19 files changed, 226 insertions(+), 305 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/commands/TimeCommand.java.patch (67%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch deleted file mode 100644 index adc880aedecc..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/DifficultyCommand.java.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/DifficultyCommand.java b/net/minecraft/server/commands/DifficultyCommand.java -index 5f9f6bda3cee7fecd4e6bd1cd82f0b1a71446014..1536602f1c5f3d57ae6396cdea4d4c75a146355b 100644 ---- a/net/minecraft/server/commands/DifficultyCommand.java -+++ b/net/minecraft/server/commands/DifficultyCommand.java -@@ -31,10 +31,10 @@ public class DifficultyCommand { - - public static int setDifficulty(final CommandSourceStack source, final Difficulty difficulty) throws CommandSyntaxException { - MinecraftServer server = source.getServer(); -- if (server.getWorldData().getDifficulty() == difficulty) { -+ if (source.getLevel().getDifficulty() == difficulty) { // CraftBukkit - throw ERROR_ALREADY_SAME_DIFFICULTY.create(difficulty.getSerializedName()); - } else { -- server.setDifficulty(difficulty, true); -+ server.setDifficulty(source.getLevel(), difficulty, source, true); // Paper - per level difficulty; don't skip other difficulty-changing logic (fix upstream's fix); WorldDifficultyChangeEvent - source.sendSuccess(() -> Component.translatable("commands.difficulty.success", difficulty.getDisplayName()), true); - return 0; - } diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch deleted file mode 100644 index 7b785b6d596a..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/GiveCommand.java.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/GiveCommand.java b/net/minecraft/server/commands/GiveCommand.java -index db01e15e20585856c04bb3248875d996fbd26548..b6ca9adb5361ebbbb53737806bff7bb3101e5e61 100644 ---- a/net/minecraft/server/commands/GiveCommand.java -+++ b/net/minecraft/server/commands/GiveCommand.java -@@ -62,7 +62,7 @@ public class GiveCommand { - ItemStack copyToDrop = prototypeItemStack.copyWithCount(size); - boolean added = player.getInventory().add(copyToDrop); - if (added && copyToDrop.isEmpty()) { -- ItemEntity drop = player.drop(prototypeItemStack.copy(), false); -+ ItemEntity drop = player.drop(prototypeItemStack.copy(), false, false, false, null); // Paper - do not fire PlayerDropItemEvent for /give command - if (drop != null) { - drop.makeFakeItem(); - } -@@ -80,7 +80,7 @@ public class GiveCommand { - ); - player.containerMenu.broadcastChanges(); - } else { -- ItemEntity drop = player.drop(copyToDrop, false); -+ ItemEntity drop = player.drop(copyToDrop, false, false, false, null); // Paper - do not fire PlayerDropItemEvent for /give command - if (drop != null) { - drop.setNoPickUpDelay(); - drop.setTarget(player.getUUID()); -@@ -98,7 +98,7 @@ public class GiveCommand { - ); - } else { - source.sendSuccess( -- () -> Component.translatable("commands.give.success.single", count, prototypeItemStack.getDisplayName(), players.size()), true -+ () -> Component.translatable("commands.give.success.multiple", count, prototypeItemStack.getDisplayName(), players.size()), true // Paper - MC-151857 - correct translation key - ); - } - diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch deleted file mode 100644 index a2fadd15a902..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/KickCommand.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/KickCommand.java b/net/minecraft/server/commands/KickCommand.java -index a4151f86e9a8737a45e472a9bbefb7ac9126beca..0227dd63f67537d769494e122616873c18d35350 100644 ---- a/net/minecraft/server/commands/KickCommand.java -+++ b/net/minecraft/server/commands/KickCommand.java -@@ -42,7 +42,7 @@ public class KickCommand { - - for (ServerPlayer player : players) { - if (!source.getServer().isSingleplayerOwner(player.nameAndId())) { -- player.connection.disconnect(reason); -+ player.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause - source.sendSuccess(() -> Component.translatable("commands.kick.success", player.getDisplayName(), reason), true); - count++; - } diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch deleted file mode 100644 index e8a06491ba0b..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/PlaceCommand.java.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/PlaceCommand.java b/net/minecraft/server/commands/PlaceCommand.java -index 4c98316d3ad1cffb3d92c94c6b839870c4a2934d..eab9553e89b781332a1026a037d2c5e9d70bd9b7 100644 ---- a/net/minecraft/server/commands/PlaceCommand.java -+++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -298,6 +298,7 @@ public class PlaceCommand { - if (!start.isValid()) { - throw ERROR_STRUCTURE_FAILED.create(); - } else { -+ start.generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.COMMAND; // CraftBukkit - set AsyncStructureGenerateEvent.Cause.COMMAND as generation cause - BoundingBox boundingBox = start.getBoundingBox(); - ChunkPos chunkMin = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.minX()), SectionPos.blockToSectionCoord(boundingBox.minZ())); - ChunkPos chunkMax = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.maxX()), SectionPos.blockToSectionCoord(boundingBox.maxZ())); diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch deleted file mode 100644 index b2b036905f38..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/RideCommand.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/RideCommand.java b/net/minecraft/server/commands/RideCommand.java -index ac31d0ae540f350ed634b5561f7a91631f35d963..682dd4b1c21902273de077ed20c7cdc37eedbc46 100644 ---- a/net/minecraft/server/commands/RideCommand.java -+++ b/net/minecraft/server/commands/RideCommand.java -@@ -54,7 +54,7 @@ public class RideCommand { - Entity currentVehicle = target.getVehicle(); - if (currentVehicle != null) { - throw ERROR_ALREADY_RIDING.create(target.getDisplayName(), currentVehicle.getDisplayName()); -- } else if (vehicle.is(EntityType.PLAYER)) { -+ } else if (vehicle.is(EntityType.PLAYER) && !io.papermc.paper.configuration.GlobalConfiguration.get().commands.rideCommandAllowPlayerAsVehicle) { // Paper - allow player as vehicle - throw ERROR_MOUNTING_PLAYER.create(); - } else if (target.getSelfAndPassengers().anyMatch(e -> e == vehicle)) { - throw ERROR_MOUNTING_LOOP.create(); diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch deleted file mode 100644 index 3ff0c9a64e95..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/ScheduleCommand.java.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/ScheduleCommand.java b/net/minecraft/server/commands/ScheduleCommand.java -index 65e60944e928d96524869aad2ced16abb79b94c7..e49571f7116020da818665083ed59e4b475c056c 100644 ---- a/net/minecraft/server/commands/ScheduleCommand.java -+++ b/net/minecraft/server/commands/ScheduleCommand.java -@@ -32,7 +32,7 @@ public class ScheduleCommand { - ); - private static final SimpleCommandExceptionType ERROR_MACRO = new SimpleCommandExceptionType(Component.translatableEscape("commands.schedule.macro")); - private static final SuggestionProvider SUGGEST_SCHEDULE = (c, p) -> SharedSuggestionProvider.suggest( -- c.getSource().getServer().getScheduledEvents().getEventsIds(), p -+ c.getSource().getLevel().scheduledEvents.getEventsIds(), p // Paper - Make schedule command per-world - ); - - public static void register(final CommandDispatcher dispatcher) { -@@ -101,7 +101,7 @@ public class ScheduleCommand { - } else { - long tickTime = source.getLevel().getGameTime() + time; - Identifier callbackId = callback.getFirst(); -- TimerQueue queue = source.getServer().getScheduledEvents(); -+ TimerQueue queue = source.getLevel().scheduledEvents; // CraftBukkit - SPIGOT-6667: Use world specific function timer - Optional> function = callback.getSecond().left(); - if (function.isPresent()) { - if (function.get() instanceof MacroFunction) { -@@ -132,7 +132,7 @@ public class ScheduleCommand { - } - - private static int remove(final CommandSourceStack source, final String id) throws CommandSyntaxException { -- int count = source.getServer().getScheduledEvents().remove(id); -+ int count = source.getLevel().scheduledEvents.remove(id); // Paper - Make schedule command per-world - if (count == 0) { - throw ERROR_CANT_REMOVE.create(id); - } else { diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch deleted file mode 100644 index d197b870c4c2..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/SummonCommand.java.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/SummonCommand.java b/net/minecraft/server/commands/SummonCommand.java -index c827ffa69e3bc8f0119c06c55fcc62fd859e4ac6..fd598900ae35b9fd0509281c24ee9f503b78a4e1 100644 ---- a/net/minecraft/server/commands/SummonCommand.java -+++ b/net/minecraft/server/commands/SummonCommand.java -@@ -78,7 +78,7 @@ public class SummonCommand { - BlockPos blockPos = BlockPos.containing(pos); - if (!Level.isInSpawnableBounds(blockPos)) { - throw INVALID_POSITION.create(); -- } else if (source.getLevel().getDifficulty() == Difficulty.PEACEFUL && !type.value().isAllowedInPeaceful()) { -+ } else if (source.getLevel().getDifficulty() == Difficulty.PEACEFUL && !type.value().isAllowedInPeaceful(nbt)) { // Paper - check peaceful override - throw ERROR_FAILED_PEACEFUL.create(); - } else { - CompoundTag entityTag = nbt.copy(); -@@ -86,6 +86,7 @@ public class SummonCommand { - ServerLevel level = source.getLevel(); - Entity entity = EntityType.loadEntityRecursive(entityTag, level, EntitySpawnReason.COMMAND, e -> { - e.snapTo(pos.x, pos.y, pos.z, e.getYRot(), e.getXRot()); -+ e.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper - Entity#getEntitySpawnReason - return e; - }); - if (entity == null) { -@@ -95,7 +96,7 @@ public class SummonCommand { - mob.finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, null); - } - -- if (!level.tryAddFreshEntityWithPassengers(entity)) { -+ if (!level.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" - throw ERROR_DUPLICATE_UUID.create(); - } else { - return entity; diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch deleted file mode 100644 index 067790ecdb94..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/TeleportCommand.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/TeleportCommand.java b/net/minecraft/server/commands/TeleportCommand.java -index b350255b16c148040104d8e37c4fc80cb07a0b4a..7047a0da56459cda404702cf4dbc69e537683ff8 100644 ---- a/net/minecraft/server/commands/TeleportCommand.java -+++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -255,7 +255,7 @@ public class TeleportCommand { - float relativeOrAbsoluteXRot = relatives.contains(Relative.X_ROT) ? xRot - victim.getXRot() : xRot; - float newYRot = Mth.wrapDegrees(relativeOrAbsoluteYRot); - float newXRot = Mth.wrapDegrees(relativeOrAbsoluteXRot); -- if (victim.teleportTo(level, relativeOrAbsoluteX, relativeOrAbsoluteY, relativeOrAbsoluteZ, relatives, newYRot, newXRot, true)) { -+ if (victim.teleportTo(level, relativeOrAbsoluteX, relativeOrAbsoluteY, relativeOrAbsoluteZ, relatives, newYRot, newXRot, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND)) { // Paper - teleport cause - if (lookAt != null) { - lookAt.perform(source, victim); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch deleted file mode 100644 index ec21440812ae..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/TridentItem.java.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/TridentItem.java b/net/minecraft/world/item/TridentItem.java -index 429978baeea934353d94021db25ef12fb316d3f4..a1e7f6138aa99b33152dd464f382bf36ad055c7f 100644 ---- a/net/minecraft/world/item/TridentItem.java -+++ b/net/minecraft/world/item/TridentItem.java -@@ -78,18 +78,38 @@ public class TridentItem extends Item implements ProjectileItem { - .orElse(SoundEvents.TRIDENT_THROW); - player.awardStat(Stats.ITEM_USED.get(this)); - if (level instanceof ServerLevel serverLevel) { -- itemStack.hurtWithoutBreaking(1, player); -+ // itemStack.hurtWithoutBreaking(1, player); // CraftBukkit - moved down - if (riptideStrength == 0.0F) { -- ItemStack thrownItemStack = itemStack.consumeAndReturn(1, player); -- ThrownTrident trident = Projectile.spawnProjectileFromRotation( -+ ItemStack thrownItemStack = itemStack.copyWithCount(1); // Paper -+ Projectile.Delayed tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent( - ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, 1.0F - ); -+ // Paper start - PlayerLaunchProjectileEvent -+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity()); -+ if (!event.callEvent() || !tridentDelayed.attemptSpawn()) { -+ // CraftBukkit start -+ // Paper end - PlayerLaunchProjectileEvent -+ return false; -+ } -+ ThrownTrident trident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent -+ if (event.shouldConsume()) { -+ thrownItemStack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent - use thrownItemStack; pickup item damage -+ } -+ trident.pickupItemStack = thrownItemStack.copy(); // SPIGOT-4511 update since damage call moved - use thrownItemStack; count = 1 -+ if (event.shouldConsume()) { -+ itemStack.consume(1, player); -+ } -+ // CraftBukkit end - if (player.hasInfiniteMaterials()) { - trident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; - } - - level.playSound(null, trident, sound.value(), SoundSource.PLAYERS, 1.0F, 1.0F); - return true; -+ // CraftBukkit start - SPIGOT-5458 also need in this branch :( -+ } else { -+ itemStack.hurtWithoutBreaking(1, player); -+ // CraftBukkit end - } - } - -@@ -103,6 +123,7 @@ public class TridentItem extends Item implements ProjectileItem { - xd *= riptideStrength / dist; - yd *= riptideStrength / dist; - zd *= riptideStrength / dist; -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(player, itemStack, xd, yd, zd)) return false; // Paper - Add player riptide event - player.push(xd, yd, zd); - player.startAutoSpinAttack(20, 8.0F, itemStack); - if (player.onGround()) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch new file mode 100644 index 000000000000..fb0f2487c318 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/server/commands/DifficultyCommand.java ++++ b/net/minecraft/server/commands/DifficultyCommand.java +@@ -31,11 +_,11 @@ + + public static int setDifficulty(final CommandSourceStack source, final Difficulty difficulty) throws CommandSyntaxException { + MinecraftServer server = source.getServer(); +- if (server.getWorldData().getDifficulty() == difficulty) { ++ if (source.getLevel().getDifficulty() == difficulty) { // CraftBukkit + throw ERROR_ALREADY_SAME_DIFFICULTY.create(difficulty.getSerializedName()); + } + +- server.setDifficulty(difficulty, true); ++ server.setDifficulty(source.getLevel(), difficulty, source, true); // Paper - per level difficulty; don't skip other difficulty-changing logic (fix upstream's fix); WorldDifficultyChangeEvent + source.sendSuccess(() -> Component.translatable("commands.difficulty.success", difficulty.getDisplayName()), true); + return 0; + } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch new file mode 100644 index 000000000000..b8cd001ae92b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/commands/GiveCommand.java ++++ b/net/minecraft/server/commands/GiveCommand.java +@@ -63,7 +_,7 @@ + ItemStack copyToDrop = prototypeItemStack.copyWithCount(size); + boolean added = player.getInventory().add(copyToDrop); + if (added && copyToDrop.isEmpty()) { +- ItemEntity drop = player.drop(prototypeItemStack.copy(), false); ++ ItemEntity drop = player.drop(prototypeItemStack.copy(), false, false, false, null); // Paper - do not fire PlayerDropItemEvent for /give command + if (drop != null) { + drop.makeFakeItem(); + } +@@ -81,7 +_,7 @@ + ); + player.containerMenu.broadcastChanges(); + } else { +- ItemEntity drop = player.drop(copyToDrop, false); ++ ItemEntity drop = player.drop(copyToDrop, false, false, false, null); // Paper - do not fire PlayerDropItemEvent for /give command + if (drop != null) { + drop.setNoPickUpDelay(); + drop.setTarget(player.getUUID()); +@@ -98,7 +_,7 @@ + true + ); + } else { +- source.sendSuccess(() -> Component.translatable("commands.give.success.single", count, prototypeItemStack.getDisplayName(), players.size()), true); ++ source.sendSuccess(() -> Component.translatable("commands.give.success.multiple", count, prototypeItemStack.getDisplayName(), players.size()), true); // Paper - MC-151857 - correct translation key + } + + return players.size(); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch new file mode 100644 index 000000000000..5ea8e5eccc39 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/commands/KickCommand.java ++++ b/net/minecraft/server/commands/KickCommand.java +@@ -43,7 +_,7 @@ + + for (ServerPlayer player : players) { + if (!source.getServer().isSingleplayerOwner(player.nameAndId())) { +- player.connection.disconnect(reason); ++ player.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause + source.sendSuccess(() -> Component.translatable("commands.kick.success", player.getDisplayName(), reason), true); + count++; + } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch new file mode 100644 index 000000000000..dfbc359450bc --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/commands/PlaceCommand.java ++++ b/net/minecraft/server/commands/PlaceCommand.java +@@ -299,6 +_,7 @@ + throw ERROR_STRUCTURE_FAILED.create(); + } + ++ start.generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.COMMAND; // CraftBukkit - set AsyncStructureGenerateEvent.Cause.COMMAND as generation cause + BoundingBox boundingBox = start.getBoundingBox(); + ChunkPos chunkMin = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.minX()), SectionPos.blockToSectionCoord(boundingBox.minZ())); + ChunkPos chunkMax = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.maxX()), SectionPos.blockToSectionCoord(boundingBox.maxZ())); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch new file mode 100644 index 000000000000..f68ef1494ca4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/commands/RideCommand.java ++++ b/net/minecraft/server/commands/RideCommand.java +@@ -56,7 +_,7 @@ + throw ERROR_ALREADY_RIDING.create(target.getDisplayName(), currentVehicle.getDisplayName()); + } + +- if (vehicle.is(EntityType.PLAYER)) { ++ if (vehicle.is(EntityType.PLAYER) && !io.papermc.paper.configuration.GlobalConfiguration.get().commands.rideCommandAllowPlayerAsVehicle) { // Paper - allow player as vehicle + throw ERROR_MOUNTING_PLAYER.create(); + } + diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch new file mode 100644 index 000000000000..61e46dfd9391 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/commands/ScheduleCommand.java ++++ b/net/minecraft/server/commands/ScheduleCommand.java +@@ -32,7 +_,7 @@ + ); + private static final SimpleCommandExceptionType ERROR_MACRO = new SimpleCommandExceptionType(Component.translatableEscape("commands.schedule.macro")); + private static final SuggestionProvider SUGGEST_SCHEDULE = (c, p) -> SharedSuggestionProvider.suggest( +- c.getSource().getServer().getScheduledEvents().getEventsIds(), p ++ c.getSource().getLevel().scheduledEvents.getEventsIds(), p // Paper - Make schedule command per-world + ); + + public static void register(final CommandDispatcher dispatcher) { +@@ -102,7 +_,7 @@ + + long tickTime = source.getLevel().getGameTime() + time; + Identifier callbackId = callback.getFirst(); +- TimerQueue queue = source.getServer().getScheduledEvents(); ++ TimerQueue queue = source.getLevel().scheduledEvents; // CraftBukkit - SPIGOT-6667: Use world specific function timer + Optional> function = callback.getSecond().left(); + if (function.isPresent()) { + if (function.get() instanceof MacroFunction) { +@@ -130,7 +_,7 @@ + } + + private static int remove(final CommandSourceStack source, final String id) throws CommandSyntaxException { +- int count = source.getServer().getScheduledEvents().remove(id); ++ int count = source.getLevel().scheduledEvents.remove(id); // Paper - Make schedule command per-world + if (count == 0) { + throw ERROR_CANT_REMOVE.create(id); + } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch new file mode 100644 index 000000000000..864b687049c4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/server/commands/SummonCommand.java ++++ b/net/minecraft/server/commands/SummonCommand.java +@@ -80,7 +_,7 @@ + throw INVALID_POSITION.create(); + } + +- if (source.getLevel().getDifficulty() == Difficulty.PEACEFUL && !type.value().isAllowedInPeaceful()) { ++ if (source.getLevel().getDifficulty() == Difficulty.PEACEFUL && !type.value().isAllowedInPeaceful(nbt)) { // Paper - check peaceful override + throw ERROR_FAILED_PEACEFUL.create(); + } + +@@ -89,6 +_,7 @@ + ServerLevel level = source.getLevel(); + Entity entity = EntityType.loadEntityRecursive(entityTag, level, EntitySpawnReason.COMMAND, e -> { + e.snapTo(pos.x, pos.y, pos.z, e.getYRot(), e.getXRot()); ++ e.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper - Entity#getEntitySpawnReason + return e; + }); + if (entity == null) { +@@ -99,7 +_,7 @@ + mob.finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, null); + } + +- if (!level.tryAddFreshEntityWithPassengers(entity)) { ++ if (!level.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" + throw ERROR_DUPLICATE_UUID.create(); + } else { + return entity; diff --git a/paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch new file mode 100644 index 000000000000..232050da4cc9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/TeleportCommand.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/commands/TeleportCommand.java ++++ b/net/minecraft/server/commands/TeleportCommand.java +@@ -256,7 +_,7 @@ + float relativeOrAbsoluteXRot = relatives.contains(Relative.X_ROT) ? xRot - victim.getXRot() : xRot; + float newYRot = Mth.wrapDegrees(relativeOrAbsoluteYRot); + float newXRot = Mth.wrapDegrees(relativeOrAbsoluteXRot); +- if (victim.teleportTo(level, relativeOrAbsoluteX, relativeOrAbsoluteY, relativeOrAbsoluteZ, relatives, newYRot, newXRot, true)) { ++ if (victim.teleportTo(level, relativeOrAbsoluteX, relativeOrAbsoluteY, relativeOrAbsoluteZ, relatives, newYRot, newXRot, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND)) { // Paper - teleport cause + if (lookAt != null) { + lookAt.perform(source, victim); + } diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch similarity index 67% rename from paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch rename to paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch index 1e1d87e67902..1513e4104bbb 100644 --- a/paper-server/patches/rejected/net/minecraft/server/commands/TimeCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/TimeCommand.java b/net/minecraft/server/commands/TimeCommand.java -index ff3fbbeca288d5133a13449fe92f6d0aeae00a01..5d08e4e8ff1ac4f253d855f7f126110244d74847 100644 --- a/net/minecraft/server/commands/TimeCommand.java +++ b/net/minecraft/server/commands/TimeCommand.java -@@ -119,7 +119,7 @@ public class TimeCommand { +@@ -119,7 +_,7 @@ final CommandSourceStack source, final SuggestionsBuilder builder, final Holder clock ) { return SharedSuggestionProvider.suggestResource( @@ -17,7 +9,7 @@ index ff3fbbeca288d5133a13449fe92f6d0aeae00a01..5d08e4e8ff1ac4f253d855f7f1261102 ); } -@@ -141,7 +141,7 @@ public class TimeCommand { +@@ -141,7 +_,7 @@ } private static int queryTime(final CommandSourceStack source, final Holder clock) { @@ -26,25 +18,24 @@ index ff3fbbeca288d5133a13449fe92f6d0aeae00a01..5d08e4e8ff1ac4f253d855f7f1261102 long totalTicks = clockManager.getTotalTicks(clock); source.sendSuccess(() -> Component.translatable("commands.time.query.absolute", clock.getRegisteredName(), totalTicks), false); return wrapTime(totalTicks); -@@ -151,7 +151,7 @@ public class TimeCommand { - if (!clock.equals(timeline.value().clock())) { +@@ -152,7 +_,7 @@ throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); - } else { -- ServerClockManager clockManager = source.getServer().clockManager(); -+ ServerClockManager clockManager = source.getLevel().clockManager(); // Paper - per-world time - long currentTicks = timeline.value().getCurrentTicks(clockManager); - source.sendSuccess(() -> Component.translatable("commands.time.query.timeline", timeline.getRegisteredName(), currentTicks), false); - return wrapTime(currentTicks); -@@ -162,33 +162,53 @@ public class TimeCommand { - if (!clock.equals(timeline.value().clock())) { + } + +- ServerClockManager clockManager = source.getServer().clockManager(); ++ ServerClockManager clockManager = source.getLevel().clockManager(); // Paper - per-world time + long currentTicks = timeline.value().getCurrentTicks(clockManager); + source.sendSuccess(() -> Component.translatable("commands.time.query.timeline", timeline.getRegisteredName(), currentTicks), false); + return wrapTime(currentTicks); +@@ -163,45 +_,67 @@ throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); - } else { -- ServerClockManager clockManager = source.getServer().clockManager(); -+ ServerClockManager clockManager = source.getLevel().clockManager(); // Paper - per-world time - long repetitions = timeline.value().getPeriodCount(clockManager); - source.sendSuccess(() -> Component.translatable("commands.time.query.timeline.repetitions", timeline.getRegisteredName(), repetitions), false); - return wrapTime(repetitions); } + +- ServerClockManager clockManager = source.getServer().clockManager(); ++ ServerClockManager clockManager = source.getLevel().clockManager(); // Paper - per-world time + long repetitions = timeline.value().getPeriodCount(clockManager); + source.sendSuccess(() -> Component.translatable("commands.time.query.timeline.repetitions", timeline.getRegisteredName(), repetitions), false); + return wrapTime(repetitions); } + // Paper start - per-world time @@ -87,18 +78,19 @@ index ff3fbbeca288d5133a13449fe92f6d0aeae00a01..5d08e4e8ff1ac4f253d855f7f1261102 + ServerClockManager clockManager = source.getLevel().clockManager(); + java.util.OptionalLong targetTime = clockManager.getTotalTicksToTimeMarker(clock, timeMarkerId); + if (targetTime.isEmpty()) { ++ // Paper end - per-world time throw ERROR_NO_TIME_MARKER_FOUND.create(clock.getRegisteredName(), timeMarkerId); - } else { -+ final long currentTime = clockManager.getTotalTicks(clock); -+ final org.bukkit.event.world.ClockTimeSkipEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.createTimeSkipEvent(source, targetTime.getAsLong() - currentTime); -+ if (event.callEvent()) { -+ clockManager.setTotalTicks(clock, currentTime + event.getSkipAmount()); -+ } -+ // Paper end - per-world time - source.sendSuccess( - () -> Component.translatable("commands.time.set.time_marker", clock.getRegisteredName(), timeMarkerId.identifier().toString()), true - ); -@@ -197,13 +217,13 @@ public class TimeCommand { + } + ++ // Paper start - per-world time ++ final long currentTime = clockManager.getTotalTicks(clock); ++ final org.bukkit.event.world.ClockTimeSkipEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.createTimeSkipEvent(source, targetTime.getAsLong() - currentTime); ++ if (event.callEvent()) { ++ clockManager.setTotalTicks(clock, currentTime + event.getSkipAmount()); ++ } ++ // Paper end - per-world time + source.sendSuccess(() -> Component.translatable("commands.time.set.time_marker", clock.getRegisteredName(), timeMarkerId.identifier().toString()), true); + return wrapTime(clockManager.getTotalTicks(clock)); } private static int setPaused(final CommandSourceStack source, final Holder clock, final boolean paused) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch new file mode 100644 index 000000000000..b1a73a1154b9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch @@ -0,0 +1,52 @@ +--- a/net/minecraft/world/item/TridentItem.java ++++ b/net/minecraft/world/item/TridentItem.java +@@ -80,18 +_,38 @@ + .orElse(SoundEvents.TRIDENT_THROW); + player.awardStat(Stats.ITEM_USED.get(this)); + if (level instanceof ServerLevel serverLevel) { +- itemStack.hurtWithoutBreaking(1, player); ++ // itemStack.hurtWithoutBreaking(1, player); // CraftBukkit - moved down + if (riptideStrength == 0.0F) { +- ItemStack thrownItemStack = itemStack.consumeAndReturn(1, player); +- ThrownTrident trident = Projectile.spawnProjectileFromRotation( ++ ItemStack thrownItemStack = itemStack.copyWithCount(1); // Paper ++ Projectile.Delayed tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent( + ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, 1.0F + ); ++ // Paper start - PlayerLaunchProjectileEvent ++ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity()); ++ if (!event.callEvent() || !tridentDelayed.attemptSpawn()) { ++ // CraftBukkit start ++ // Paper end - PlayerLaunchProjectileEvent ++ return false; ++ } ++ ThrownTrident trident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent ++ if (event.shouldConsume()) { ++ thrownItemStack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent - use thrownItemStack; pickup item damage ++ } ++ trident.pickupItemStack = thrownItemStack.copy(); // SPIGOT-4511 update since damage call moved - use thrownItemStack; count = 1 ++ if (event.shouldConsume()) { ++ itemStack.consume(1, player); ++ } ++ // CraftBukkit end + if (player.hasInfiniteMaterials()) { + trident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; + } + + level.playSound(null, trident, sound.value(), SoundSource.PLAYERS, 1.0F, 1.0F); + return true; ++ // CraftBukkit start - SPIGOT-5458 also need in this branch :( ++ } else { ++ itemStack.hurtWithoutBreaking(1, player); ++ // CraftBukkit end + } + } + +@@ -105,6 +_,7 @@ + xd *= riptideStrength / dist; + yd *= riptideStrength / dist; + zd *= riptideStrength / dist; ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(player, itemStack, xd, yd, zd)) return false; // Paper - Add player riptide event + player.push(xd, yd, zd); + player.startAutoSpinAttack(20, 8.0F, itemStack); + if (player.onGround()) { From 8592abbea95be6d77e3e923d569849357b0f975b Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 20:36:18 +0100 Subject: [PATCH 07/16] 60 --- .../server/commands/BanIpCommands.java.patch | 19 - .../minecraft/commands/Commands.java.patch | 50 +- .../server/commands/BanIpCommands.java.patch | 11 + .../server/level/ChunkHolder.java.patch | 40 +- .../server/level/ChunkMap.java.patch | 99 ++- .../server/level/ServerChunkCache.java.patch | 64 +- .../server/level/ServerLevel.java.patch | 161 +++-- .../server/level/ServerPlayer.java.patch | 611 +++++++++--------- .../level/ServerPlayerGameMode.java.patch | 273 ++++---- .../server/level/WorldGenRegion.java.patch | 56 +- .../decoration/BlockAttachedEntity.java.patch | 93 +-- 11 files changed, 702 insertions(+), 775 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/server/commands/BanIpCommands.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/commands/Commands.java.patch (90%) create mode 100644 paper-server/patches/sources/net/minecraft/server/commands/BanIpCommands.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ChunkHolder.java.patch (86%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ChunkMap.java.patch (81%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ServerChunkCache.java.patch (79%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ServerLevel.java.patch (89%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ServerPlayer.java.patch (79%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/ServerPlayerGameMode.java.patch (64%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/level/WorldGenRegion.java.patch (57%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch (62%) diff --git a/paper-server/patches/rejected/net/minecraft/server/commands/BanIpCommands.java.patch b/paper-server/patches/rejected/net/minecraft/server/commands/BanIpCommands.java.patch deleted file mode 100644 index 9da4904e24a9..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/commands/BanIpCommands.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/commands/BanIpCommands.java b/net/minecraft/server/commands/BanIpCommands.java -index 82f565f54749c630f01a6f50b67d93518170152e..36b858bfe123edc2f1c5c7861dd0e4475ef7a5f1 100644 ---- a/net/minecraft/server/commands/BanIpCommands.java -+++ b/net/minecraft/server/commands/BanIpCommands.java -@@ -62,7 +62,7 @@ public class BanIpCommands { - } - - for (ServerPlayer player : players) { -- player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned")); -+ player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED); // Paper - kick event cause - } - - return players.size(); diff --git a/paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch similarity index 90% rename from paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch rename to paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index 5ff202861060..ebd705212a61 100644 --- a/paper-server/patches/rejected/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786eef5c3031 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -157,6 +157,7 @@ import org.jspecify.annotations.Nullable; +@@ -156,6 +_,7 @@ import org.slf4j.Logger; public class Commands { @@ -16,7 +8,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e public static final String COMMAND_PREFIX = "/"; private static final ThreadLocal<@Nullable ExecutionContext> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); private static final Logger LOGGER = LogUtils.getLogger(); -@@ -181,6 +182,7 @@ public class Commands { +@@ -180,6 +_,7 @@ @Override public boolean isRestricted(final CommandNode node) { @@ -24,7 +16,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e Predicate requirement = node.getRequirement(); return !requirement.test(this.noPermissionSource); } -@@ -188,6 +190,11 @@ public class Commands { +@@ -187,6 +_,11 @@ private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(final Commands.CommandSelection commandSelection, final CommandBuildContext context) { @@ -36,7 +28,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -299,6 +306,42 @@ public class Commands { +@@ -298,6 +_,42 @@ PublishCommand.register(this.dispatcher); } @@ -79,7 +71,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -318,6 +361,13 @@ public class Commands { +@@ -317,6 +_,13 @@ } public void performCommand(final ParseResults command, final String commandString) { @@ -93,36 +85,36 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e CommandSourceStack sender = command.getContext().getSource(); Profiler.get().push(() -> "/" + commandString); ContextChain commandChain = finishParsing(command, commandString, sender); -@@ -331,10 +381,12 @@ public class Commands { +@@ -330,10 +_,12 @@ ) ); } -- } catch (Exception var12) { +- } catch (Exception e) { + // Paper start -+ } catch (Throwable var12) { // always gracefully handle it, no matter how bad:tm: -+ if (throwCommandError) throw var12; // rethrow directly if requested - MutableComponent hover = Component.literal(var12.getMessage() == null ? var12.getClass().getName() : var12.getMessage()); ++ } catch (Throwable e) { // always gracefully handle it, no matter how bad:tm: ++ if (throwCommandError) throw e; // rethrow directly if requested + MutableComponent hover = Component.literal(e.getMessage() == null ? e.getClass().getName() : e.getMessage()); - if (LOGGER.isDebugEnabled()) { -- LOGGER.error("Command exception: /{}", commandString, var12); -+ LOGGER.error("Command exception: /{}", commandString, var12); // Paper - always show execution exception in console log +- LOGGER.error("Command exception: /{}", commandString, e); ++ LOGGER.error("Command exception: /{}", commandString, e); // Paper - always show execution exception in console log + if (sender.getServer().isDebugging() || LOGGER.isDebugEnabled()) { // Paper - Debugging - StackTraceElement[] stackTrace = var12.getStackTrace(); + StackTraceElement[] stackTrace = e.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -365,7 +417,11 @@ public class Commands { +@@ -364,7 +_,11 @@ return ContextChain.tryFlatten(command.getContext().build(commandString)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(command.getReader())); - } catch (CommandSyntaxException var7) { -- sender.sendFailure(ComponentUtils.fromMessage(var7.getRawMessage())); + } catch (CommandSyntaxException e) { +- sender.sendFailure(ComponentUtils.fromMessage(e.getRawMessage())); + // Paper start - Add UnknownCommandEvent + final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text(); + // sender.sendFailure(ComponentUtils.fromMessage(var7.getRawMessage())); + builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage())); + // Paper end - Add UnknownCommandEvent - if (var7.getInput() != null && var7.getCursor() >= 0) { - int cursor = Math.min(var7.getInput().length(), var7.getCursor()); + if (e.getInput() != null && e.getCursor() >= 0) { + int cursor = Math.min(e.getInput().length(), e.getCursor()); MutableComponent context = Component.empty() -@@ -382,7 +438,17 @@ public class Commands { +@@ -381,7 +_,17 @@ } context.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -141,7 +133,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e } return null; -@@ -410,19 +476,112 @@ public class Commands { +@@ -409,19 +_,112 @@ } public void sendCommands(final ServerPlayer player) { @@ -257,7 +249,7 @@ index 798054fc87e770746c90f59e35fe46e40bbe29d1..a882caec9d4ad21605eaafeb2872786e if (builder.getRedirect() != null) { builder.redirect(converted.get(builder.getRedirect())); } -@@ -431,7 +590,7 @@ public class Commands { +@@ -430,7 +_,7 @@ converted.put(child, node); target.addChild(node); if (!child.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/BanIpCommands.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/BanIpCommands.java.patch new file mode 100644 index 000000000000..cd0718c09501 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/commands/BanIpCommands.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/commands/BanIpCommands.java ++++ b/net/minecraft/server/commands/BanIpCommands.java +@@ -63,7 +_,7 @@ + } + + for (ServerPlayer player : players) { +- player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned")); ++ player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED); // Paper - kick event cause + } + + return players.size(); diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch similarity index 86% rename from paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch index 5d861dd9e7fb..52808dc0fd74 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ChunkHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ChunkHolder.java b/net/minecraft/server/level/ChunkHolder.java -index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e4a44285c 100644 --- a/net/minecraft/server/level/ChunkHolder.java +++ b/net/minecraft/server/level/ChunkHolder.java -@@ -33,9 +33,9 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -33,9 +_,9 @@ public static final ChunkResult UNLOADED_LEVEL_CHUNK = ChunkResult.error("Unloaded level chunk"); private static final CompletableFuture> UNLOADED_LEVEL_CHUNK_FUTURE = CompletableFuture.completedFuture(UNLOADED_LEVEL_CHUNK); private final LevelHeightAccessor levelHeightAccessor; @@ -21,7 +13,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e public int oldTicketLevel; private int ticketLevel; private int queueLevel; -@@ -71,6 +71,18 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -71,6 +_,18 @@ this.changedBlocksPerSection = new ShortSet[levelHeightAccessor.getSectionsCount()]; } @@ -40,7 +32,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e public CompletableFuture> getTickingChunkFuture() { return this.tickingChunkFuture; } -@@ -83,7 +95,7 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -83,7 +_,7 @@ return this.fullChunkFuture; } @@ -49,15 +41,15 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); } -@@ -127,6 +139,7 @@ public class ChunkHolder extends GenerationChunkHolder { - } else { - boolean hadChangedSections = this.hasChangedSections; - int sectionIndex = this.levelHeightAccessor.getSectionIndex(pos.getY()); -+ if (sectionIndex < 0 || sectionIndex >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 - ShortSet changedBlocksInSection = this.changedBlocksPerSection[sectionIndex]; - if (changedBlocksInSection == null) { - this.hasChangedSections = true; -@@ -270,6 +283,38 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -128,6 +_,7 @@ + + boolean hadChangedSections = this.hasChangedSections; + int sectionIndex = this.levelHeightAccessor.getSectionIndex(pos.getY()); ++ if (sectionIndex < 0 || sectionIndex >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 + ShortSet changedBlocksInSection = this.changedBlocksPerSection[sectionIndex]; + if (changedBlocksInSection == null) { + this.hasChangedSections = true; +@@ -270,6 +_,38 @@ scheduler.onFullChunkStatusChange(this.pos, status); } @@ -96,7 +88,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e protected void updateFutures(final ChunkMap scheduler, final Executor mainThreadExecutor) { FullChunkStatus oldFullStatus = ChunkLevel.fullStatus(this.oldTicketLevel); FullChunkStatus newFullStatus = ChunkLevel.fullStatus(this.ticketLevel); -@@ -277,12 +322,28 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -277,12 +_,28 @@ boolean isAccessible = newFullStatus.isOrAfter(FullChunkStatus.FULL); this.wasAccessibleSinceLastSave |= isAccessible; if (!wasAccessible && isAccessible) { @@ -125,7 +117,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e this.fullChunkFuture.complete(UNLOADED_LEVEL_CHUNK); this.fullChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -292,11 +353,25 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -292,11 +_,25 @@ if (!wasTicking && isTicking) { this.tickingChunkFuture = scheduler.prepareTickingChunk(this); this.scheduleFullChunkPromotion(scheduler, this.tickingChunkFuture, mainThreadExecutor, FullChunkStatus.BLOCK_TICKING); @@ -152,7 +144,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e this.tickingChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -309,11 +384,24 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -309,11 +_,24 @@ this.entityTickingChunkFuture = scheduler.prepareEntityTickingChunk(this); this.scheduleFullChunkPromotion(scheduler, this.entityTickingChunkFuture, mainThreadExecutor, FullChunkStatus.ENTITY_TICKING); @@ -178,7 +170,7 @@ index 9c3ccc96b75a847b0e3305e8e9527bf2edf86505..60d7c6ddbd179ddaa75a9211bdf8902e this.entityTickingChunkFuture = UNLOADED_LEVEL_CHUNK_FUTURE; } -@@ -323,6 +411,26 @@ public class ChunkHolder extends GenerationChunkHolder { +@@ -323,6 +_,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch similarity index 81% rename from paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 5ff21858af70..f84b2e35a3a1 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e299a9c3408 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -152,6 +152,33 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -152,6 +_,33 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -42,7 +34,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 public ChunkMap( final ServerLevel level, final LevelStorageSource.LevelStorageAccess levelStorage, -@@ -179,13 +206,19 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -179,13 +_,19 @@ this.level = level; RegistryAccess registryAccess = level.registryAccess(); long levelSeed = level.getSeed(); @@ -64,7 +56,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor worldgen = new ConsecutiveExecutor(executor, "worldgen"); this.chunkStatusListener = chunkStatusListener; -@@ -212,6 +245,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -212,6 +_,12 @@ this.chunksToEagerlySave.add(chunkPos.pack()); } @@ -77,7 +69,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -348,9 +387,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -348,9 +_,9 @@ } }); sb.append("Updating:").append(System.lineSeparator()); @@ -89,15 +81,15 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 CrashReport report = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory category = report.addCategory("Chunk loading"); category.setDetail("Details", details); -@@ -385,6 +424,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP - chunk.setTicketLevel(level); - } else { - chunk = new ChunkHolder(ChunkPos.unpack(node), level, this.level, this.lightEngine, this::onLevelChange, this); -+ ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, chunk); // Paper - } +@@ -386,6 +_,7 @@ + chunk.setTicketLevel(level); + } else { + chunk = new ChunkHolder(ChunkPos.unpack(node), level, this.level, this.lightEngine, this::onLevelChange, this); ++ ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, chunk); // Paper + } - this.updatingChunkMap.put(node, chunk); -@@ -413,8 +453,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + this.updatingChunkMap.put(node, chunk); +@@ -413,8 +_,8 @@ protected void saveAllChunks(final boolean flushStorage) { if (flushStorage) { @@ -108,7 +100,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -440,7 +480,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -440,7 +_,7 @@ this.nextChunkSaveTime.clear(); long now = Util.getMillis(); @@ -117,7 +109,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 this.saveChunkIfNeeded(chunk, now); } } -@@ -461,6 +501,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -461,6 +_,7 @@ public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -125,7 +117,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -519,7 +560,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -519,7 +_,11 @@ this.scheduleUnload(pos, chunkHolder); } else { ChunkAccess chunk = chunkHolder.getLatestChunk(); @@ -138,7 +130,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 if (chunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -532,7 +577,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -532,7 +_,9 @@ this.lightEngine.updateChunkStatus(chunk.getPos()); this.lightEngine.tryScheduleUpdate(); this.nextChunkSaveTime.remove(chunk.getPos().pack()); @@ -149,7 +141,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 } }, this.unloadQueue::add).whenComplete((ignored, throwable) -> { if (throwable != null) { -@@ -841,7 +888,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -843,7 +_,7 @@ } public int size() { @@ -158,7 +150,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -868,10 +915,10 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -870,10 +_,10 @@ .addColumn("fluid_ticks") .build(output); @@ -173,7 +165,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 Optional chunk = Optional.ofNullable(holder.getLatestChunk()); Optional fullChunk = chunk.flatMap( chunkAccess -> chunkAccess instanceof LevelChunk ? Optional.of((LevelChunk)chunkAccess) : Optional.empty() -@@ -920,14 +967,14 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -922,14 +_,14 @@ return this.upgradeChunkTag( tag, -1, @@ -191,7 +183,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 generatorIdentifier.ifPresent(identifier -> contextTag.putString("generator", identifier.toString())); return contextTag; } -@@ -939,7 +986,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -941,7 +_,7 @@ ChunkHolder holder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (holder != null) { LevelChunk chunk = holder.getTickingChunk(); @@ -200,7 +192,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 output.add(chunk); } } -@@ -959,8 +1006,14 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -961,8 +_,14 @@ } public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) { @@ -216,7 +208,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 } boolean anyPlayerCloseEnoughTo(final BlockPos pos, final int maxDistance) { -@@ -976,8 +1029,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -978,8 +_,24 @@ } private boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) { @@ -242,31 +234,32 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 return true; } } -@@ -993,7 +1062,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP - Builder builder = ImmutableList.builder(); +@@ -996,7 +_,7 @@ + Builder builder = ImmutableList.builder(); - for (ServerPlayer player : this.playerMap.getAllPlayers()) { -- if (this.playerIsCloseEnoughForSpawning(player, pos)) { -+ if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot - builder.add(player); - } + for (ServerPlayer player : this.playerMap.getAllPlayers()) { +- if (this.playerIsCloseEnoughForSpawning(player, pos)) { ++ if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot + builder.add(player); } -@@ -1002,12 +1071,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } +@@ -1004,13 +_,13 @@ + return builder.build(); } - private boolean playerIsCloseEnoughForSpawning(final ServerPlayer player, final ChunkPos pos) { + private boolean playerIsCloseEnoughForSpawning(final ServerPlayer player, final ChunkPos pos, final double range) { // Spigot if (player.isSpectator()) { return false; - } else { - double distanceToChunk = euclideanDistanceSquared(pos, player.position()); -- return distanceToChunk < 16384.0; -+ return distanceToChunk < range; // Spigot } + + double distanceToChunk = euclideanDistanceSquared(pos, player.position()); +- return distanceToChunk < 16384.0; ++ return distanceToChunk < range; // Spigot } -@@ -1136,9 +1205,19 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + private boolean playerIsCloseEnoughTo(final ServerPlayer player, final Vec3 pos, final int maxDistance) { +@@ -1138,9 +_,19 @@ } public void addEntity(final Entity entity) { @@ -286,7 +279,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 if (range != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1162,6 +1241,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1164,6 +_,7 @@ } protected void removeEntity(final Entity entity) { @@ -294,18 +287,20 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 if (entity instanceof ServerPlayer player) { this.updatePlayerStatus(player, false); -@@ -1329,8 +1409,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1325,10 +_,10 @@ + private final Entity entity; + private final int range; + private SectionPos lastSectionPos; +- public final Set seenBy = Sets.newIdentityHashSet(); ++ public final Set seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl + public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { - Objects.requireNonNull(ChunkMap.this); - super(); -- this.seenBy = Sets.newIdentityHashSet(); - this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this); -+ this.seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl + this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1377,6 +1457,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1375,6 +_,7 @@ } public void removePlayer(final ServerPlayer player) { @@ -313,7 +308,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1386,23 +1467,47 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1384,23 +_,47 @@ } public void updatePlayer(final ServerPlayer player) { @@ -364,7 +359,7 @@ index a8ead972b8b12a21387e06d8d0abc535a1df5c19..c129d7a0823d7eaae677ca3b54839e29 } } else { this.removePlayer(player); -@@ -1419,6 +1524,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1417,6 +_,7 @@ for (Entity passenger : this.entity.getIndirectPassengers()) { int passengerRange = passenger.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index 0130739821bb..6c6d0782b322 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59e2ed2f5e 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -66,6 +66,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -66,6 +_,7 @@ private final TicketStorage ticketStorage; private long lastInhabitedUpdate; public boolean spawnEnemies = true; @@ -16,7 +8,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 private static final int CACHE_SIZE = 4; private final long[] lastChunkPos = new long[4]; private final @Nullable ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; -@@ -74,6 +75,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -74,6 +_,13 @@ private final Set chunkHoldersToBroadcast = new ReferenceOpenHashSet<>(); @VisibleForDebug private NaturalSpawner.@Nullable SpawnState lastSpawnState; @@ -30,7 +22,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 public ServerChunkCache( final ServerLevel level, -@@ -87,6 +95,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -87,6 +_,7 @@ final boolean syncWrites, final ChunkStatusUpdateListener chunkStatusListener, final Supplier overworldDataStorage @@ -38,8 +30,8 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 ) { this.level = level; this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(level); -@@ -99,7 +108,7 @@ public class ServerChunkCache extends ChunkSource { - LOGGER.error("Failed to create dimension data storage directory", (Throwable)var14); +@@ -99,7 +_,7 @@ + LOGGER.error("Failed to create dimension data storage directory", e); } - this.savedDataStorage = new SavedDataStorage(dataFolder, fixerUpper, level.registryAccess()); @@ -47,7 +39,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 this.ticketStorage = this.savedDataStorage.computeIfAbsent(TicketStorage.TYPE); this.chunkMap = new ChunkMap( level, -@@ -122,6 +131,64 @@ public class ServerChunkCache extends ChunkSource { +@@ -122,6 +_,64 @@ this.clearCache(); } @@ -112,24 +104,16 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -155,7 +222,7 @@ public class ServerChunkCache extends ChunkSource { - for (int i = 0; i < 4; i++) { - if (pos == this.lastChunkPos[i] && targetStatus == this.lastChunkStatus[i]) { - ChunkAccess chunkAccess = this.lastChunk[i]; -- if (chunkAccess != null || !loadOrGenerate) { -+ if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime - return chunkAccess; - } +@@ -156,7 +_,7 @@ + for (int i = 0; i < 4; i++) { + if (pos == this.lastChunkPos[i] && targetStatus == this.lastChunkStatus[i]) { + ChunkAccess chunkAccess = this.lastChunk[i]; +- if (chunkAccess != null || !loadOrGenerate) { ++ if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime + return chunkAccess; } -@@ -164,6 +231,7 @@ public class ServerChunkCache extends ChunkSource { - profiler.incrementCounter("getChunkCacheMiss"); - CompletableFuture> serverFuture = this.getChunkFutureMainThread(x, z, targetStatus, loadOrGenerate); - this.mainThreadProcessor.managedBlock(serverFuture::isDone); -+ // com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x, z); // Paper - Add debug for sync chunk loads - ChunkResult chunkResult = serverFuture.join(); - ChunkAccess chunk = chunkResult.orElse(null); - if (chunk == null && loadOrGenerate) { -@@ -236,7 +304,15 @@ public class ServerChunkCache extends ChunkSource { + } +@@ -236,7 +_,15 @@ long key = pos.pack(); int targetTicketLevel = ChunkLevel.byStatus(targetStatus); ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(key); @@ -146,7 +130,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 this.addTicket(new Ticket(TicketType.UNKNOWN, targetTicketLevel), pos); if (this.chunkAbsent(chunkHolder, targetTicketLevel)) { ProfilerFiller profiler = Profiler.get(); -@@ -256,7 +332,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -256,7 +_,7 @@ } private boolean chunkAbsent(final @Nullable ChunkHolder chunkHolder, final int targetTicketLevel) { @@ -155,7 +139,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 } @Override -@@ -310,17 +386,39 @@ public class ServerChunkCache extends ChunkSource { +@@ -310,17 +_,39 @@ @Override public void close() throws IOException { @@ -197,7 +181,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -344,7 +442,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -344,7 +_,7 @@ if (!this.level.isDebug()) { ProfilerFiller profiler = Profiler.get(); profiler.push("pollingChunks"); @@ -206,7 +190,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 profiler.push("tickingChunks"); this.tickChunks(profiler, timeDiff); profiler.pop(); -@@ -376,12 +474,20 @@ public class ServerChunkCache extends ChunkSource { +@@ -376,12 +_,20 @@ chunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnCookie; @@ -231,7 +215,7 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 } else { spawningCategories = List.of(); } -@@ -556,7 +662,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -558,7 +_,13 @@ @Override public void setSpawnSettings(final boolean spawnEnemies) { @@ -245,17 +229,17 @@ index 7dc458e02d1af284146162d4d015fda3a5c4518c..bf8496c8cadb29db9c46015e202e7d59 } public String getChunkDebugData(final ChunkPos pos) { -@@ -624,12 +736,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -625,12 +_,18 @@ @Override protected boolean pollTask() { + try { // CraftBukkit - process pending Chunk loadCallback() and unloadCallback() after each run task if (ServerChunkCache.this.runDistanceManagerUpdates()) { return true; - } else { - ServerChunkCache.this.lightEngine.tryScheduleUpdate(); - return super.pollTask(); } + + ServerChunkCache.this.lightEngine.tryScheduleUpdate(); + return super.pollTask(); + // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task + } finally { + ServerChunkCache.this.chunkMap.callbackExecutor.run(); diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch similarity index 89% rename from paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 493d935eb6cf..134f77c5b1c4 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a0d644721 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -194,7 +194,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -194,7 +_,7 @@ private final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -17,7 +9,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a private final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; private EnvironmentAttributeSystem environmentAttributes; -@@ -221,24 +221,199 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -221,24 +_,199 @@ private final boolean tickTime; private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -219,7 +211,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a boolean syncWrites = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityStorage = new EntityStorage( -@@ -260,16 +435,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -260,16 +_,17 @@ server.getStructureManager(), executor, generator, @@ -240,7 +232,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } this.raids = this.getDataStorage().computeIfAbsent(Raids.TYPE); -@@ -277,14 +453,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -277,14 +_,13 @@ levelData.setGameType(server.getDefaultGameType()); } @@ -256,7 +248,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a generator, this.chunkSource.randomState(), this, -@@ -300,10 +475,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -300,10 +_,18 @@ this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); @@ -264,6 +256,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a + this.waypointManager = new ServerWaypointManager(this); // Paper - optimize ServerWaypointManager with locator bar disabled this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); this.updateSkyBrightness(); +- } + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + } + @@ -271,12 +264,12 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a + @Override + public boolean hasChunk(int chunkX, int chunkZ) { + return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null; - } ++ } + // Paper end @Deprecated @VisibleForTesting -@@ -322,7 +505,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -322,7 +_,7 @@ @Override public ServerClockManager clockManager() { @@ -285,7 +278,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } @Override -@@ -354,11 +537,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -354,11 +_,24 @@ int percentage = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(percentage) && this.sleepStatus.areEnoughDeepSleeping(percentage, this.players)) { Optional> defaultClock = this.dimensionType().defaultClock(); @@ -312,7 +305,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -373,9 +569,9 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -373,9 +_,9 @@ if (!this.isDebug() && runs) { long tick = this.getGameTime(); profiler.push("blockTicks"); @@ -324,7 +317,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a profiler.pop(); } -@@ -393,7 +589,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -393,7 +_,7 @@ this.handlingTick = false; profiler.pop(); @@ -333,7 +326,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (isActive) { this.resetEmptyTime(); } -@@ -437,9 +633,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -437,9 +_,12 @@ } } ); @@ -346,7 +339,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } profiler.push("entityManagement"); -@@ -468,7 +667,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -468,7 +_,7 @@ long time = this.levelData.getGameTime() + 1L; this.serverLevelData.setGameTime(time); Profiler.get().push("scheduledFunctions"); @@ -355,7 +348,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a Profiler.get().pop(); } } -@@ -491,11 +690,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -491,11 +_,13 @@ ProfilerFiller profiler = Profiler.get(); profiler.push("iceandsnow"); @@ -369,7 +362,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a profiler.popPush("tickBlocks"); if (tickSpeed > 0) { -@@ -536,12 +737,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -536,12 +_,12 @@ int minZ = chunkPos.getMinBlockZ(); ProfilerFiller profiler = Profiler.get(); profiler.push("thunder"); @@ -384,7 +377,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a && !this.getBlockState(pos.below()).is(BlockTags.LIGHTNING_RODS); if (isTrap) { SkeletonHorse horse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -549,7 +750,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -549,7 +_,7 @@ horse.setTrap(true); horse.setAge(0); horse.setPos(pos.getX(), pos.getY(), pos.getZ()); @@ -393,7 +386,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } } -@@ -557,7 +758,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -557,7 +_,7 @@ if (bolt != null) { bolt.snapTo(Vec3.atBottomCenterOf(pos)); bolt.setVisualOnly(isTrap); @@ -402,7 +395,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } } } -@@ -571,7 +772,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -571,7 +_,7 @@ BlockPos belowPos = topPos.below(); Biome biome = this.getBiome(topPos).value(); if (biome.shouldFreeze(this, belowPos)) { @@ -411,7 +404,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } if (this.isRaining()) { -@@ -583,10 +784,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -583,10 +_,10 @@ if (currentLayers < Math.min(maxHeight, 8)) { BlockState newState = state.setValue(SnowLayerBlock.LAYERS, currentLayers + 1); Block.pushEntitiesUp(state, newState, this, topPos); @@ -424,7 +417,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } } -@@ -611,16 +812,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -611,6 +_,13 @@ } protected BlockPos findLightningTargetAround(final BlockPos pos) { @@ -438,19 +431,21 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a BlockPos center = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional lightningRodTarget = this.findLightningRod(center); if (lightningRodTarget.isPresent()) { - return lightningRodTarget.get(); - } else { - AABB search = AABB.encapsulatingFullBlocks(center, center.atY(this.getMaxY() + 1)).inflate(3.0); -- List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition())); -+ List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition()) && !input.isSpectator()); // Paper - Fix lightning being able to hit spectators (MC-262422) - if (!entities.isEmpty()) { - return entities.get(this.random.nextInt(entities.size())).blockPosition(); - } else { -+ if (returnNullWhenNoTarget) return null; // Paper - Add methods to find targets for lightning strikes - if (center.getY() == this.getMinY() - 1) { - center = center.above(2); - } -@@ -739,8 +948,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -618,11 +_,12 @@ + } + + AABB search = AABB.encapsulatingFullBlocks(center, center.atY(this.getMaxY() + 1)).inflate(3.0); +- List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition())); ++ List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition()) && !input.isSpectator()); // Paper - Fix lightning being able to hit spectators (MC-262422) + if (!entities.isEmpty()) { + return entities.get(this.random.nextInt(entities.size())).blockPosition(); + } + ++ if (returnNullWhenNoTarget) return null; // Paper - Add methods to find targets for lightning strikes + if (center.getY() == this.getMinY() - 1) { + center = center.above(2); + } +@@ -739,8 +_,8 @@ weatherData.setThunderTime(thunderTime); weatherData.setRainTime(rainTime); weatherData.setClearWeatherTime(clearWeatherTime); @@ -461,7 +456,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } this.oThunderLevel = this.thunderLevel; -@@ -761,6 +970,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -761,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -469,7 +464,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -783,15 +993,48 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -783,15 +_,48 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -522,7 +517,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } public void resetEmptyTime() { -@@ -813,18 +1056,46 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -813,18 +_,46 @@ } } @@ -569,7 +564,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } private void tickPassenger(final Entity vehicle, final Entity entity) { -@@ -833,10 +1104,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -833,10 +_,12 @@ } else if (entity instanceof Player || this.entityTickList.contains(entity)) { entity.setOldPosAndRot(); entity.tickCount++; @@ -582,7 +577,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a profiler.pop(); for (Entity passenger : entity.getPassengers()) { -@@ -867,6 +1140,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -867,6 +_,7 @@ public void save(final @Nullable ProgressListener progressListener, final boolean flush, final boolean noSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!noSave) { @@ -590,7 +585,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -887,6 +1161,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -887,6 +_,7 @@ private void saveLevelData(final boolean sync) { SavedDataStorage savedDataStorage = this.getChunkSource().getDataStorage(); @@ -598,7 +593,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (sync) { savedDataStorage.saveAndJoin(); } else { -@@ -949,18 +1224,40 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -949,18 +_,40 @@ @Override public boolean addFreshEntity(final Entity entity) { @@ -642,7 +637,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } } -@@ -983,42 +1280,121 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -983,42 +_,121 @@ this.entityManager.addNewEntity(player); } @@ -689,11 +684,11 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a + // CraftBukkit end if (entity.getSelfAndPassengers().map(Entity::getUUID).anyMatch(this.entityManager::isLoaded)) { return false; - } else { -- this.addFreshEntityWithPassengers(entity); -+ this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit - return true; } + +- this.addFreshEntityWithPassengers(entity); ++ this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit + return true; } public void unload(final LevelChunk levelChunk) { @@ -717,14 +712,15 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a public void removePlayerImmediately(final ServerPlayer player, final Entity.RemovalReason reason) { - player.remove(reason); +- } + player.remove(reason, null); // CraftBukkit - add Bukkit remove cause + } + + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { + return this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.UNKNOWN); - } - ++ } ++ + public boolean strikeLightning(Entity entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause cause) { + org.bukkit.event.weather.LightningStrikeEvent lightning = org.bukkit.craftbukkit.event.CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + @@ -735,7 +731,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a + return this.addFreshEntity(entitylightning); + } + // CraftBukkit end -+ + @Override public void destroyBlockProgress(final int id, final BlockPos blockPos, final int progress) { + // CraftBukkit start @@ -768,7 +764,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a player.connection.send(new ClientboundBlockDestructionPacket(id, blockPos, progress)); } } -@@ -1106,7 +1482,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1106,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -777,7 +773,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1118,6 +1494,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1118,6 +_,11 @@ @Override public void gameEvent(final Holder gameEvent, final Vec3 position, final GameEvent.Context context) { @@ -789,7 +785,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a this.gameEventDispatcher.post(gameEvent, position, context); } -@@ -1130,17 +1511,28 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1130,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -818,7 +814,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a try { this.isUpdatingNavigations = true; -@@ -1152,15 +1544,23 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1152,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -842,7 +838,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, null, orientation); } -@@ -1214,6 +1614,44 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1214,6 +_,44 @@ final WeightedList blockParticles, final Holder explosionSound ) { @@ -887,7 +883,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a Explosion.BlockInteraction blockInteraction = switch (interactionType) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); -@@ -1222,10 +1660,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1222,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -905,7 +901,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a ParticleOptions explosionParticle = explosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer player : this.players) { -@@ -1234,6 +1679,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1234,6 +_,8 @@ player.connection.send(new ClientboundExplodePacket(center, r, blockCount, playerKnockback, explosionParticle, explosionSound, blockParticles)); } } @@ -914,7 +910,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } private Explosion.BlockInteraction getDestroyType(final GameRule gameRule) { -@@ -1311,7 +1758,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1311,7 +_,7 @@ final double zDist, final double speed ) { @@ -923,7 +919,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } public int sendParticles( -@@ -1327,13 +1774,49 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1327,13 +_,49 @@ final double zDist, final double speed ) { @@ -975,16 +971,16 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (this.sendParticles(player, overrideLimiter, x, y, z, packet)) { result++; } -@@ -1421,7 +1904,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1421,7 +_,7 @@ public @Nullable BlockPos findNearestMapStructure( final TagKey structureTag, final BlockPos origin, final int maxSearchRadius, final boolean createReference ) { - if (!this.server.getWorldGenSettings().options().generateStructures()) { + if (!this.worldGenSettings.options().generateStructures()) { // CraftBukkit return null; - } else { - Optional> tag = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1479,10 +1962,36 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet + } + +@@ -1479,10 +_,36 @@ @Override public @Nullable MapItemSavedData getMapData(final MapId id) { @@ -1022,7 +1018,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a this.getServer().getDataStorage().set(MapItemSavedData.type(id), data); } -@@ -1492,7 +2001,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1492,7 +_,20 @@ @Override public void setRespawnData(final LevelData.RespawnData respawnData) { @@ -1044,7 +1040,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } @Override -@@ -1529,6 +2051,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1529,6 +_,11 @@ this.debugSynchronizers.dropPoi(immutable); })); newType.ifPresent(poiType -> this.getServer().execute(() -> { @@ -1056,7 +1052,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a PoiRecord record = this.getPoiManager().add(immutable, (Holder)poiType); if (record != null) { this.debugSynchronizers.registerPoi(record); -@@ -1677,12 +2204,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1677,12 +_,12 @@ } public boolean isFlat() { @@ -1071,7 +1067,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } public @Nullable EnderDragonFight getDragonFight() { -@@ -1690,7 +2217,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1690,7 +_,7 @@ } public WeatherData getWeatherData() { @@ -1080,7 +1076,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } @Override -@@ -1737,6 +2264,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1737,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1088,11 +1084,12 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a return this.entityManager.getEntityGetter(); } -@@ -1841,8 +2369,30 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1841,8 +_,30 @@ } public GameRules getGameRules() { - return this.server.getGameRules(); +- } + return this.gameRules; // Paper - per-level GameRules + } + @@ -1115,12 +1112,12 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlags(), 512); + } - } ++ } + // Paper end - notify observers even if grow failed @Override public CrashReportCategory fillReportDetails(final CrashReport report) { -@@ -1905,6 +2455,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1900,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypoint && waypoint.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypoint); } @@ -1128,7 +1125,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } @Override -@@ -1918,17 +2469,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1913,17 +_,24 @@ @Override public void onTickingStart(final Entity entity) { @@ -1154,7 +1151,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a if (entity instanceof ServerPlayer player) { ServerLevel.this.players.add(player); if (player.isReceivingWaypoints()) { -@@ -1943,7 +2501,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1938,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1163,7 +1160,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1960,10 +2518,52 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1955,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1216,7 +1213,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer player) { ServerLevel.this.players.remove(player); -@@ -1972,7 +2572,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1967,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1225,7 +1222,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1990,6 +2590,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1985,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1241,7 +1238,7 @@ index 26f49ed11b207ca5abe5a4953cd5b7f05262ec3a..f39d48821d728232472ebc5bd6868e6a } @Override -@@ -1997,4 +2606,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1992,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index b1837fc8eed2..79221cdf5182 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -253,7 +253,8 @@ public class ServerPlayer extends Player { +@@ -252,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -18,7 +10,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -308,6 +309,13 @@ public class ServerPlayer extends Player { +@@ -297,6 +_,13 @@ } } @@ -32,7 +24,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 @Override public void sendSlotChange(final AbstractContainerMenu container, final int slotIndex, final ItemStack itemStack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slotIndex, itemStack)); -@@ -347,6 +355,32 @@ public class ServerPlayer extends Player { +@@ -332,6 +_,32 @@ } } @@ -65,7 +57,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 @Override public void dataChanged(final AbstractContainerMenu container, final int id, final int value) { } -@@ -377,10 +411,43 @@ public class ServerPlayer extends Player { +@@ -358,10 +_,43 @@ public void sendSystemMessage(final Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -109,7 +101,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) { super(level, gameProfile); -@@ -391,8 +458,14 @@ public class ServerPlayer extends Player { +@@ -372,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((id, output) -> server.getRecipeManager().listDisplaysForRecipe(id, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -125,7 +117,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -410,6 +483,7 @@ public class ServerPlayer extends Player { +@@ -391,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(p -> this.recipeBook.loadUntrusted(p, id -> this.server.getRecipeManager().byKey(id).isPresent())); @@ -133,7 +125,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (this.isSleeping()) { this.stopSleeping(); } -@@ -417,6 +491,19 @@ public class ServerPlayer extends Player { +@@ -398,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -153,7 +145,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -444,12 +531,24 @@ public class ServerPlayer extends Player { +@@ -425,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -179,7 +171,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 ValueOutput vehicleWrapper = playerOutput.child("RootVehicle"); vehicleWrapper.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(vehicleWrapper.child("Entity")); -@@ -461,7 +560,7 @@ public class ServerPlayer extends Player { +@@ -442,7 +_,7 @@ if (!rootTag.isEmpty()) { ServerLevel serverLevel = this.level(); Entity vehicle = EntityType.loadEntityRecursive( @@ -188,20 +180,20 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 ); if (vehicle != null) { UUID attachTo = rootTag.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -478,10 +577,10 @@ public class ServerPlayer extends Player { +@@ -459,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); - vehicle.discard(); + vehicle.discard(null); // CraftBukkit - add Bukkit remove cause - for (Entity entityx : vehicle.getIndirectPassengers()) { -- entityx.discard(); -+ entityx.discard(null); // CraftBukkit - add Bukkit remove cause + for (Entity entity : vehicle.getIndirectPassengers()) { +- entity.discard(); ++ entity.discard(null); // CraftBukkit - add Bukkit remove cause } } } -@@ -493,6 +592,7 @@ public class ServerPlayer extends Player { +@@ -474,6 +_,7 @@ ValueOutput.ValueOutputList pearlsOutput = playerOutput.childrenList("ender_pearls"); for (ThrownEnderpearl enderPearl : this.enderPearls) { @@ -209,7 +201,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (enderPearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -527,6 +627,16 @@ public class ServerPlayer extends Player { +@@ -508,6 +_,16 @@ } } @@ -226,7 +218,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 public void setExperiencePoints(final int amount) { float limit = this.getXpNeededForNextLevel(); float max = (limit - 1.0F) / limit; -@@ -591,6 +701,11 @@ public class ServerPlayer extends Player { +@@ -572,6 +_,11 @@ @Override public void tick() { @@ -238,7 +230,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -598,9 +713,18 @@ public class ServerPlayer extends Player { +@@ -579,9 +_,18 @@ this.invulnerableTime--; } @@ -260,7 +252,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.containerMenu = this.inventoryMenu; } -@@ -659,10 +783,10 @@ public class ServerPlayer extends Player { +@@ -640,10 +_,10 @@ public void doTick() { try { @@ -273,7 +265,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.containerMenu = this.inventoryMenu; } -@@ -692,7 +816,7 @@ public class ServerPlayer extends Player { +@@ -673,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -282,8 +274,8 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -723,6 +847,12 @@ public class ServerPlayer extends Player { - this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); +@@ -704,6 +_,12 @@ + this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil(this.lastRecordedExperience)); } + // CraftBukkit start - Force max health updates @@ -294,12 +286,11 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; - this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -736,6 +866,21 @@ public class ServerPlayer extends Player { + this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil(this.lastRecordedLevel)); +@@ -717,6 +_,20 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } -+ + // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border + if (this.oldLevel == -1) { + this.oldLevel = this.experienceLevel; @@ -314,10 +305,10 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + ((org.bukkit.craftbukkit.CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().tick(); + } + // CraftBukkit end - } catch (Throwable var4) { - CrashReport report = CrashReport.forThrowable(var4, "Ticking player"); + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Ticking player"); CrashReportCategory category = report.addCategory("Player being ticked"); -@@ -760,7 +905,7 @@ public class ServerPlayer extends Player { +@@ -741,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -326,7 +317,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } float saturation = this.foodData.getSaturationLevel(); -@@ -780,6 +925,7 @@ public class ServerPlayer extends Player { +@@ -761,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -334,7 +325,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.removeEntitiesOnShoulder(); } } -@@ -824,33 +970,62 @@ public class ServerPlayer extends Player { +@@ -805,29 +_,58 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -377,47 +368,45 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + @Nullable + private Entity respawnEntityOnShoulder0(final CompoundTag tag) { // CraftBukkit void->boolean + // Paper end - release entity api - return entity - overload - ServerLevel reporter = this.level(); - if (reporter instanceof ServerLevel) { - ServerLevel serverLevel = reporter; - if (!tag.isEmpty()) { - try (ProblemReporter.ScopedCollector reporterx = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { -- EntityType.create( -+ return EntityType.create( // Paper - release entity api - TagValueInput.create(reporterx.forChild(() -> ".shoulder"), serverLevel.registryAccess(), tag), serverLevel, EntitySpawnReason.LOAD - ) -- .ifPresent(entity -> { -+ .map(entity -> { // Paper - release entity api - if (entity instanceof TamableAnimal tamed) { - tamed.setOwner(this); - } - - entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ()); -- serverLevel.addWithUUID(entity); -- }); -+ return serverLevel.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // Paper - spawn reason -+ }).orElse(null); // Paper - release entity api - return entity - } + if (this.level() instanceof ServerLevel serverLevel && !tag.isEmpty()) { + try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { +- EntityType.create( ++ return EntityType.create( // Paper - release entity api + TagValueInput.create(reporter.forChild(() -> ".shoulder"), serverLevel.registryAccess(), tag), serverLevel, EntitySpawnReason.LOAD + ) +- .ifPresent(entity -> { ++ .map(entity -> { // Paper - release entity api + if (entity instanceof TamableAnimal tamed) { + tamed.setOwner(this); + } + + entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ()); +- serverLevel.addWithUUID(entity); +- }); ++ return serverLevel.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // Paper - spawn reason ++ }).orElse(null); // Paper - release entity api - return entity } } + return null; // Paper - return null } @Override -@@ -887,15 +1062,36 @@ public class ServerPlayer extends Player { +@@ -864,15 +_,36 @@ } private void updateScoreForCriteria(final ObjectiveCriteria criteria, final int value) { - this.level().getScoreboard().forAllObjectives(criteria, this, score -> score.set(value)); -+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(value)); // CraftBukkit - Use our scores instead - } - +- } +- - @Override - public void die(final DamageSource source) { - this.gameEvent(GameEvent.ENTITY_DIE); - boolean showDeathMessage = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); - if (showDeathMessage) { - Component deathMessage = this.getCombatTracker().getDeathMessage(); ++ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(value)); // CraftBukkit - Use our scores instead ++ } ++ + // Paper start - PlayerDeathEvent#getItemsToKeep + private static boolean shouldKeepDeathEventItem( + final org.bukkit.event.entity.PlayerDeathEvent event, @@ -448,7 +437,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -912,6 +1108,64 @@ public class ServerPlayer extends Player { +@@ -889,6 +_,64 @@ } ) ); @@ -513,7 +502,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -921,7 +1175,7 @@ public class ServerPlayer extends Player { +@@ -898,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -522,7 +511,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } this.removeEntitiesOnShoulder(); -@@ -929,11 +1183,35 @@ public class ServerPlayer extends Player { +@@ -906,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -561,7 +550,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 LivingEntity killer = this.getKillCredit(); if (killer != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killer.getType())); -@@ -967,10 +1245,10 @@ public class ServerPlayer extends Player { +@@ -944,10 +_,10 @@ if (victim != this) { super.awardKillScore(victim, killingBlow); Scoreboard scoreboard = this.level().getScoreboard(); @@ -574,7 +563,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } else { this.awardStat(Stats.MOB_KILLS); } -@@ -983,11 +1261,11 @@ public class ServerPlayer extends Player { +@@ -960,11 +_,11 @@ private void handleTeamKill(final ScoreHolder source, final ScoreHolder target, final ObjectiveCriteria[] criteriaByTeam) { Scoreboard scoreboard = this.level().getScoreboard(); @@ -588,36 +577,37 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } } -@@ -998,9 +1276,20 @@ public class ServerPlayer extends Player { - return false; - } else { - Entity entity = source.getEntity(); -- return !(entity instanceof Player playerx && !this.canHarmPlayer(playerx)) -- && !(entity instanceof AbstractArrow arrow && arrow.getOwner() instanceof Player player && !this.canHarmPlayer(player)) -- && super.hurtServer(level, source, damage); -+ if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false. -+ !(entity instanceof Player playerx && !this.canHarmPlayer(playerx)) -+ && !(entity instanceof AbstractArrow arrow && arrow.getOwner() instanceof Player player && !this.canHarmPlayer(player)) -+ )) return false; // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false. -+ // Paper start - cancellable death events -+ this.queueHealthUpdatePacket = true; -+ boolean damaged = super.hurtServer(level, source, damage); -+ this.queueHealthUpdatePacket = false; -+ if (this.queuedHealthUpdatePacket != null) { -+ this.connection.send(this.queuedHealthUpdatePacket); -+ this.queuedHealthUpdatePacket = null; -+ } -+ return damaged; -+ // Paper end - cancellable death events +@@ -976,9 +_,20 @@ } + + Entity entity = source.getEntity(); +- return !(entity instanceof Player player && !this.canHarmPlayer(player)) +- && !(entity instanceof AbstractArrow arrow && arrow.getOwner() instanceof Player owner && !this.canHarmPlayer(owner)) +- && super.hurtServer(level, source, damage); ++ if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false. ++ !(entity instanceof Player player && !this.canHarmPlayer(player)) ++ && !(entity instanceof AbstractArrow arrow && arrow.getOwner() instanceof Player owner && !this.canHarmPlayer(owner)) ++ )) return false; // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false. ++ // Paper start - cancellable death events ++ this.queueHealthUpdatePacket = true; ++ boolean damaged = super.hurtServer(level, source, damage); ++ this.queueHealthUpdatePacket = false; ++ if (this.queuedHealthUpdatePacket != null) { ++ this.connection.send(this.queuedHealthUpdatePacket); ++ this.queuedHealthUpdatePacket = null; ++ } ++ return damaged; ++ // Paper end - cancellable death events } -@@ -1013,24 +1302,98 @@ public class ServerPlayer extends Player { + @Override +@@ -990,24 +_,98 @@ return this.level().isPvpAllowed(); } - public TeleportTransition findRespawnPositionAndUseSpawnBlock( - final boolean consumeSpawnBlock, final TeleportTransition.PostTeleportTransition postTeleportTransition +- ) { + // Paper start + public record RespawnResult(TeleportTransition transition, boolean isBedSpawn, boolean isAnchorSpawn) { + } @@ -633,7 +623,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + public @Nullable RespawnResult findRespawnPositionAndUseSpawnBlock0( + final boolean consumeSpawnBlock, final TeleportTransition.PostTeleportTransition postTeleportTransition, + final org.bukkit.event.player.PlayerRespawnEvent.RespawnReason respawnReason - ) { ++ ) { + TeleportTransition teleportTransition; + boolean isBedSpawn = false; + boolean isAnchorSpawn = false; @@ -660,9 +650,10 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } else { - return TeleportTransition.createDefault(this, postTeleportTransition); +- } + // CraftBukkit start + teleportTransition = TeleportTransition.createDefault(this, postTeleportTransition); - } ++ } + + org.bukkit.entity.Player respawnPlayer = this.getBukkitEntity(); + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit( @@ -716,7 +707,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } public boolean isReceivingWaypoints() { -@@ -1064,15 +1427,17 @@ public class ServerPlayer extends Player { +@@ -1041,16 +_,18 @@ if (block instanceof RespawnAnchorBlock && (forced || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, pos) ) { @@ -730,14 +721,15 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 - return standUpPosition.map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F)); + return standUpPosition.map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F, false, true, finalConsumeAnchorCharge)); // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) - } else if (block instanceof BedBlock && level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos).canSetSpawn(level)) { - return BedBlock.findStandUpPosition(EntityType.PLAYER, level, pos, blockState.getValue(BedBlock.FACING), yaw) -- .map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F)); -+ .map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F, true, false, null)); // Paper - Fix SPIGOT-5989 - } else if (!forced) { - return Optional.empty(); } else { -@@ -1080,7 +1445,7 @@ public class ServerPlayer extends Player { + if (block instanceof BedBlock && level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos).canSetSpawn(level)) { + return BedBlock.findStandUpPosition(EntityType.PLAYER, level, pos, blockState.getValue(BedBlock.FACING), yaw) +- .map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F)); ++ .map(p -> ServerPlayer.RespawnPosAngle.of(p, pos, 0.0F, true, false, null)); // Paper - Fix SPIGOT-5989 + } + + if (!forced) { +@@ -1061,7 +_,7 @@ BlockState topState = level.getBlockState(pos.above()); boolean freeTop = topState.getBlock().isPossibleToRespawnInThis(topState); return freeBottom && freeTop @@ -746,7 +738,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 : Optional.empty(); } } -@@ -1096,7 +1461,8 @@ public class ServerPlayer extends Player { +@@ -1077,7 +_,8 @@ } @Override @@ -755,94 +747,94 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154 if (this.isRemoved()) { return null; - } else { -@@ -1107,12 +1473,46 @@ public class ServerPlayer extends Player { - ServerLevel newLevel = transition.newLevel(); - ServerLevel oldLevel = this.level(); - ResourceKey lastDimension = oldLevel.dimension(); -+ // CraftBukkit start -+ ResourceKey oldLevelTypeKey = oldLevel.getTypeKey(); + } +@@ -1089,12 +_,46 @@ + ServerLevel newLevel = transition.newLevel(); + ServerLevel oldLevel = this.level(); + ResourceKey lastDimension = oldLevel.dimension(); ++ // CraftBukkit start ++ ResourceKey oldLevelTypeKey = oldLevel.getTypeKey(); + -+ org.bukkit.Location enter = this.getBukkitEntity().getLocation(); -+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(transition), transition.relatives()); -+ org.bukkit.Location exit = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), newLevel, absolutePosition.yRot(), absolutePosition.xRot()); -+ final org.bukkit.event.player.PlayerTeleportEvent tpEvent; -+ // Paper start - gateway-specific teleport event -+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) { -+ tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit.clone(), new org.bukkit.craftbukkit.block.CraftEndGateway(this.level().getWorld(), theEndGatewayBlockEntity)); -+ } else { -+ tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(this.getBukkitEntity(), enter, exit.clone(), transition.cause()); -+ } -+ // Paper end - gateway-specific teleport event -+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(tpEvent); -+ org.bukkit.Location newExit = tpEvent.getTo(); -+ if (tpEvent.isCancelled()) { -+ return null; -+ } -+ if (!newExit.equals(exit)) { -+ newLevel = ((org.bukkit.craftbukkit.CraftWorld) newExit.getWorld()).getHandle(); -+ transition = new TeleportTransition( -+ newLevel, -+ org.bukkit.craftbukkit.util.CraftLocation.toVec3(newExit), -+ Vec3.ZERO, -+ newExit.getYaw(), -+ newExit.getPitch(), -+ transition.missingRespawnBlock(), -+ transition.asPassenger(), -+ Set.of(), -+ transition.postTeleportTransition(), -+ transition.cause()); -+ } -+ // CraftBukkit end - if (!transition.asPassenger()) { - this.removeVehicle(); - } - - if (newLevel.dimension() == lastDimension) { -- this.connection.teleport(PositionMoveRotation.of(transition), transition.relatives()); -+ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit - this.connection.resetPosition(); - transition.postTeleportTransition().onTransition(this); - return this; -@@ -1123,18 +1523,19 @@ public class ServerPlayer extends Player { - this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); - PlayerList playerList = this.server.getPlayerList(); - playerList.sendPlayerPermissionLevel(this); -+ this.portalProcess = null; // SPIGOT-7785: there is no need to carry this over as it contains the old world/location and we might run into trouble if there is a portal in the same spot in both worlds - oldLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.unsetRemoved(); - ProfilerFiller profiler = Profiler.get(); - profiler.push("moving"); -- if (lastDimension == Level.OVERWORLD && newLevel.dimension() == Level.NETHER) { -+ if (oldLevelTypeKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD && newLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event - this.enteredNetherPosition = this.position(); - } ++ org.bukkit.Location enter = this.getBukkitEntity().getLocation(); ++ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(transition), transition.relatives()); ++ org.bukkit.Location exit = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), newLevel, absolutePosition.yRot(), absolutePosition.xRot()); ++ final org.bukkit.event.player.PlayerTeleportEvent tpEvent; ++ // Paper start - gateway-specific teleport event ++ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) { ++ tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit.clone(), new org.bukkit.craftbukkit.block.CraftEndGateway(this.level().getWorld(), theEndGatewayBlockEntity)); ++ } else { ++ tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(this.getBukkitEntity(), enter, exit.clone(), transition.cause()); ++ } ++ // Paper end - gateway-specific teleport event ++ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(tpEvent); ++ org.bukkit.Location newExit = tpEvent.getTo(); ++ if (tpEvent.isCancelled()) { ++ return null; ++ } ++ if (!newExit.equals(exit)) { ++ newLevel = ((org.bukkit.craftbukkit.CraftWorld) newExit.getWorld()).getHandle(); ++ transition = new TeleportTransition( ++ newLevel, ++ org.bukkit.craftbukkit.util.CraftLocation.toVec3(newExit), ++ Vec3.ZERO, ++ newExit.getYaw(), ++ newExit.getPitch(), ++ transition.missingRespawnBlock(), ++ transition.asPassenger(), ++ Set.of(), ++ transition.postTeleportTransition(), ++ transition.cause()); ++ } ++ // CraftBukkit end + if (!transition.asPassenger()) { + this.removeVehicle(); + } - profiler.pop(); - profiler.push("placing"); - this.setServerLevel(newLevel); -- this.connection.teleport(PositionMoveRotation.of(transition), transition.relatives()); -+ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit - use internal teleport without event - this.connection.resetPosition(); - newLevel.addDuringTeleport(this); - profiler.pop(); -@@ -1149,6 +1550,15 @@ public class ServerPlayer extends Player { - this.lastSentHealth = -1.0F; - this.lastSentFood = -1; - this.teleportSpectators(transition, oldLevel); -+ // CraftBukkit start -+ org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), oldLevel.getWorld()); -+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent); -+ // CraftBukkit end -+ // Paper start - Reset shield blocking on dimension change -+ if (this.isBlocking()) { -+ this.stopUsingItem(); -+ } -+ // Paper end - Reset shield blocking on dimension change - return this; - } + if (newLevel.dimension() == lastDimension) { +- this.connection.teleport(PositionMoveRotation.of(transition), transition.relatives()); ++ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit + this.connection.resetPosition(); + transition.postTeleportTransition().onTransition(this); + return this; +@@ -1106,18 +_,19 @@ + this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); + PlayerList playerList = this.server.getPlayerList(); + playerList.sendPlayerPermissionLevel(this); ++ this.portalProcess = null; // SPIGOT-7785: there is no need to carry this over as it contains the old world/location and we might run into trouble if there is a portal in the same spot in both worlds + oldLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unsetRemoved(); + ProfilerFiller profiler = Profiler.get(); + profiler.push("moving"); +- if (lastDimension == Level.OVERWORLD && newLevel.dimension() == Level.NETHER) { ++ if (oldLevelTypeKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD && newLevel.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event + this.enteredNetherPosition = this.position(); } -@@ -1163,12 +1573,26 @@ public class ServerPlayer extends Player { + + profiler.pop(); + profiler.push("placing"); + this.setServerLevel(newLevel); +- this.connection.teleport(PositionMoveRotation.of(transition), transition.relatives()); ++ this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit - use internal teleport without event + this.connection.resetPosition(); + newLevel.addDuringTeleport(this); + profiler.pop(); +@@ -1132,6 +_,15 @@ + this.lastSentHealth = -1.0F; + this.lastSentFood = -1; + this.teleportSpectators(transition, oldLevel); ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), oldLevel.getWorld()); ++ this.level().getCraftServer().getPluginManager().callEvent(changeEvent); ++ // CraftBukkit end ++ // Paper start - Reset shield blocking on dimension change ++ if (this.isBlocking()) { ++ this.stopUsingItem(); ++ } ++ // Paper end - Reset shield blocking on dimension change + return this; + } + +@@ -1144,12 +_,26 @@ public void triggerDimensionChangeTriggers(final ServerLevel oldLevel) { ResourceKey oldKey = oldLevel.dimension(); ResourceKey newKey = this.level().dimension(); @@ -872,41 +864,36 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.enteredNetherPosition = null; } } -@@ -1184,10 +1608,12 @@ public class ServerPlayer extends Player { +@@ -1165,9 +_,10 @@ this.containerMenu.broadcastChanges(); } - @Override - public Either startSleepInBed(final BlockPos pos) { - Direction direction = this.level().getBlockState(pos).getValue(HorizontalDirectionalBlock.FACING); -- if (!this.isSleeping() && this.isAlive()) { + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(final BlockPos pos, final Direction direction) { + BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); -+ if (bedRule.explodes()) { -+ return Either.left(Player.BedSleepingProblem.EXPLOSION); -+ } else if (!this.isSleeping() && this.isAlive()) { ++ if (bedRule.explodes()) return Either.left(Player.BedSleepingProblem.EXPLOSION); + if (!this.isSleeping() && this.isAlive()) { BedRule rule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); boolean canSleep = rule.canSleep(this.level()); - boolean canSetSpawn = rule.canSetSpawn(this.level()); -@@ -1200,7 +1626,7 @@ public class ServerPlayer extends Player { - } else { - if (canSetSpawn) { - this.setRespawnPosition( -- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), pos, this.getYRot(), this.getXRot()), false), true -+ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), pos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent - ); - } +@@ -1186,7 +_,7 @@ -@@ -1229,7 +1655,37 @@ public class ServerPlayer extends Player { - } - } + if (canSetSpawn) { + this.setRespawnPosition( +- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), pos, this.getYRot(), this.getXRot()), false), true ++ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), pos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent + ); + } -- Either result = super.startSleepInBed(pos).ifRight(unit -> { -+ // CraftBukkit start -+ return Either.right(Unit.INSTANCE); -+ } -+ } +@@ -1209,7 +_,33 @@ + } + } + +- Either result = super.startSleepInBed(pos).ifRight(unit -> { ++ // CraftBukkit start ++ return Either.right(Unit.INSTANCE); + } else { + return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); + } @@ -929,26 +916,22 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + if (bedResult.left().isPresent()) { + return bedResult; + } -+ + { -+ { -+ Either result = super.startSleepInBed(pos, force).ifRight(unit -> { -+ // CraftBukkit end - this.awardStat(Stats.SLEEP_IN_BED); - CriteriaTriggers.SLEPT_IN_BED.trigger(this); - }); -@@ -1239,10 +1695,7 @@ public class ServerPlayer extends Player { - - this.level().updateSleepingPlayerList(); - return result; -- } - } ++ Either result = super.startSleepInBed(pos, force).ifRight(unit -> { ++ // CraftBukkit end + this.awardStat(Stats.SLEEP_IN_BED); + CriteriaTriggers.SLEPT_IN_BED.trigger(this); + }); +@@ -1219,8 +_,6 @@ + + this.level().updateSleepingPlayerList(); + return result; - } else { - return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); } } -@@ -1270,19 +1723,30 @@ public class ServerPlayer extends Player { +@@ -1248,19 +_,30 @@ @Override public void stopSleepInBed(final boolean forcefulWakeUp, final boolean updateLevelList) { @@ -981,7 +964,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1330,8 +1794,9 @@ public class ServerPlayer extends Player { +@@ -1308,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -992,64 +975,64 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1339,12 +1804,39 @@ public class ServerPlayer extends Player { - if (provider == null) { +@@ -1318,12 +_,39 @@ return OptionalInt.empty(); - } else { -- if (this.containerMenu != this.inventoryMenu) { -+ if (false && this.containerMenu != this.inventoryMenu) { // CraftBukkit - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEventWithTitle(...) - this.closeContainer(); - } + } - this.nextContainerCounter(); - AbstractContainerMenu menu = provider.createMenu(this.containerCounter, this.getInventory(), this); -+ Component title = null; // Paper - Add titleOverride to InventoryOpenEvent -+ // CraftBukkit start - Inventory open hook -+ if (menu != null) { -+ menu.setTitle(provider.getDisplayName()); +- if (this.containerMenu != this.inventoryMenu) { ++ if (false && this.containerMenu != this.inventoryMenu) { // CraftBukkit - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEventWithTitle(...) + this.closeContainer(); + } + + this.nextContainerCounter(); + AbstractContainerMenu menu = provider.createMenu(this.containerCounter, this.getInventory(), this); ++ Component title = null; // Paper - Add titleOverride to InventoryOpenEvent ++ // CraftBukkit start - Inventory open hook ++ if (menu != null) { ++ menu.setTitle(provider.getDisplayName()); + -+ boolean cancelled = false; -+ // Paper start - Add titleOverride to InventoryOpenEvent -+ final com.mojang.datafixers.util.Pair result = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEventWithTitle(this, menu, cancelled); -+ menu = result.getSecond(); -+ title = io.papermc.paper.adventure.PaperAdventure.asVanilla(result.getFirst()); -+ // Paper end - Add titleOverride to InventoryOpenEvent -+ if (menu == null && !cancelled) { // Let pre-cancelled events fall through -+ // SPIGOT-5263 - close chest if cancelled -+ if (provider instanceof Container container) { -+ container.stopOpen(this); -+ } else if (provider instanceof org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest.Provider doubleChestProvider) { -+ // SPIGOT-5355 - double chests too :( -+ doubleChestProvider.container.stopOpen(this); -+ // Paper start - Fix InventoryOpenEvent cancellation -+ } else if (!this.enderChestInventory.isActiveChest(null)) { -+ this.enderChestInventory.stopOpen(this); -+ // Paper end - Fix InventoryOpenEvent cancellation -+ } -+ return OptionalInt.empty(); ++ boolean cancelled = false; ++ // Paper start - Add titleOverride to InventoryOpenEvent ++ final com.mojang.datafixers.util.Pair result = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEventWithTitle(this, menu, cancelled); ++ menu = result.getSecond(); ++ title = io.papermc.paper.adventure.PaperAdventure.asVanilla(result.getFirst()); ++ // Paper end - Add titleOverride to InventoryOpenEvent ++ if (menu == null && !cancelled) { // Let pre-cancelled events fall through ++ // SPIGOT-5263 - close chest if cancelled ++ if (provider instanceof Container container) { ++ container.stopOpen(this); ++ } else if (provider instanceof org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest.Provider doubleChestProvider) { ++ // SPIGOT-5355 - double chests too :( ++ doubleChestProvider.container.stopOpen(this); ++ // Paper start - Fix InventoryOpenEvent cancellation ++ } else if (!this.enderChestInventory.isActiveChest(null)) { ++ this.enderChestInventory.stopOpen(this); ++ // Paper end - Fix InventoryOpenEvent cancellation + } ++ return OptionalInt.empty(); + } -+ // CraftBukkit end - if (menu == null) { - if (this.isSpectator()) { - this.sendOverlayMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED)); -@@ -1352,9 +1844,13 @@ public class ServerPlayer extends Player { ++ } ++ // CraftBukkit end + if (menu == null) { + if (this.isSpectator()) { + this.sendOverlayMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED)); +@@ -1331,9 +_,13 @@ - return OptionalInt.empty(); - } else { -- this.connection.send(new ClientboundOpenScreenPacket(menu.containerId, menu.getType(), provider.getDisplayName())); -+ // CraftBukkit start -+ this.containerMenu = menu; // Moved up -+ if (!this.isImmobile()) + return OptionalInt.empty(); + } else { +- this.connection.send(new ClientboundOpenScreenPacket(menu.containerId, menu.getType(), provider.getDisplayName())); ++ // CraftBukkit start ++ this.containerMenu = menu; // Moved up ++ if (!this.isImmobile()) + this.connection.send(new net.minecraft.network.protocol.game.ClientboundOpenScreenPacket(menu.containerId, menu.getType(), java.util.Objects.requireNonNullElseGet(title, menu::getTitle))); // Paper - Add titleOverride to InventoryOpenEven -+ // CraftBukkit end - this.initMenu(menu); -- this.containerMenu = menu; -+ // CraftBukkit - moved up - return OptionalInt.of(this.containerCounter); - } ++ // CraftBukkit end + this.initMenu(menu); +- this.containerMenu = menu; ++ // CraftBukkit - moved up + return OptionalInt.of(this.containerCounter); } -@@ -1374,27 +1870,49 @@ public class ServerPlayer extends Player { + } +@@ -1352,27 +_,49 @@ @Override public void openHorseInventory(final AbstractHorse horse, final Container container) { @@ -1104,7 +1087,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.initMenu(this.containerMenu); } -@@ -1416,10 +1934,30 @@ public class ServerPlayer extends Player { +@@ -1394,10 +_,30 @@ @Override public void closeContainer() { @@ -1135,7 +1118,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1442,19 +1980,19 @@ public class ServerPlayer extends Player { +@@ -1420,19 +_,19 @@ int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (distance > 0) { this.awardStat(Stats.SWIM_ONE_CM, distance); @@ -1158,7 +1141,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1465,13 +2003,13 @@ public class ServerPlayer extends Player { +@@ -1443,13 +_,13 @@ if (horizontalDistance > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, horizontalDistance); @@ -1175,7 +1158,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } } else if (this.isFallFlying()) { -@@ -1515,13 +2053,13 @@ public class ServerPlayer extends Player { +@@ -1493,13 +_,13 @@ @Override public void awardStat(final Stat stat, final int count) { this.stats.increment(this, stat, count); @@ -1191,7 +1174,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1552,9 +2090,9 @@ public class ServerPlayer extends Player { +@@ -1530,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1203,7 +1186,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } -@@ -1569,6 +2107,13 @@ public class ServerPlayer extends Player { +@@ -1547,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1217,7 +1200,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1580,6 +2125,7 @@ public class ServerPlayer extends Player { +@@ -1558,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1225,7 +1208,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1609,18 +2155,18 @@ public class ServerPlayer extends Player { +@@ -1587,18 +_,18 @@ this.onUpdateAbilities(); this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); if (restoreAll) { @@ -1247,7 +1230,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || oldPlayer.isSpectator()) { this.transferInventoryXpAndScore(oldPlayer); } -@@ -1632,7 +2178,7 @@ public class ServerPlayer extends Player { +@@ -1610,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1256,7 +1239,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1684,9 +2230,22 @@ public class ServerPlayer extends Player { +@@ -1662,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1280,7 +1263,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1704,6 +2263,7 @@ public class ServerPlayer extends Player { +@@ -1682,6 +_,7 @@ final float newYRot, final float newXRot, final boolean resetCamera @@ -1288,7 +1271,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 ) { if (this.isSleeping()) { this.stopSleepInBed(true, true); -@@ -1713,7 +2273,7 @@ public class ServerPlayer extends Player { +@@ -1691,7 +_,7 @@ this.setCamera(this); } @@ -1297,7 +1280,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (success) { this.setYHeadRot(relatives.contains(Relative.Y_ROT) ? this.getYHeadRot() + newYRot : newYRot); this.connection.resetFlyingTicks(); -@@ -1752,9 +2312,18 @@ public class ServerPlayer extends Player { +@@ -1730,11 +_,16 @@ } public boolean setGameMode(final GameType mode) { @@ -1309,25 +1292,25 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 boolean wasSpectator = this.isSpectator(); - if (!this.gameMode.changeGameModeForPlayer(mode)) { - return false; +- } +- + org.bukkit.event.player.PlayerGameModeChangeEvent event = this.gameMode.changeGameModeForPlayer(mode, cause, message); -+ if (event == null) { -+ return null; -+ } else if (event.isCancelled()) { -+ return event; // need to return the event for the cancel message -+ // Paper end - Expand PlayerGameModeChangeEvent - } else { - this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, mode.getId())); - if (mode == GameType.SPECTATOR) { -@@ -1771,7 +2340,7 @@ public class ServerPlayer extends Player { - - this.onUpdateAbilities(); - this.updateEffectVisibility(); -- return true; -+ return event; // Paper - Expand PlayerGameModeChangeEvent - } ++ if (event == null) return null; ++ if (event.isCancelled()) return event; // need to return the event for the cancel message ++ // Paper end - Expand PlayerGameModeChangeEvent + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, mode.getId())); + if (mode == GameType.SPECTATOR) { + this.removeEntitiesOnShoulder(); +@@ -1750,7 +_,7 @@ + + this.onUpdateAbilities(); + this.updateEffectVisibility(); +- return true; ++ return event; // Paper - Expand PlayerGameModeChangeEvent } -@@ -1840,8 +2409,13 @@ public class ServerPlayer extends Player { + @Override +@@ -1818,8 +_,13 @@ } public void sendChatMessage(final OutgoingChatMessage message, final boolean filtered, final ChatType.Bound chatType) { @@ -1342,7 +1325,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } } -@@ -1852,7 +2426,42 @@ public class ServerPlayer extends Player { +@@ -1830,7 +_,42 @@ } public void updateOptions(final ClientInformation information) { @@ -1385,9 +1368,9 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 this.requestedViewDistance = information.viewDistance(); this.chatVisibility = information.chatVisibility(); this.canChatColor = information.chatColors(); -@@ -1937,8 +2546,23 @@ public class ServerPlayer extends Player { +@@ -1915,8 +_,23 @@ Entity oldCamera = this.getCamera(); - this.camera = (Entity)(newCamera == null ? this : newCamera); + this.camera = newCamera == null ? this : newCamera; if (oldCamera != this.camera) { + // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity + if (this.camera == this) { @@ -1410,7 +1393,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } if (newCamera != null) { -@@ -1962,11 +2586,11 @@ public class ServerPlayer extends Player { +@@ -1940,11 +_,11 @@ } public @Nullable Component getTabListDisplayName() { @@ -1424,7 +1407,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -1996,11 +2620,60 @@ public class ServerPlayer extends Player { +@@ -1974,11 +_,60 @@ } public void setRespawnPosition(final ServerPlayer.@Nullable RespawnConfig respawnConfig, final boolean showMessage) { @@ -1468,7 +1451,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 + + if (event.getLocation() != null) { + respawnConfig = new ServerPlayer.RespawnConfig( -+ net.minecraft.world.level.storage.LevelData.RespawnData.of( ++ LevelData.RespawnData.of( + ((org.bukkit.craftbukkit.CraftWorld) event.getLocation().getWorld()).getHandle().dimension(), + org.bukkit.craftbukkit.util.CraftLocation.toBlockPos(event.getLocation()), + event.getLocation().getYaw(), @@ -1487,7 +1470,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } public SectionPos getLastSectionPos() { -@@ -2020,16 +2693,23 @@ public class ServerPlayer extends Player { +@@ -1998,16 +_,23 @@ } @Override @@ -1516,7 +1499,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 return entity; } -@@ -2081,7 +2761,7 @@ public class ServerPlayer extends Player { +@@ -2059,7 +_,7 @@ super.updateUsingItem(useItem); } @@ -1525,7 +1508,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 Inventory inventory = this.getInventory(); ItemStack removed = inventory.removeFromSelected(all); this.containerMenu -@@ -2091,7 +2771,7 @@ public class ServerPlayer extends Player { +@@ -2069,7 +_,7 @@ this.stopUsingItem(); } @@ -1534,7 +1517,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } @Override -@@ -2154,9 +2834,9 @@ public class ServerPlayer extends Player { +@@ -2132,9 +_,9 @@ } @Override @@ -1546,7 +1529,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 if (oldVehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance effect : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(oldVehicle.getId(), effect.getEffect())); -@@ -2278,7 +2958,7 @@ public class ServerPlayer extends Player { +@@ -2256,7 +_,7 @@ } public static long placeEnderPearlTicket(final ServerLevel level, final ChunkPos chunk) { @@ -1555,7 +1538,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 return TicketType.ENDER_PEARL.timeout(); } -@@ -2308,9 +2988,11 @@ public class ServerPlayer extends Player { +@@ -2286,9 +_,11 @@ } } @@ -1570,7 +1553,7 @@ index aabf2c3172cc2d43e436d36cf01b1a2a373390e0..2ffb9c7388e15ec3e3afd3fa50cc0149 } private static float calculateLookAtYaw(final Vec3 position, final BlockPos lookAtBlockPos) { -@@ -2330,4 +3012,135 @@ public class ServerPlayer extends Player { +@@ -2308,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch similarity index 64% rename from paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 8a1b35518558..3b08b045d0c0 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e66daaaa4 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -46,16 +46,37 @@ public class ServerPlayerGameMode { +@@ -46,17 +_,37 @@ private BlockPos delayedDestroyPos = BlockPos.ZERO; private int delayedTickStart; private int lastSentState = -1; @@ -31,39 +23,41 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e + // Paper end - Expand PlayerGameModeChangeEvent if (gameModeForPlayer == this.gameModeForPlayer) { - return false; +- } +- + return null; // Paper - Expand PlayerGameModeChangeEvent - } else { -+ // CraftBukkit start -+ org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent( -+ this.player.getBukkitEntity(), -+ org.bukkit.GameMode.getByValue(gameModeForPlayer.getId()), -+ playerGameModeChangeCause, // Paper -+ cancelMessage -+ ); -+ if (!event.callEvent()) { -+ return event; // Paper - Expand PlayerGameModeChangeEvent -+ } -+ // CraftBukkit end - Abilities abilities = this.player.getAbilities(); - this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); - if (abilities.flying && gameModeForPlayer != GameType.SPECTATOR && this.isInRangeOfGround()) { -@@ -66,13 +87,13 @@ public class ServerPlayerGameMode { - this.level - .getServer() - .getPlayerList() -- .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player)); -+ .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit - this.level.updateSleepingPlayerList(); - if (gameModeForPlayer == GameType.CREATIVE) { - this.player.resetCurrentImpulseContext(); - } - -- return true; ++ } ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent( ++ this.player.getBukkitEntity(), ++ org.bukkit.GameMode.getByValue(gameModeForPlayer.getId()), ++ playerGameModeChangeCause, // Paper ++ cancelMessage ++ ); ++ if (!event.callEvent()) { + return event; // Paper - Expand PlayerGameModeChangeEvent ++ } ++ // CraftBukkit end + Abilities abilities = this.player.getAbilities(); + this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); + if (abilities.flying && gameModeForPlayer != GameType.SPECTATOR && this.isInRangeOfGround()) { +@@ -67,13 +_,13 @@ + this.level + .getServer() + .getPlayerList() +- .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player)); ++ .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit + this.level.updateSleepingPlayerList(); + if (gameModeForPlayer == GameType.CREATIVE) { + this.player.resetCurrentImpulseContext(); } + +- return true; ++ return event; // Paper - Expand PlayerGameModeChangeEvent } -@@ -105,10 +126,11 @@ public class ServerPlayerGameMode { + protected void setGameModeForPlayer(final GameType gameModeForPlayer, final @Nullable GameType previousGameModeForPlayer) { +@@ -105,10 +_,11 @@ } public void tick() { @@ -78,7 +72,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e this.hasDelayedDestroy = false; } else { float destroyProgress = this.incrementDestroyProgress(blockState, this.delayedDestroyPos, this.delayedTickStart); -@@ -118,7 +140,13 @@ public class ServerPlayerGameMode { +@@ -118,7 +_,13 @@ } } } else if (this.isDestroyingBlock) { @@ -93,7 +87,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e if (blockState.isAir()) { this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.lastSentState = -1; -@@ -151,6 +179,7 @@ public class ServerPlayerGameMode { +@@ -151,6 +_,7 @@ final BlockPos pos, final ServerboundPlayerActionPacket.Action action, final Direction direction, final int maxY, final int sequence ) { if (!this.player.isWithinBlockInteractionRange(pos, 1.0)) { @@ -101,7 +95,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxY) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); -@@ -164,16 +193,35 @@ public class ServerPlayerGameMode { +@@ -164,16 +_,35 @@ } if (!this.level.mayInteract(this.player, pos)) { @@ -109,11 +103,13 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "may not interact"); +- return; +- } + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + // CraftBukkit end - return; - } - ++ return; ++ } ++ + // CraftBukkit start + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + if (event.isCancelled()) { @@ -121,7 +117,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e + return; + } + // CraftBukkit end -+ + if (this.player.getAbilities().instabuild) { this.destroyAndAck(pos, sequence, "creative destroy"); return; @@ -137,7 +133,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "block action restricted"); -@@ -183,7 +231,7 @@ public class ServerPlayerGameMode { +@@ -183,7 +_,7 @@ this.destroyProgressStart = this.gameTicks; float progress = 1.0F; BlockState blockState = this.level.getBlockState(pos); @@ -146,7 +142,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -198,6 +246,23 @@ public class ServerPlayerGameMode { +@@ -198,6 +_,23 @@ progress = blockState.getDestroyProgress(this.player, this.player.level(), pos); } @@ -170,7 +166,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e if (!blockState.isAir() && progress >= 1.0F) { this.destroyAndAck(pos, sequence, "insta mine"); } else { -@@ -238,14 +303,22 @@ public class ServerPlayerGameMode { +@@ -238,14 +_,22 @@ this.debugLogging(pos, true, sequence, "stopped destroying"); } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; @@ -195,7 +191,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e } } } -@@ -261,17 +334,62 @@ public class ServerPlayerGameMode { +@@ -261,13 +_,53 @@ public boolean destroyBlock(final BlockPos pos) { BlockState state = this.level.getBlockState(pos); @@ -241,100 +237,101 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e + + if (false && !this.player.getMainHandItem().canDestroyBlock(state, this.level, pos, this.player)) { // CraftBukkit - false return false; - } else { -+ state = this.level.getBlockState(pos); // CraftBukkit - update state from plugins -+ if (state.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling - BlockEntity blockEntity = this.level.getBlockEntity(pos); - Block block = state.getBlock(); -- if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { -+ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission - this.level.sendBlockUpdated(pos, state, state, Block.UPDATE_ALL); - return false; - } else if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { - return false; - } else { -+ // CraftBukkit start -+ org.bukkit.block.BlockState bState = bblock.getState(); -+ this.level.captureDrops = new java.util.ArrayList<>(); -+ // CraftBukkit end - BlockState adjustedState = block.playerWillDestroy(this.level, pos, state, this.player); - boolean changed = this.level.removeBlock(pos, false); - if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -282,19 +400,44 @@ public class ServerPlayerGameMode { - block.destroy(this.level, pos, adjustedState); - } + } +- ++ state = this.level.getBlockState(pos); // CraftBukkit - update state from plugins ++ if (state.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling + BlockEntity blockEntity = this.level.getBlockEntity(pos); + Block block = state.getBlock(); +- if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { ++ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission + this.level.sendBlockUpdated(pos, state, state, Block.UPDATE_ALL); + return false; + } +@@ -276,6 +_,10 @@ + return false; + } -+ ItemStack mainHandStack = null; // Paper - Trigger bee_nest_destroyed trigger in the correct place -+ boolean isCorrectTool = false; // Paper - Trigger bee_nest_destroyed trigger in the correct place - if (this.player.preventsBlockDrops()) { -- return true; -+ // return true; // CraftBukkit - } else { - ItemStack itemStack = this.player.getMainHandItem(); - ItemStack destroyedWith = itemStack.copy(); - boolean canDestroy = this.player.hasCorrectToolForDrops(adjustedState); -+ mainHandStack = destroyedWith; // Paper - Trigger bee_nest_destroyed trigger in the correct place -+ isCorrectTool = canDestroy; // Paper - Trigger bee_nest_destroyed trigger in the correct place - itemStack.mineBlock(this.level, adjustedState, pos, this.player); -- if (changed && canDestroy) { -- block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith); -+ if (changed && canDestroy) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion -+ block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith, event.isDropItems(), false); // Paper - fix drops not preventing stats/food exhaustion - } ++ // CraftBukkit start ++ org.bukkit.block.BlockState bState = bblock.getState(); ++ this.level.captureDrops = new java.util.ArrayList<>(); ++ // CraftBukkit end + BlockState adjustedState = block.playerWillDestroy(this.level, pos, state, this.player); + boolean changed = this.level.removeBlock(pos, false); + if (SharedConstants.DEBUG_BLOCK_BREAK) { +@@ -286,19 +_,44 @@ + block.destroy(this.level, pos, adjustedState); + } -- return true; -+ // return true; // CraftBukkit -+ } -+ // CraftBukkit start -+ java.util.List itemsToDrop = this.level.captureDrops; // Paper - capture all item additions to the world -+ this.level.captureDrops = null; // Paper - capture all item additions to the world; Remove this earlier so that we can actually drop stuff -+ if (event.isDropItems()) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bState, this.player, itemsToDrop); // Paper - capture all item additions to the world -+ } ++ ItemStack mainHandStack = null; // Paper - Trigger bee_nest_destroyed trigger in the correct place ++ boolean isCorrectTool = false; // Paper - Trigger bee_nest_destroyed trigger in the correct place + if (this.player.preventsBlockDrops()) { +- return true; ++ // return true; // CraftBukkit + } + + ItemStack itemStack = this.player.getMainHandItem(); + ItemStack destroyedWith = itemStack.copy(); + boolean canDestroy = this.player.hasCorrectToolForDrops(adjustedState); ++ mainHandStack = destroyedWith; // Paper - Trigger bee_nest_destroyed trigger in the correct place ++ isCorrectTool = canDestroy; // Paper - Trigger bee_nest_destroyed trigger in the correct place + itemStack.mineBlock(this.level, adjustedState, pos, this.player); +- if (changed && canDestroy) { +- block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith); +- } ++ if (changed && canDestroy) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion ++ block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith, event.isDropItems(), false); // Paper - fix drops not preventing stats/food exhaustion ++ } + -+ // Drop event experience -+ if (changed) { -+ state.getBlock().popExperience(this.level, pos, event.getExpToDrop(), this.player); // Paper - } -+ // Paper start - Trigger bee_nest_destroyed trigger in the correct place (check impls of block#playerDestroy) -+ if (mainHandStack != null) { -+ if (changed && isCorrectTool && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && blockEntity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above -+ CriteriaTriggers.BEE_NEST_DESTROYED.trigger(player, state, mainHandStack, beehiveBlockEntity.getOccupantCount()); -+ } -+ } -+ // Paper end - Trigger bee_nest_destroyed trigger in the correct place ++ // return true; // CraftBukkit ++ // CraftBukkit start ++ java.util.List itemsToDrop = this.level.captureDrops; // Paper - capture all item additions to the world ++ this.level.captureDrops = null; // Paper - capture all item additions to the world; Remove this earlier so that we can actually drop stuff ++ if (event.isDropItems()) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bState, this.player, itemsToDrop); // Paper - capture all item additions to the world ++ } + -+ return true; -+ // CraftBukkit end - } - } ++ // Drop event experience ++ if (changed) { ++ state.getBlock().popExperience(this.level, pos, event.getExpToDrop(), this.player); // Paper ++ } ++ // Paper start - Trigger bee_nest_destroyed trigger in the correct place (check impls of block#playerDestroy) ++ if (mainHandStack != null) { ++ if (changed && isCorrectTool && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && blockEntity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above ++ CriteriaTriggers.BEE_NEST_DESTROYED.trigger(player, state, mainHandStack, beehiveBlockEntity.getOccupantCount()); ++ } ++ } ++ // Paper end - Trigger bee_nest_destroyed trigger in the correct place + + return true; ++ // CraftBukkit end } -@@ -307,6 +450,7 @@ public class ServerPlayerGameMode { - } else { - int oldCount = itemStack.getCount(); - int oldDamage = itemStack.getDamageValue(); -+ final ItemStack stackBeforeUse = itemStack.copy(); // Paper - Store stack before use for interact prediction check - InteractionResult result = itemStack.use(level, player, hand); - ItemStack resultStack; - if (result instanceof InteractionResult.Success success) { -@@ -332,7 +476,14 @@ public class ServerPlayerGameMode { - } - if (!player.isUsingItem()) { -- player.inventoryMenu.sendAllDataToRemote(); -+ // Paper start - Optimize sendAllDataToRemote calls -+ // This is a weird one where the Vanilla behavior is from an ancient version, but also isn't calling startUsingItem on certain instant-use items -+ // TODO Check up on this proper, possibly remove all and move into more specific places -+ if (io.papermc.paper.util.MCUtil.clientPredictsInteraction(player, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), stackBeforeUse)) { -+ player.inventoryMenu.forceHeldSlot(hand); -+ } -+ player.inventoryMenu.broadcastChanges(); -+ // Paper end - Optimize sendAllDataToRemote calls - } + public InteractionResult useItem(final ServerPlayer player, final Level level, final ItemStack itemStack, final InteractionHand hand) { +@@ -312,6 +_,7 @@ + + int oldCount = itemStack.getCount(); + int oldDamage = itemStack.getDamageValue(); ++ final ItemStack stackBeforeUse = itemStack.copy(); // Paper - Store stack before use for interact prediction check + InteractionResult result = itemStack.use(level, player, hand); + ItemStack resultStack; + if (result instanceof InteractionResult.Success success) { +@@ -340,25 +_,70 @@ + } - return result; -@@ -340,17 +491,55 @@ public class ServerPlayerGameMode { + if (!player.isUsingItem()) { +- player.inventoryMenu.sendAllDataToRemote(); ++ // Paper start - Optimize sendAllDataToRemote calls ++ // This is a weird one where the Vanilla behavior is from an ancient version, but also isn't calling startUsingItem on certain instant-use items ++ // TODO Check up on this proper, possibly remove all and move into more specific places ++ if (io.papermc.paper.util.MCUtil.clientPredictsInteraction(player, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), stackBeforeUse)) { ++ player.inventoryMenu.forceHeldSlot(hand); ++ } ++ player.inventoryMenu.broadcastChanges(); ++ // Paper end - Optimize sendAllDataToRemote calls } + + return result; } + // CraftBukkit start - whole method @@ -352,7 +349,9 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e + boolean cancelledItem = false; // Paper - correctly handle items on cooldown if (!state.getBlock().isEnabled(level.enabledFeatures())) { return InteractionResult.FAIL; - } else if (this.gameModeForPlayer == GameType.SPECTATOR) { + } + + if (this.gameModeForPlayer == GameType.SPECTATOR) { MenuProvider menuProvider = state.getMenuProvider(level, pos); - if (menuProvider != null) { - player.openMenu(menuProvider); @@ -391,7 +390,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e return InteractionResult.CONSUME; } else { return InteractionResult.PASS; -@@ -375,7 +564,7 @@ public class ServerPlayerGameMode { +@@ -383,7 +_,7 @@ } } @@ -400,7 +399,7 @@ index 63c93a0ea490c835db80ba009f2aeba08261e2a7..f1faa0439bf5bce583e70ce37ade4b7e UseOnContext context = new UseOnContext(player, hand, hitResult); InteractionResult success; if (player.hasInfiniteMaterials()) { -@@ -392,6 +581,11 @@ public class ServerPlayerGameMode { +@@ -400,6 +_,11 @@ return success; } else { diff --git a/paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch similarity index 57% rename from paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch rename to paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch index ea5c6b554ccd..2afc9c8017cd 100644 --- a/paper-server/patches/rejected/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java -index df9d1b51d333a7497648b0d74236c66bff372205..690bb45bc91e4ca76754ca8f125c844a54484caf 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -146,6 +146,28 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -146,6 +_,28 @@ return distance < this.generatingStep.directDependencies().size(); } @@ -37,15 +29,15 @@ index df9d1b51d333a7497648b0d74236c66bff372205..690bb45bc91e4ca76754ca8f125c844a @Override public BlockState getBlockState(final BlockPos pos) { return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -221,6 +243,7 @@ public class WorldGenRegion implements WorldGenLevel { - } +@@ -221,6 +_,7 @@ + return null; } + private boolean hasSetFarWarned = false; // Paper - Buffer OOB setBlock calls @Override public boolean ensureCanWrite(final BlockPos pos) { int chunkX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -238,6 +261,8 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -238,6 +_,8 @@ return true; } else { @@ -54,7 +46,7 @@ index df9d1b51d333a7497648b0d74236c66bff372205..690bb45bc91e4ca76754ca8f125c844a Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + chunkX -@@ -249,6 +274,12 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -249,6 +_,12 @@ + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -67,25 +59,25 @@ index df9d1b51d333a7497648b0d74236c66bff372205..690bb45bc91e4ca76754ca8f125c844a return false; } } -@@ -273,6 +304,17 @@ public class WorldGenRegion implements WorldGenLevel { - chunk.removeBlockEntity(pos); - } - } else { -+ // Paper start - Clear block entity before setting up a DUMMY block entity -+ // The concept of removing a block entity when the block itself changes is generally lifted -+ // from LevelChunk#setBlockState. -+ // It is however to note that this may only run if the block actually changes. -+ // Otherwise a chest block entity generated by a structure template that is later "updated" to -+ // be waterlogged would remove its existing block entity (see PaperMC/Paper#10750) -+ // This logic is *also* found in LevelChunk#setBlockState. -+ if (oldState != null && !java.util.Objects.equals(oldState.getBlock(), blockState.getBlock())) { -+ chunk.removeBlockEntity(pos); -+ } -+ // Paper end - Clear block entity before setting up a DUMMY block entity - CompoundTag tag = new CompoundTag(); - tag.putInt("x", pos.getX()); - tag.putInt("y", pos.getY()); -@@ -301,6 +343,13 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -274,6 +_,17 @@ + chunk.removeBlockEntity(pos); + } + } else { ++ // Paper start - Clear block entity before setting up a DUMMY block entity ++ // The concept of removing a block entity when the block itself changes is generally lifted ++ // from LevelChunk#setBlockState. ++ // It is however to note that this may only run if the block actually changes. ++ // Otherwise a chest block entity generated by a structure template that is later "updated" to ++ // be waterlogged would remove its existing block entity (see PaperMC/Paper#10750) ++ // This logic is *also* found in LevelChunk#setBlockState. ++ if (oldState != null && !java.util.Objects.equals(oldState.getBlock(), blockState.getBlock())) { ++ chunk.removeBlockEntity(pos); ++ } ++ // Paper end - Clear block entity before setting up a DUMMY block entity + CompoundTag tag = new CompoundTag(); + tag.putInt("x", pos.getX()); + tag.putInt("y", pos.getY()); +@@ -301,6 +_,13 @@ @Override public boolean addFreshEntity(final Entity entity) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch similarity index 62% rename from paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch index 751ef0d5028b..1f290f04eaaa 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java -index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf30010aa7975 100644 --- a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java +++ b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java -@@ -21,7 +21,7 @@ import org.slf4j.Logger; +@@ -21,7 +_,7 @@ public abstract class BlockAttachedEntity extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); @@ -17,7 +9,7 @@ index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf300 protected BlockPos pos; protected BlockAttachedEntity(final EntityType type, final Level level) { -@@ -39,10 +39,26 @@ public abstract class BlockAttachedEntity extends Entity { +@@ -39,10 +_,26 @@ public void tick() { if (this.level() instanceof ServerLevel level) { this.checkBelowWorld(); @@ -46,32 +38,44 @@ index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf300 this.dropItem(level, null); } } -@@ -75,6 +91,21 @@ public abstract class BlockAttachedEntity extends Entity { - return false; - } else { - if (!this.isRemoved()) { -+ // CraftBukkit start - fire break events -+ Entity damager = source.getDirectEntity(); -+ final org.bukkit.event.hanging.HangingBreakEvent event; -+ if (damager != null) { -+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), new org.bukkit.craftbukkit.damage.CraftDamageSource(source), source.is(net.minecraft.tags.DamageTypeTags.IS_EXPLOSION) ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.ENTITY); -+ } else { -+ event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), source.is(net.minecraft.tags.DamageTypeTags.IS_EXPLOSION) ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.DEFAULT); -+ } +@@ -78,6 +_,21 @@ + } + + if (!this.isRemoved()) { ++ // CraftBukkit start - fire break events ++ Entity damager = source.getDirectEntity(); ++ final org.bukkit.event.hanging.HangingBreakEvent event; ++ if (damager != null) { ++ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), new org.bukkit.craftbukkit.damage.CraftDamageSource(source), source.is(net.minecraft.tags.DamageTypeTags.IS_EXPLOSION) ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.ENTITY); ++ } else { ++ event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), source.is(net.minecraft.tags.DamageTypeTags.IS_EXPLOSION) ? org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.EXPLOSION : org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.DEFAULT); ++ } + -+ event.callEvent(); ++ event.callEvent(); + -+ if (this.isRemoved() || event.isCancelled()) { -+ return true; -+ } -+ // CraftBukkit end - this.kill(level); - this.markHurt(); - this.dropItem(level, source.getEntity()); -@@ -93,19 +124,37 @@ public abstract class BlockAttachedEntity extends Entity { ++ if (this.isRemoved() || event.isCancelled()) { ++ return true; ++ } ++ // CraftBukkit end + this.kill(level); + this.markHurt(); + this.dropItem(level, source.getEntity()); +@@ -95,18 +_,36 @@ @Override public void move(final MoverType moverType, final Vec3 delta) { if (this.level() instanceof ServerLevel level && !this.isRemoved() && delta.lengthSqr() > 0.0) { +- this.kill(level); +- this.dropItem(level, null); +- } +- } +- +- @Override +- public void push(final double xa, final double ya, final double za) { +- if (this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { +- this.kill(level); +- this.dropItem(level, null); +- } +- } + // CraftBukkit start - fire break events + // TODO - Does this need its own cause? Seems to only be triggered by pistons + org.bukkit.event.hanging.HangingBreakEvent event = new org.bukkit.event.hanging.HangingBreakEvent((org.bukkit.entity.Hanging) this.getBukkitEntity(), org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.PHYSICS); @@ -81,21 +85,19 @@ index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf300 + return; + } + // CraftBukkit end - this.kill(level); - this.dropItem(level, null); - } - } - - @Override -- public void push(final double xa, final double ya, final double za) { -- if (this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { ++ this.kill(level); ++ this.dropItem(level, null); ++ } ++ } ++ ++ @Override + public void push(final double xa, final double ya, final double za, @Nullable final Entity pushingEntity) { // Paper - override correct overload + if (false && this.level() instanceof ServerLevel level && !this.isRemoved() && xa * xa + ya * ya + za * za > 0.0) { // CraftBukkit - not needed - this.kill(level); - this.dropItem(level, null); - } - } - ++ this.kill(level); ++ this.dropItem(level, null); ++ } ++ } ++ + // CraftBukkit start - selectively save tile position + @Override + protected void addAdditionalSaveData(final net.minecraft.world.level.storage.ValueOutput output, final boolean includeAll) { @@ -104,7 +106,6 @@ index cd278c307c212da5455202f12495c7426b62422c..a5d2c56a933bada6b88af5e03a6cf300 + } + } + // CraftBukkit end -+ + @Override protected void addAdditionalSaveData(final ValueOutput output) { - output.store("block_pos", BlockPos.CODEC, this.getPos()); From bf592cfb55b6bc0a0a4802e1bd4e640d57a73648 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 20:55:36 +0100 Subject: [PATCH 08/16] 70 --- .../LeashFenceKnotEntity.java.patch | 37 ------ .../world/inventory/LecternMenu.java.patch | 107 ------------------ .../entity/decoration/ArmorStand.java.patch | 89 +++++++-------- .../entity/decoration/ItemFrame.java.patch | 52 ++++----- .../LeashFenceKnotEntity.java.patch | 29 +++++ .../world/entity/item/ItemEntity.java.patch | 68 +++++------ .../AbstractContainerMenu.java.patch | 79 +++++++------ .../world/inventory/BeaconMenu.java.patch | 22 +--- .../inventory/ItemCombinerMenu.java.patch | 40 ++----- .../world/inventory/LecternMenu.java.patch | 102 +++++++++++++++++ .../world/inventory/LoomMenu.java.patch | 53 ++++----- .../level/material/FlowingFluid.java.patch | 28 ++--- 12 files changed, 309 insertions(+), 397 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/decoration/ArmorStand.java.patch (82%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/decoration/ItemFrame.java.patch (72%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/item/ItemEntity.java.patch (83%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/AbstractContainerMenu.java.patch (87%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/BeaconMenu.java.patch (86%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/ItemCombinerMenu.java.patch (69%) create mode 100644 paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/LoomMenu.java.patch (86%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/material/FlowingFluid.java.patch (87%) diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch deleted file mode 100644 index 7e695a0914c3..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -index 2ae0015d6c00640a72864091235b71ad0d4aaac3..a4999a82fa5ed58b88cc11b42524d2513a3ed37a 100644 ---- a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -+++ b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -@@ -85,7 +85,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { - boolean attachedMob = false; - - for (Leashable leashable : Leashable.leashableLeashedTo(player)) { -- if (leashable.canHaveALeashAttachedTo(this)) { -+ if (leashable.canHaveALeashAttachedTo(this) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(leashable, this, player, hand)) { // Paper - leash event - leashable.setLeashedTo(this, true); - attachedMob = true; - } -@@ -94,7 +94,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { - boolean anyDropped = false; - if (!attachedMob && !player.isSecondaryUseActive()) { - for (Leashable mob : Leashable.leashableLeashedTo(this)) { -- if (mob.canHaveALeashAttachedTo(player)) { -+ if (mob.canHaveALeashAttachedTo(player) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(mob, player, player, hand)) { // Paper - leash event - mob.setLeashedTo(player, true); - anyDropped = true; - } -@@ -114,7 +114,7 @@ public class LeashFenceKnotEntity extends BlockAttachedEntity { - @Override - public void notifyLeasheeRemoved(final Leashable entity) { - if (Leashable.leashableLeashedTo(this).isEmpty()) { -- this.discard(); -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - } - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch b/paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch deleted file mode 100644 index 838a0a6a4e10..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/LecternMenu.java.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/LecternMenu.java b/net/minecraft/world/inventory/LecternMenu.java -index ae2b95dae3d57d53721a5da27db6c8a739a7a51e..8b8c60726facd1f0b93779bd44d7a3e879fd4086 100644 ---- a/net/minecraft/world/inventory/LecternMenu.java -+++ b/net/minecraft/world/inventory/LecternMenu.java -@@ -15,12 +15,29 @@ public class LecternMenu extends AbstractContainerMenu { - public static final int BUTTON_PAGE_JUMP_RANGE_START = 100; - private final Container lectern; - private final ContainerData lecternData; -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLecternView view = null; -+ private final org.bukkit.entity.Player player; - -- public LecternMenu(final int containerId) { -- this(containerId, new SimpleContainer(1), new SimpleContainerData(1)); -+ @Override -+ public org.bukkit.craftbukkit.inventory.view.CraftLecternView getBukkitView() { -+ if (this.view != null) { -+ return this.view; -+ } -+ -+ org.bukkit.craftbukkit.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLectern(this.lectern); -+ this.view = new org.bukkit.craftbukkit.inventory.view.CraftLecternView(this.player, inventory, this); -+ return this.view; - } -+ // CraftBukkit end - -- public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData) { -+ // CraftBukkit start - add player inventory -+ public LecternMenu(final int containerId, final net.minecraft.world.entity.player.Inventory inventory) { -+ this(containerId, new SimpleContainer(1), new SimpleContainerData(1), inventory); -+ } -+ -+ public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData, net.minecraft.world.entity.player.Inventory inventory) { -+ // CraftBukkit end - add player inventory - super(MenuType.LECTERN, containerId); - checkContainerSize(lectern, 1); - checkContainerDataCount(lecternData, 1); -@@ -38,10 +55,12 @@ public class LecternMenu extends AbstractContainerMenu { - } - }); - this.addDataSlots(lecternData); -+ this.player = (org.bukkit.entity.Player) inventory.player.getBukkitEntity(); // CraftBukkit - } - - @Override - public boolean clickMenuButton(final Player player, final int buttonId) { -+ io.papermc.paper.event.player.PlayerLecternPageChangeEvent playerLecternPageChangeEvent; org.bukkit.craftbukkit.inventory.CraftInventoryLectern bukkitView; // Paper - Add PlayerLecternPageChangeEvent - if (buttonId >= 100) { - int pageToSet = buttonId - 100; - this.setData(0, pageToSet); -@@ -50,12 +69,26 @@ public class LecternMenu extends AbstractContainerMenu { - switch (buttonId) { - case 1: { - int currentPage = this.lecternData.get(0); -- this.setData(0, currentPage - 1); -+ // Paper start - Add PlayerLecternPageChangeEvent -+ bukkitView = (org.bukkit.craftbukkit.inventory.CraftInventoryLectern) getBukkitView().getTopInventory(); -+ playerLecternPageChangeEvent = new io.papermc.paper.event.player.PlayerLecternPageChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), bukkitView.getHolder(), bukkitView.getBook(), io.papermc.paper.event.player.PlayerLecternPageChangeEvent.PageChangeDirection.LEFT, currentPage, currentPage - 1); -+ if (!playerLecternPageChangeEvent.callEvent()) { -+ return false; -+ } -+ this.setData(0, playerLecternPageChangeEvent.getNewPage()); -+ // Paper end - Add PlayerLecternPageChangeEvent - return true; - } - case 2: { - int currentPage = this.lecternData.get(0); -- this.setData(0, currentPage + 1); -+ // Paper start - Add PlayerLecternPageChangeEvent -+ bukkitView = (org.bukkit.craftbukkit.inventory.CraftInventoryLectern) getBukkitView().getTopInventory(); -+ playerLecternPageChangeEvent = new io.papermc.paper.event.player.PlayerLecternPageChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), bukkitView.getHolder(), bukkitView.getBook(), io.papermc.paper.event.player.PlayerLecternPageChangeEvent.PageChangeDirection.RIGHT, currentPage, currentPage + 1); -+ if (!playerLecternPageChangeEvent.callEvent()) { -+ return false; -+ } -+ this.setData(0, playerLecternPageChangeEvent.getNewPage()); -+ // Paper end - Add PlayerLecternPageChangeEvent - return true; - } - case 3: -@@ -63,6 +96,12 @@ public class LecternMenu extends AbstractContainerMenu { - return false; - } - -+ // CraftBukkit start - Event for taking the book -+ org.bukkit.event.player.PlayerTakeLecternBookEvent event = new org.bukkit.event.player.PlayerTakeLecternBookEvent(this.player, this.getBukkitView().getTopInventory().getHolder()); -+ if (!event.callEvent()) { -+ return false; -+ } -+ // CraftBukkit end - ItemStack book = this.lectern.removeItemNoUpdate(0); - this.lectern.setChanged(); - if (!player.getInventory().add(book)) { -@@ -89,6 +128,8 @@ public class LecternMenu extends AbstractContainerMenu { - - @Override - public boolean stillValid(final Player player) { -+ if (this.lectern instanceof net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory lecternInventory && !lecternInventory.getLectern().hasBook()) return false; // CraftBukkit -+ if (!this.checkReachable) return true; // CraftBukkit - return this.lectern.stillValid(player); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch similarity index 82% rename from paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 5fa2ba4c0202..d56896d3e894 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c264b25fee 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -88,9 +88,16 @@ public class ArmorStand extends LivingEntity { +@@ -88,9 +_,16 @@ private boolean invisible = false; public long lastHit; public int disabledSlots = 0; @@ -25,7 +17,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 } public ArmorStand(final Level level, final double x, final double y, final double z) { -@@ -102,6 +109,13 @@ public class ArmorStand extends LivingEntity { +@@ -102,6 +_,13 @@ return createLivingAttributes().add(Attributes.STEP_HEIGHT, 0.0); } @@ -39,7 +31,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 @Override public void refreshDimensions() { double oldX = this.getX(); -@@ -137,6 +151,14 @@ public class ArmorStand extends LivingEntity { +@@ -137,6 +_,14 @@ return slot != EquipmentSlot.BODY && slot != EquipmentSlot.SADDLE && !this.isDisabled(slot); } @@ -54,7 +46,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 @Override protected void addAdditionalSaveData(final ValueOutput output) { super.addAdditionalSaveData(output); -@@ -150,6 +172,7 @@ public class ArmorStand extends LivingEntity { +@@ -150,6 +_,7 @@ } output.store("Pose", ArmorStand.ArmorStandPose.CODEC, this.getArmorStandPose()); @@ -62,7 +54,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 } @Override -@@ -163,10 +186,16 @@ public class ArmorStand extends LivingEntity { +@@ -163,10 +_,16 @@ this.setMarker(input.getBooleanOr("Marker", false)); this.noPhysics = !this.hasPhysics(); input.read("Pose", ArmorStand.ArmorStandPose.CODEC).ifPresent(this::setArmorStandPose); @@ -80,7 +72,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 return false; } -@@ -176,6 +205,7 @@ public class ArmorStand extends LivingEntity { +@@ -176,6 +_,7 @@ @Override protected void pushEntities() { @@ -88,13 +80,10 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 for (Entity entity : this.level().getEntities(this, this.getBoundingBox(), RIDABLE_MINECARTS)) { if (this.distanceToSqr(entity) <= 0.2) { entity.push(this); -@@ -248,7 +278,25 @@ public class ArmorStand extends LivingEntity { +@@ -256,6 +_,23 @@ return false; - } else if (itemStack.isEmpty() && (this.disabledSlots & 1 << slot.getFilterBit(16)) != 0) { - return false; -- } else if (player.hasInfiniteMaterials() && itemStack.isEmpty() && !playerItemStack.isEmpty()) { -+ } -+ + } + + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack); + org.bukkit.inventory.ItemStack playerHeldItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(playerItemStack); @@ -111,14 +100,14 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 + return true; + } + // CraftBukkit end -+ if (player.hasInfiniteMaterials() && itemStack.isEmpty() && !playerItemStack.isEmpty()) { ++ + if (player.hasInfiniteMaterials() && itemStack.isEmpty() && !playerItemStack.isEmpty()) { this.setItemSlot(slot, playerItemStack.copyWithCount(1)); return true; - } else if (playerItemStack.isEmpty() || playerItemStack.getCount() <= 1) { -@@ -270,15 +318,32 @@ public class ArmorStand extends LivingEntity { - } else if (!level.getGameRules().get(GameRules.MOB_GRIEFING) && source.getEntity() instanceof Mob) { - return false; - } else if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { +@@ -286,21 +_,38 @@ + } + + if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { - this.kill(level); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage)) { @@ -127,10 +116,14 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 + this.kill(level, source); // CraftBukkit + // CraftBukkit end return false; -- } else if (this.isInvulnerableTo(level, source) || this.invisible || this.isMarker()) { -+ } else if (this.isInvulnerableTo(level, source) /*|| this.invisible*/ || this.isMarker()) { // CraftBukkit + } + +- if (this.isInvulnerableTo(level, source) || this.invisible || this.isMarker()) { ++ if (this.isInvulnerableTo(level, source) /*|| this.invisible*/ || this.isMarker()) { // CraftBukkit return false; - } else if (source.is(DamageTypeTags.IS_EXPLOSION)) { + } + + if (source.is(DamageTypeTags.IS_EXPLOSION)) { - this.brokenByAnything(level, source); - this.kill(level); + // CraftBukkit start @@ -143,7 +136,9 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 + if (!event.isCancelled()) this.kill(level, source, false); // CraftBukkit + // Paper end return false; - } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { + } + + if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage, true, this.invisible)) { + return false; @@ -152,7 +147,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 if (this.isOnFire()) { this.causeDamage(level, source, 0.15F); } else { -@@ -287,9 +352,19 @@ public class ArmorStand extends LivingEntity { +@@ -309,9 +_,19 @@ return false; } else if (source.is(DamageTypeTags.BURNS_ARMOR_STANDS) && this.getHealth() > 0.5F) { @@ -172,16 +167,16 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 boolean allowIncrementalBreaking = source.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean shouldKill = source.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); if (!allowIncrementalBreaking && !shouldKill) { -@@ -299,7 +374,7 @@ public class ArmorStand extends LivingEntity { - } else if (source.isCreativePlayer()) { - this.playBrokenSound(); - this.showBreakingParticles(); -- this.kill(level); -+ this.kill(level, source); // CraftBukkit - return true; - } else { - long time = level.getGameTime(); -@@ -308,9 +383,9 @@ public class ArmorStand extends LivingEntity { +@@ -322,7 +_,7 @@ + if (source.isCreativePlayer()) { + this.playBrokenSound(); + this.showBreakingParticles(); +- this.kill(level); ++ this.kill(level, source); // CraftBukkit + return true; + } + +@@ -332,9 +_,9 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); this.lastHit = time; } else { @@ -193,7 +188,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 } return true; -@@ -362,31 +437,42 @@ public class ArmorStand extends LivingEntity { +@@ -386,31 +_,42 @@ float health = this.getHealth(); health -= dmg; if (health <= 0.5F) { @@ -230,6 +225,8 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 + ItemStack itemStack = this.equipment.get(slot); // Paper - move equipment removal past event call if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { - Block.popResource(this.level(), this.blockPosition().above(), itemStack); +- } +- } + this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly} + } + } @@ -238,14 +235,14 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 + if (!event.isCancelled()) { + for (EquipmentSlot slot : EquipmentSlot.VALUES) { + this.equipment.set(slot, ItemStack.EMPTY); - } - } ++ } ++ } + return event; + // Paper end - move equipment removal past event call } private void playBrokenSound() { -@@ -434,9 +520,40 @@ public class ArmorStand extends LivingEntity { +@@ -458,9 +_,40 @@ return this.isSmall(); } @@ -287,7 +284,7 @@ index aa800f45f8230aa1123464b2c5003be5c0ae0516..b9cd4bdd48d3c9fc96838d051d18d1c2 this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -683,4 +800,13 @@ public class ArmorStand extends LivingEntity { +@@ -707,4 +_,13 @@ .apply(i, ArmorStand.ArmorStandPose::new) ); } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch similarity index 72% rename from paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch index d852d4aba617..29cd1f73ffd7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java -index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2e9040928 100644 --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -54,6 +54,7 @@ public class ItemFrame extends HangingEntity { +@@ -54,6 +_,7 @@ private static final boolean DEFAULT_FIXED = false; public float dropChance = 1.0F; public boolean fixed = false; @@ -16,7 +8,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 public ItemFrame(final EntityType type, final Level level) { super(type, level); -@@ -111,6 +112,11 @@ public class ItemFrame extends HangingEntity { +@@ -111,6 +_,11 @@ } private AABB createBoundingBox(final BlockPos blockPos, final Direction direction, final boolean hasFramedMap) { @@ -28,7 +20,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 float shiftToBlockWall = 0.46875F; Vec3 position = Vec3.atCenterOf(blockPos).relative(direction, -0.46875); float width = hasFramedMap ? 1.0F : 0.75F; -@@ -142,9 +148,9 @@ public class ItemFrame extends HangingEntity { +@@ -144,9 +_,9 @@ } @Override @@ -40,7 +32,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 } } -@@ -173,6 +179,18 @@ public class ItemFrame extends HangingEntity { +@@ -175,6 +_,18 @@ if (this.isInvulnerableToBase(source)) { return false; } else if (this.shouldDamageDropItem(source)) { @@ -59,7 +51,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 this.dropItem(level, source.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -256,6 +274,13 @@ public class ItemFrame extends HangingEntity { +@@ -258,6 +_,13 @@ return this.getEntityData().get(DATA_ITEM); } @@ -73,7 +65,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 public @Nullable MapId getFramedMapId(final ItemStack itemStack) { return itemStack.get(DataComponents.MAP_ID); } -@@ -269,13 +294,19 @@ public class ItemFrame extends HangingEntity { +@@ -271,13 +_,19 @@ } public void setItem(ItemStack itemStack, final boolean updateNeighbours) { @@ -94,7 +86,7 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -302,6 +333,7 @@ public class ItemFrame extends HangingEntity { +@@ -304,6 +_,7 @@ } private void onItemChanged(final ItemStack item) { @@ -102,22 +94,22 @@ index 9dd28b667ea3405f9fa418afe73a79ec6ac07fd9..898f64de427b84cbf9b0e5198098f8e2 this.recalculateBoundingBox(); } -@@ -366,7 +398,13 @@ public class ItemFrame extends HangingEntity { - if (data != null && data.isTrackedCountOverLimit(256)) { +@@ -371,7 +_,13 @@ return InteractionResult.FAIL; - } else { -- this.setItem(itemStack); -+ // Paper start - Add PlayerItemFrameChangeEvent -+ io.papermc.paper.event.player.PlayerItemFrameChangeEvent event = new io.papermc.paper.event.player.PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), itemStack.asBukkitCopy(), io.papermc.paper.event.player.PlayerItemFrameChangeEvent.ItemFrameChangeAction.PLACE); -+ if (!event.callEvent()) { -+ return InteractionResult.FAIL; -+ } -+ this.setItem(ItemStack.fromBukkitCopy(event.getItemStack())); -+ // Paper end - Add PlayerItemFrameChangeEvent - this.gameEvent(GameEvent.BLOCK_CHANGE, player); - itemStack.consume(1, player); - return InteractionResult.SUCCESS; -@@ -375,6 +413,13 @@ public class ItemFrame extends HangingEntity { + } + +- this.setItem(itemStack); ++ // Paper start - Add PlayerItemFrameChangeEvent ++ io.papermc.paper.event.player.PlayerItemFrameChangeEvent event = new io.papermc.paper.event.player.PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), itemStack.asBukkitCopy(), io.papermc.paper.event.player.PlayerItemFrameChangeEvent.ItemFrameChangeAction.PLACE); ++ if (!event.callEvent()) { ++ return InteractionResult.FAIL; ++ } ++ this.setItem(ItemStack.fromBukkitCopy(event.getItemStack())); ++ // Paper end - Add PlayerItemFrameChangeEvent + this.gameEvent(GameEvent.BLOCK_CHANGE, player); + itemStack.consume(1, player); + return InteractionResult.SUCCESS; +@@ -379,6 +_,13 @@ return InteractionResult.PASS; } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch new file mode 100644 index 000000000000..df6708a939c7 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java ++++ b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java +@@ -86,7 +_,7 @@ + boolean attachedMob = false; + + for (Leashable leashable : Leashable.leashableLeashedTo(player)) { +- if (leashable.canHaveALeashAttachedTo(this)) { ++ if (leashable.canHaveALeashAttachedTo(this) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(leashable, this, player, hand)) { // Paper - leash event + leashable.setLeashedTo(this, true); + attachedMob = true; + } +@@ -95,7 +_,7 @@ + boolean anyDropped = false; + if (!attachedMob && !player.isSecondaryUseActive()) { + for (Leashable mob : Leashable.leashableLeashedTo(this)) { +- if (mob.canHaveALeashAttachedTo(player)) { ++ if (mob.canHaveALeashAttachedTo(player) && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerLeashEntityEvent(mob, player, player, hand)) { // Paper - leash event + mob.setLeashedTo(player, true); + anyDropped = true; + } +@@ -114,7 +_,7 @@ + @Override + public void notifyLeasheeRemoved(final Leashable entity) { + if (Leashable.leashableLeashedTo(this).isEmpty()) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause + } + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch similarity index 83% rename from paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index ddf2da2b9f19..57f1315b9295 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860e0cde916 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -51,6 +51,9 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -51,6 +_,9 @@ public @Nullable EntityReference thrower; public @Nullable UUID target; public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; @@ -18,7 +10,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 public ItemEntity(final EntityType type, final Level level) { super(type, level); -@@ -80,6 +83,14 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -80,6 +_,14 @@ this.setDeltaMovement(deltaX, deltaY, deltaZ); } @@ -33,7 +25,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 @Override public boolean dampensVibrations() { return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); -@@ -116,7 +127,7 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -116,7 +_,7 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -42,7 +34,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -144,13 +155,17 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -144,13 +_,17 @@ } } @@ -62,7 +54,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 friction = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -183,8 +198,14 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -183,8 +_,14 @@ } } @@ -79,7 +71,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } } } -@@ -209,9 +230,18 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -209,9 +_,18 @@ private void mergeWithNeighbours() { if (this.isMergable()) { @@ -99,7 +91,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 this.tryToMerge(entity); if (this.isRemoved()) { break; -@@ -223,7 +253,7 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -223,7 +_,7 @@ private boolean isMergable() { ItemStack item = this.getItem(); @@ -108,7 +100,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } private void tryToMerge(final ItemEntity other) { -@@ -256,11 +286,16 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -256,11 +_,16 @@ } private static void merge(final ItemEntity toItem, final ItemStack toStack, final ItemEntity fromItem, final ItemStack fromStack) { @@ -126,26 +118,26 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } } -@@ -288,12 +323,17 @@ public class ItemEntity extends Entity implements TraceableEntity { - } else if (!this.getItem().canBeHurtBy(source)) { +@@ -293,12 +_,17 @@ return false; - } else { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage)) { -+ return false; -+ } -+ // CraftBukkit end - this.markHurt(); - this.health = (int)(this.health - damage); - this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); - if (this.health <= 0) { - this.getItem().onDestroyed(this); -- this.discard(); -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - } + } + ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage)) { ++ return false; ++ } ++ // CraftBukkit end + this.markHurt(); + this.health = (int)(this.health - damage); + this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); + if (this.health <= 0) { + this.getItem().onDestroyed(this); +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause + } - return true; -@@ -315,6 +355,11 @@ public class ItemEntity extends Entity implements TraceableEntity { + return true; +@@ -319,6 +_,11 @@ if (!this.getItem().isEmpty()) { output.store("Item", ItemStack.CODEC, this.getItem()); } @@ -157,7 +149,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } @Override -@@ -325,8 +370,17 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -329,8 +_,17 @@ this.target = input.read("Owner", UUIDUtil.CODEC).orElse(null); this.thrower = EntityReference.read(input, "Thrower"); this.setItem(input.read("Item", ItemStack.CODEC).orElse(ItemStack.EMPTY)); @@ -176,7 +168,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } } -@@ -336,10 +390,73 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -340,10 +_,73 @@ ItemStack itemStack = this.getItem(); Item item = itemStack.getItem(); int orgCount = itemStack.getCount(); @@ -251,7 +243,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 itemStack.setCount(orgCount); } -@@ -376,6 +493,7 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -380,6 +_,7 @@ public void setItem(final ItemStack itemStack) { this.getEntityData().set(DATA_ITEM, itemStack); @@ -259,7 +251,7 @@ index 7c5fade0dc26233db02cb0f5895da2aed38ca2c2..c482c3348267ca2b88109e34291aa860 } public void setTarget(final @Nullable UUID target) { -@@ -420,7 +538,7 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -424,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch similarity index 87% rename from paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 90c5470eb49f..acf6056d0032 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8dbaa198e17 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -65,6 +65,35 @@ public abstract class AbstractContainerMenu { +@@ -64,6 +_,35 @@ private final List containerListeners = Lists.newArrayList(); private @Nullable ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; @@ -44,10 +36,12 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db protected AbstractContainerMenu(final @Nullable MenuType menuType, final int containerId) { this.menuType = menuType; -@@ -176,8 +205,43 @@ public abstract class AbstractContainerMenu { +@@ -175,8 +_,43 @@ if (this.synchronizer != null) { this.synchronizer.sendInitialData(this, itemsToSend, carried.copy(), this.remoteDataSlots.toIntArray()); +- } +- } + this.synchronizer.sendOffHandSlotChange(); // Paper - Sync offhand slot in menus; update player's offhand since the offhand slot is not added to the slots for menus but can be changed by swapping from a menu slot + } + } @@ -72,8 +66,8 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db + + if (this.synchronizer != null) { + this.synchronizer.sendSlotChange(this, slotsIndex, item.copy()); - } - } ++ } ++ } + // Paper end + + // CraftBukkit start - from synchronizeCarriedToRemote @@ -88,7 +82,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db public void removeSlotListener(final ContainerListener listener) { this.containerListeners.remove(listener); -@@ -243,7 +307,7 @@ public abstract class AbstractContainerMenu { +@@ -242,7 +_,7 @@ this.lastSlots.set(i, newItem); for (ContainerListener containerListener : this.containerListeners) { @@ -97,7 +91,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db } } } -@@ -351,6 +415,7 @@ public abstract class AbstractContainerMenu { +@@ -350,6 +_,7 @@ this.resetQuickCraft(); } } else if (this.quickcraftStatus == QUICKCRAFT_HEADER_CONTINUE) { @@ -105,7 +99,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db Slot slot = this.slots.get(slotIndex); ItemStack carriedItemStack = this.getCarried(); if (canItemQuickReplace(slot, carriedItemStack, true) -@@ -375,6 +440,7 @@ public abstract class AbstractContainerMenu { +@@ -374,6 +_,7 @@ } int remaining = this.getCarried().getCount(); @@ -113,18 +107,21 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db for (Slot slot : this.quickcraftSlots) { ItemStack carriedItemStack = this.getCarried(); -@@ -387,12 +453,42 @@ public abstract class AbstractContainerMenu { +@@ -386,12 +_,42 @@ int maxSize = Math.min(source.getMaxStackSize(), slot.getMaxStackSize(source)); int newCount = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots.size(), this.quickcraftType, source) + carry, maxSize); remaining -= newCount - carry; - slot.setByPlayer(source.copyWithCount(newCount)); -+ // slot.setByPlayer(source.copyWithCount(newCount)); -+ draggedSlots.put(slot.index, source.copyWithCount(newCount)); // CraftBukkit - Put in map instead of setting - } - } - +- } +- } +- - source.setCount(remaining); - this.setCarried(source); ++ // slot.setByPlayer(source.copyWithCount(newCount)); ++ draggedSlots.put(slot.index, source.copyWithCount(newCount)); // CraftBukkit - Put in map instead of setting ++ } ++ } ++ + // CraftBukkit start - InventoryDragEvent + org.bukkit.inventory.InventoryView view = this.getBukkitView(); + org.bukkit.inventory.ItemStack newCarried = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(source); @@ -159,7 +156,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db } this.resetQuickCraft(); -@@ -406,8 +502,11 @@ public abstract class AbstractContainerMenu { +@@ -405,8 +_,11 @@ if (slotIndex == -999) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { @@ -172,13 +169,13 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db } else { player.drop(this.getCarried().split(1), true); } -@@ -469,8 +568,18 @@ public abstract class AbstractContainerMenu { +@@ -468,8 +_,18 @@ } - slotx.setChanged(); + slot.setChanged(); + // CraftBukkit start - Make sure the client has the right slot contents -+ if (player instanceof ServerPlayer serverPlayer && slotx.getMaxStackSize() != Container.MAX_STACK) { -+ serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slotx.index, slotx.getItem())); ++ if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != Container.MAX_STACK) { ++ serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem())); + // Updating a crafting inventory makes the client reset the result slot, have to send it again + if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) { + serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); @@ -191,10 +188,10 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db ItemStack source = inventory.getItem(buttonNum); Slot target = this.slots.get(slotIndex); ItemStack targetItemStack = target.getItem(); -@@ -530,7 +639,11 @@ public abstract class AbstractContainerMenu { +@@ -529,7 +_,11 @@ } - itemStack = slotx.safeTake(amount, Integer.MAX_VALUE, player); + itemStack = slot.safeTake(amount, Integer.MAX_VALUE, player); - player.drop(itemStack, true); + // CraftBukkit start - SPIGOT-8010: break loop + if (player.drop(itemStack, true) == null) { @@ -204,7 +201,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db player.handleCreativeModeItemDrop(itemStack); } } -@@ -595,14 +708,15 @@ public abstract class AbstractContainerMenu { +@@ -590,14 +_,15 @@ if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -222,7 +219,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db boolean serverPlayerHasDisconnected = player instanceof ServerPlayer serverPlayer && serverPlayer.hasDisconnected(); if (playerRemovedNotChangingDimension || serverPlayerHasDisconnected) { player.drop(carried, false); -@@ -642,6 +756,14 @@ public abstract class AbstractContainerMenu { +@@ -637,6 +_,14 @@ public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(final ItemStack itemStack, final int startSlot, final int endSlot, final boolean backwards) { @@ -237,7 +234,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db boolean anythingChanged = false; int destSlot = startSlot; if (backwards) { -@@ -652,18 +774,27 @@ public abstract class AbstractContainerMenu { +@@ -647,18 +_,27 @@ while (!itemStack.isEmpty() && (backwards ? destSlot >= startSlot : destSlot < endSlot)) { Slot slot = this.slots.get(destSlot); ItemStack target = slot.getItem(); @@ -265,29 +262,29 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db anythingChanged = true; } } -@@ -686,10 +817,21 @@ public abstract class AbstractContainerMenu { +@@ -681,10 +_,21 @@ while (backwards ? destSlot >= startSlot : destSlot < endSlot) { - Slot slotx = this.slots.get(destSlot); - ItemStack targetx = slotx.getItem(); + Slot slot = this.slots.get(destSlot); + ItemStack target = slot.getItem(); + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + if (isCheck) { -+ targetx = targetx.copy(); ++ target = target.copy(); + } + // Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent - if (targetx.isEmpty() && slotx.mayPlace(itemStack)) { - int maxStackSize = slotx.getMaxStackSize(itemStack); + if (target.isEmpty() && slot.mayPlace(itemStack)) { + int maxStackSize = slot.getMaxStackSize(itemStack); + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + if (isCheck) { + itemStack.shrink(Math.min(itemStack.getCount(), maxStackSize)); + } else { + // Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent - slotx.setByPlayer(itemStack.split(Math.min(itemStack.getCount(), maxStackSize))); - slotx.setChanged(); + slot.setByPlayer(itemStack.split(Math.min(itemStack.getCount(), maxStackSize))); + slot.setChanged(); + } // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent anythingChanged = true; break; } -@@ -773,6 +915,11 @@ public abstract class AbstractContainerMenu { +@@ -768,6 +_,11 @@ } public ItemStack getCarried() { @@ -299,7 +296,7 @@ index d96e439e3c1f6ed6d15258757efbdb84f0f29224..e58fa32f0d93dd6b5243937cb380e8db return this.carried; } -@@ -826,4 +973,15 @@ public abstract class AbstractContainerMenu { +@@ -821,4 +_,15 @@ this.stateId = this.stateId + 1 & 32767; return this.stateId; } diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch similarity index 86% rename from paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch index efff8ab3d176..fdf2796bc797 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,22 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/BeaconMenu.java b/net/minecraft/world/inventory/BeaconMenu.java -index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23aeb12435 100644 --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -23,24 +23,14 @@ public class BeaconMenu extends AbstractContainerMenu { +@@ -22,20 +_,14 @@ private static final int USE_ROW_SLOT_START = 28; private static final int USE_ROW_SLOT_END = 37; private static final int NO_EFFECT = 0; - private final Container beacon = new SimpleContainer(1) { -- { -- Objects.requireNonNull(BeaconMenu.this); -- } -- - @Override - public boolean canPlaceItem(final int slot, final ItemStack itemStack) { - return itemStack.is(ItemTags.BEACON_PAYMENT_ITEMS); @@ -38,7 +26,7 @@ index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23 public BeaconMenu(final int containerId, final Container inventory) { this(containerId, inventory, new SimpleContainerData(3), ContainerLevelAccess.NULL); -@@ -48,6 +38,25 @@ public class BeaconMenu extends AbstractContainerMenu { +@@ -43,6 +_,25 @@ public BeaconMenu(final int containerId, final Container inventory, final ContainerData beaconData, final ContainerLevelAccess access) { super(MenuType.BEACON, containerId); @@ -64,7 +52,7 @@ index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23 checkContainerDataCount(beaconData, 3); this.beaconData = beaconData; this.access = access; -@@ -70,6 +79,7 @@ public class BeaconMenu extends AbstractContainerMenu { +@@ -65,6 +_,7 @@ @Override public boolean stillValid(final Player player) { @@ -72,7 +60,7 @@ index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23 return stillValid(this.access, player, Blocks.BEACON); } -@@ -143,13 +153,30 @@ public class BeaconMenu extends AbstractContainerMenu { +@@ -138,13 +_,30 @@ public @Nullable Holder getSecondaryEffect() { return decodeEffect(this.beaconData.get(2)); } @@ -106,7 +94,7 @@ index 80e323668ad23d19884180d43de80a1b6f822346..aab514519fcdb9bfa2cedb0a37628a23 } } -@@ -172,4 +199,17 @@ public class BeaconMenu extends AbstractContainerMenu { +@@ -167,4 +_,17 @@ return 1; } } diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch index 533e59d310b0..f83035ec169b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/ItemCombinerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -1,22 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/ItemCombinerMenu.java b/net/minecraft/world/inventory/ItemCombinerMenu.java -index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df608ef810 100644 --- a/net/minecraft/world/inventory/ItemCombinerMenu.java +++ b/net/minecraft/world/inventory/ItemCombinerMenu.java -@@ -16,16 +16,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { +@@ -15,12 +_,7 @@ protected final ContainerLevelAccess access; protected final Player player; protected final Container inputSlots; - protected final ResultContainer resultSlots = new ResultContainer() { -- { -- Objects.requireNonNull(ItemCombinerMenu.this); -- } -- - @Override - public void setChanged() { - ItemCombinerMenu.this.slotsChanged(this); @@ -26,16 +14,12 @@ index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df private final int resultSlotIndex; protected boolean mayPickup(final Player player, final boolean hasItem) { -@@ -45,6 +36,18 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { +@@ -40,6 +_,14 @@ ) { super(menuType, containerId); this.access = access; + // Paper start - Add missing InventoryHolders; delay field init + this.resultSlots = new ResultContainer(this.createBlockHolder(this.access)) { -+ { -+ Objects.requireNonNull(ItemCombinerMenu.this); -+ } -+ + @Override + public void setChanged() { + ItemCombinerMenu.this.slotsChanged(this); @@ -45,7 +29,7 @@ index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df this.player = inventory.player; this.inputSlots = this.createContainer(itemInputSlots.getNumOfInputSlots()); this.resultSlotIndex = itemInputSlots.getResultSlotIndex(); -@@ -54,15 +57,15 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { +@@ -49,11 +_,11 @@ } private void createInputSlots(final ItemCombinerMenuSlotDefinition itemInputSlots) { @@ -53,10 +37,6 @@ index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df - this.addSlot(new Slot(this.inputSlots, slot.slotIndex(), slot.x(), slot.y()) { + for (final ItemCombinerMenuSlotDefinition.SlotDefinition slotDefinition : itemInputSlots.getSlots()) { // Paper - fix conflicting variable name + this.addSlot(new Slot(this.inputSlots, slotDefinition.slotIndex(), slotDefinition.x(), slotDefinition.y()) { // Paper - fix conflicting variable name - { - Objects.requireNonNull(ItemCombinerMenu.this); - } - @Override public boolean mayPlace(final ItemStack itemStack) { - return slot.mayPlace().test(itemStack); @@ -64,16 +44,16 @@ index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df } }); } -@@ -96,7 +99,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { +@@ -83,7 +_,7 @@ public abstract void createResult(); private SimpleContainer createContainer(final int size) { - return new SimpleContainer(size) { -+ return new SimpleContainer(this.createBlockHolder(this.access), size) { - { - Objects.requireNonNull(ItemCombinerMenu.this); - } -@@ -114,6 +117,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { ++ return new SimpleContainer(this.createBlockHolder(this.access), size) { // Paper - pass block holder + @Override + public void setChanged() { + super.setChanged(); +@@ -97,6 +_,7 @@ super.slotsChanged(container); if (container == this.inputSlots) { this.createResult(); @@ -81,7 +61,7 @@ index a8e294746a4ece509b4b7587fb39fe9c51d1432e..2ecda29bb90e6c93e7fb3e08a79187df } } -@@ -125,6 +129,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu { +@@ -108,6 +_,7 @@ @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch new file mode 100644 index 000000000000..51ed6331b18c --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch @@ -0,0 +1,102 @@ +--- a/net/minecraft/world/inventory/LecternMenu.java ++++ b/net/minecraft/world/inventory/LecternMenu.java +@@ -14,12 +_,29 @@ + public static final int BUTTON_PAGE_JUMP_RANGE_START = 100; + private final Container lectern; + private final ContainerData lecternData; +- +- public LecternMenu(final int containerId) { +- this(containerId, new SimpleContainer(1), new SimpleContainerData(1)); +- } +- +- public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData) { ++ // CraftBukkit start ++ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLecternView view = null; ++ private final org.bukkit.entity.Player player; ++ ++ @Override ++ public org.bukkit.craftbukkit.inventory.view.CraftLecternView getBukkitView() { ++ if (this.view != null) { ++ return this.view; ++ } ++ ++ org.bukkit.craftbukkit.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLectern(this.lectern); ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftLecternView(this.player, inventory, this); ++ return this.view; ++ } ++ // CraftBukkit end ++ ++ // CraftBukkit start - add player inventory ++ public LecternMenu(final int containerId, final net.minecraft.world.entity.player.Inventory inventory) { ++ this(containerId, new SimpleContainer(1), new SimpleContainerData(1), inventory); ++ } ++ ++ public LecternMenu(final int containerId, final Container lectern, final ContainerData lecternData, net.minecraft.world.entity.player.Inventory inventory) { ++ // CraftBukkit end - add player inventory + super(MenuType.LECTERN, containerId); + checkContainerSize(lectern, 1); + checkContainerDataCount(lecternData, 1); +@@ -33,10 +_,12 @@ + } + }); + this.addDataSlots(lecternData); ++ this.player = (org.bukkit.entity.Player) inventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override + public boolean clickMenuButton(final Player player, final int buttonId) { ++ io.papermc.paper.event.player.PlayerLecternPageChangeEvent playerLecternPageChangeEvent; org.bukkit.craftbukkit.inventory.CraftInventoryLectern bukkitView; // Paper - Add PlayerLecternPageChangeEvent + if (buttonId >= 100) { + int pageToSet = buttonId - 100; + this.setData(0, pageToSet); +@@ -46,12 +_,26 @@ + switch (buttonId) { + case 1: { + int currentPage = this.lecternData.get(0); +- this.setData(0, currentPage - 1); ++ // Paper start - Add PlayerLecternPageChangeEvent ++ bukkitView = (org.bukkit.craftbukkit.inventory.CraftInventoryLectern) getBukkitView().getTopInventory(); ++ playerLecternPageChangeEvent = new io.papermc.paper.event.player.PlayerLecternPageChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), bukkitView.getHolder(), bukkitView.getBook(), io.papermc.paper.event.player.PlayerLecternPageChangeEvent.PageChangeDirection.LEFT, currentPage, currentPage - 1); ++ if (!playerLecternPageChangeEvent.callEvent()) { ++ return false; ++ } ++ this.setData(0, playerLecternPageChangeEvent.getNewPage()); ++ // Paper end - Add PlayerLecternPageChangeEvent + return true; + } + case 2: { + int currentPage = this.lecternData.get(0); +- this.setData(0, currentPage + 1); ++ // Paper start - Add PlayerLecternPageChangeEvent ++ bukkitView = (org.bukkit.craftbukkit.inventory.CraftInventoryLectern) getBukkitView().getTopInventory(); ++ playerLecternPageChangeEvent = new io.papermc.paper.event.player.PlayerLecternPageChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), bukkitView.getHolder(), bukkitView.getBook(), io.papermc.paper.event.player.PlayerLecternPageChangeEvent.PageChangeDirection.RIGHT, currentPage, currentPage + 1); ++ if (!playerLecternPageChangeEvent.callEvent()) { ++ return false; ++ } ++ this.setData(0, playerLecternPageChangeEvent.getNewPage()); ++ // Paper end - Add PlayerLecternPageChangeEvent + return true; + } + case 3: +@@ -59,6 +_,12 @@ + return false; + } + ++ // CraftBukkit start - Event for taking the book ++ org.bukkit.event.player.PlayerTakeLecternBookEvent event = new org.bukkit.event.player.PlayerTakeLecternBookEvent(this.player, this.getBukkitView().getTopInventory().getHolder()); ++ if (!event.callEvent()) { ++ return false; ++ } ++ // CraftBukkit end + ItemStack book = this.lectern.removeItemNoUpdate(0); + this.lectern.setChanged(); + if (!player.getInventory().add(book)) { +@@ -84,6 +_,8 @@ + + @Override + public boolean stillValid(final Player player) { ++ if (this.lectern instanceof net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory lecternInventory && !lecternInventory.getLectern().hasBook()) return false; // CraftBukkit ++ if (!this.checkReachable) return true; // CraftBukkit + return this.lectern.stillValid(player); + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch similarity index 86% rename from paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch index 5649ec42ebb9..0b1e4e071bbd 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch @@ -1,27 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/LoomMenu.java b/net/minecraft/world/inventory/LoomMenu.java -index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b439a2364cc 100644 --- a/net/minecraft/world/inventory/LoomMenu.java +++ b/net/minecraft/world/inventory/LoomMenu.java -@@ -39,29 +39,23 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -38,21 +_,23 @@ private final Slot patternSlot; private final Slot resultSlot; private long lastSoundTime; - private final Container inputContainer = new SimpleContainer(3) { -- { -- Objects.requireNonNull(LoomMenu.this); -- } -+ private final Container inputContainer; // Paper - Add missing InventoryHolders - move down -+ private final Container outputContainer; // Paper - Add missing InventoryHolders - move down -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLoomView view = null; -+ private final org.bukkit.entity.Player player; - - @Override - public void setChanged() { - super.setChanged(); @@ -30,20 +13,24 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 - } - }; - private final Container outputContainer = new SimpleContainer(1) { -- { -- Objects.requireNonNull(LoomMenu.this); -+ @Override -+ public org.bukkit.craftbukkit.inventory.view.CraftLoomView getBukkitView() { -+ if (this.view != null) { -+ return this.view; - } - - @Override - public void setChanged() { - super.setChanged(); - LoomMenu.this.slotUpdateListener.run(); - } - }; ++ private final Container inputContainer; // Paper - Add missing InventoryHolders - move down ++ private final Container outputContainer; // Paper - Add missing InventoryHolders - move down ++ // CraftBukkit start ++ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftLoomView view = null; ++ private final org.bukkit.entity.Player player; ++ ++ @Override ++ public org.bukkit.craftbukkit.inventory.view.CraftLoomView getBukkitView() { ++ if (this.view != null) { ++ return this.view; ++ } ++ + org.bukkit.craftbukkit.inventory.CraftInventoryLoom inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLoom(this.inputContainer, this.outputContainer); + this.view = new org.bukkit.craftbukkit.inventory.view.CraftLoomView(this.player, inventory, this); + return this.view; @@ -52,7 +39,7 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 public LoomMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -70,6 +64,28 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -61,6 +_,28 @@ public LoomMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.LOOM, containerId); this.access = access; @@ -79,9 +66,9 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 + }; + // CraftBukkit end this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { - { - Objects.requireNonNull(LoomMenu.this); -@@ -131,6 +147,7 @@ public class LoomMenu extends AbstractContainerMenu { + @Override + public boolean mayPlace(final ItemStack itemStack) { +@@ -106,6 +_,7 @@ this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlot(this.selectedBannerPatternIndex); this.patternGetter = inventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN); @@ -89,7 +76,7 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 } private static boolean isPatternItem(final ItemStack itemStack) { -@@ -143,14 +160,39 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -118,14 +_,39 @@ @Override public boolean stillValid(final Player player) { @@ -131,7 +118,7 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 return true; } else { return false; -@@ -212,7 +254,8 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -187,7 +_,8 @@ this.resultSlot.set(ItemStack.EMPTY); } @@ -141,7 +128,7 @@ index 0757602c1687ff13995c4d46a6a124b88cfd1ed6..bb9541a373fdc9fd1e76220d8d824b43 } else { this.resultSlot.set(ItemStack.EMPTY); this.selectablePatterns = List.of(); -@@ -302,7 +345,14 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -277,7 +_,14 @@ result.update( DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, diff --git a/paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch similarity index 87% rename from paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch index 0c58f015cc5a..b6e26231a701 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java -index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30ebf4854f6 100644 --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -121,6 +121,15 @@ public abstract class FlowingFluid extends Fluid { +@@ -120,6 +_,15 @@ Fluid newBelowFluidType = newBelowFluid.getType(); if (belowFluid.canBeReplacedWith(level, belowPos, newBelowFluidType, Direction.DOWN) && canHoldSpecificFluid(level, belowPos, belowState, newBelowFluidType)) { @@ -24,7 +16,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e this.spreadTo(level, belowPos, belowState, Direction.DOWN, newBelowFluid); if (this.sourceNeighborCount(level, pos) >= 3) { this.spreadToSides(level, pos, fluidState, state); -@@ -149,7 +158,18 @@ public abstract class FlowingFluid extends Fluid { +@@ -148,7 +_,18 @@ Direction spread = entry.getKey(); FluidState newNeighborFluid = entry.getValue(); BlockPos neighborPos = pos.relative(spread); @@ -44,7 +36,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e } } } -@@ -161,7 +181,8 @@ public abstract class FlowingFluid extends Fluid { +@@ -160,7 +_,8 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos relativePos = mutablePos.setWithOffset(pos, direction); @@ -54,7 +46,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e FluidState fluidState = blockState.getFluidState(); if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, relativePos, blockState)) { if (fluidState.isSource()) { -@@ -264,13 +285,15 @@ public abstract class FlowingFluid extends Fluid { +@@ -265,13 +_,15 @@ container.placeLiquid(level, pos, state, target); } else { if (!state.isAir()) { @@ -71,7 +63,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e protected abstract void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state); protected int getSlopeDistance( -@@ -281,7 +304,8 @@ public abstract class FlowingFluid extends Fluid { +@@ -282,7 +_,8 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { if (direction != from) { BlockPos testPos = pos.relative(direction); @@ -81,7 +73,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e FluidState testFluidState = testState.getFluidState(); if (this.canPassThrough(level, this.getFlowing(), pos, state, direction, testPos, testState, testFluidState)) { if (context.isHole(testPos)) { -@@ -363,7 +387,8 @@ public abstract class FlowingFluid extends Fluid { +@@ -364,7 +_,8 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos testPos = pos.relative(direction); @@ -91,7 +83,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e FluidState testFluidState = testState.getFluidState(); if (this.canMaybePassThrough(level, pos, state, direction, testPos, testState, testFluidState)) { FluidState newFluid = this.getNewLiquid(level, testPos, testState); -@@ -434,10 +459,24 @@ public abstract class FlowingFluid extends Fluid { +@@ -435,10 +_,24 @@ if (newFluidState.isEmpty()) { fluidState = newFluidState; blockState = Blocks.AIR.defaultBlockState(); @@ -105,7 +97,7 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e level.setBlock(pos, blockState, Block.UPDATE_ALL); } else if (newFluidState != fluidState) { fluidState = newFluidState; - blockState = newFluidState.createLegacyBlock(); + blockState = fluidState.createLegacyBlock(); + // CraftBukkit start + org.bukkit.event.block.FluidLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFluidLevelChangeEvent(level, pos, blockState); + if (event.isCancelled()) { @@ -114,9 +106,9 @@ index 91b0379efd3e56d0ee36decd0edc2ac257cdc199..27aa4e640ee29d96a854846bb906c30e + blockState = ((org.bukkit.craftbukkit.block.data.CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end level.setBlock(pos, blockState, Block.UPDATE_ALL); - level.scheduleTick(pos, newFluidState.getType(), tickDelay); + level.scheduleTick(pos, fluidState.getType(), tickDelay); } -@@ -510,8 +549,27 @@ public abstract class FlowingFluid extends Fluid { +@@ -507,8 +_,27 @@ return this.getBlockState(pos, this.getCacheKey(pos)); } From e367ce5fab50966313e5c7429f310ea7dbffd4e3 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 21:15:14 +0100 Subject: [PATCH 09/16] 90 --- .../criterion/LocationPredicate.java.patch | 19 --- .../world/entity/monster/Endermite.java.patch | 28 ---- .../world/entity/monster/Monster.java.patch | 19 --- .../component/LodestoneTracker.java.patch | 19 --- ...ApplyStatusEffectsConsumeEffect.java.patch | 27 ---- .../mojang/math/OctahedralGroup.java.patch | 20 +-- .../criterion/LocationPredicate.java.patch | 11 ++ .../net/minecraft/core/Direction.java.patch | 16 +- .../minecraft/core/HolderLookup.java.patch | 30 ++-- .../minecraft/core/MappedRegistry.java.patch | 42 +++--- .../net/minecraft/core/Rotations.java.patch | 19 +-- .../config/PrepareSpawnTask.java.patch | 121 +++++++-------- .../world/entity/animal/bee/Bee.java.patch | 40 ++--- .../world/entity/monster/EnderMan.java.patch | 71 ++++----- .../world/entity/monster/Endermite.java.patch | 20 +++ .../world/entity/monster/Monster.java.patch | 11 ++ .../world/entity/monster/Phantom.java.patch | 34 ++--- .../entity/monster/Silverfish.java.patch | 24 +-- .../inventory/CartographyTableMenu.java.patch | 28 +--- .../inventory/EnchantmentMenu.java.patch | 138 ++++++++---------- .../world/inventory/GrindstoneMenu.java.patch | 28 +--- .../inventory/StonecutterMenu.java.patch | 99 ++++++------- .../component/LodestoneTracker.java.patch | 11 ++ .../component/ResolvableProfile.java.patch | 16 +- ...ApplyStatusEffectsConsumeEffect.java.patch | 20 +++ 25 files changed, 366 insertions(+), 545 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch rename paper-server/patches/{rejected => sources}/com/mojang/math/OctahedralGroup.java.patch (54%) create mode 100644 paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/core/Direction.java.patch (69%) rename paper-server/patches/{rejected => sources}/net/minecraft/core/HolderLookup.java.patch (58%) rename paper-server/patches/{rejected => sources}/net/minecraft/core/MappedRegistry.java.patch (67%) rename paper-server/patches/{rejected => sources}/net/minecraft/core/Rotations.java.patch (59%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/network/config/PrepareSpawnTask.java.patch (67%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/bee/Bee.java.patch (76%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/monster/EnderMan.java.patch (71%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/monster/Phantom.java.patch (54%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/monster/Silverfish.java.patch (68%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/CartographyTableMenu.java.patch (81%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/EnchantmentMenu.java.patch (54%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/GrindstoneMenu.java.patch (82%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/inventory/StonecutterMenu.java.patch (54%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/component/ResolvableProfile.java.patch (60%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch b/paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch deleted file mode 100644 index 5cbea554c724..000000000000 --- a/paper-server/patches/rejected/net/minecraft/advancements/criterion/LocationPredicate.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/advancements/criterion/LocationPredicate.java b/net/minecraft/advancements/criterion/LocationPredicate.java -index 6ba5ffb666d68be734a70323c0eb942708b8e77e..1d5209fa2cb129e59fa9b311bbe0ac9fe11e362c 100644 ---- a/net/minecraft/advancements/criterion/LocationPredicate.java -+++ b/net/minecraft/advancements/criterion/LocationPredicate.java -@@ -44,7 +44,7 @@ public record LocationPredicate( - public boolean matches(final ServerLevel level, final double x, final double y, final double z) { - if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { - return false; -- } else if (this.dimension.isPresent() && this.dimension.get() != level.dimension()) { -+ } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? level.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(level))) { // Paper - Add option for strict advancement dimension checks - return false; - } else { - BlockPos pos = BlockPos.containing(x, y, z); diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch deleted file mode 100644 index 96925ee4467d..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Endermite.java.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/Endermite.java b/net/minecraft/world/entity/monster/Endermite.java -index d2b57a3b3bf0ab25e3ec78b32549df0389fe35dc..cc4e015e355f0c76a52cb64a82cced57700032af 100644 ---- a/net/minecraft/world/entity/monster/Endermite.java -+++ b/net/minecraft/world/entity/monster/Endermite.java -@@ -123,7 +123,7 @@ public class Endermite extends Monster { - } - - if (this.life >= 2400) { -- this.discard(); -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } - } - } -@@ -136,7 +136,7 @@ public class Endermite extends Monster { - } else if (EntitySpawnReason.isSpawner(spawnReason)) { - return true; - } else { -- Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); -+ Player nearestPlayer = level.getNearestPlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); // Paper - Affects Spawning API - return nearestPlayer == null; - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch deleted file mode 100644 index e9e873aa11e5..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Monster.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/Monster.java b/net/minecraft/world/entity/monster/Monster.java -index 515d4e90f3beeedd1b4d7e4180d0fb7cf73612c5..4ac86e516641142a7c3bd414dc3450e912a1c2b0 100644 ---- a/net/minecraft/world/entity/monster/Monster.java -+++ b/net/minecraft/world/entity/monster/Monster.java -@@ -88,7 +88,7 @@ public abstract class Monster extends PathfinderMob implements Enemy { - return false; - } else { - DimensionType dimensionType = level.dimensionType(); -- int blockLightLimit = dimensionType.monsterSpawnBlockLightLimit(); -+ int blockLightLimit = level.getLevel().paperConfig().entities.spawning.monsterSpawnMaxLightLevel.or(dimensionType.monsterSpawnBlockLightLimit()); // Paper - Configurable max block light for monster spawning - if (blockLightLimit < 15 && level.getBrightness(LightLayer.BLOCK, pos) > blockLightLimit) { - return false; - } else { diff --git a/paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch deleted file mode 100644 index 6aa138b8a788..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/component/LodestoneTracker.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/component/LodestoneTracker.java b/net/minecraft/world/item/component/LodestoneTracker.java -index a77e820d7b5ac01de7aa959fd6fed318b9169894..649988375dd5d6406ad4137534373d0a3548f0b3 100644 ---- a/net/minecraft/world/item/component/LodestoneTracker.java -+++ b/net/minecraft/world/item/component/LodestoneTracker.java -@@ -29,7 +29,7 @@ public record LodestoneTracker(Optional target, boolean tracked) { - return this; - } else { - BlockPos blockPos = this.target.get().pos(); -- return level.isInWorldBounds(blockPos) && level.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos) -+ return level.isInWorldBounds(blockPos) && (!level.hasChunkAt(blockPos) || level.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) // Paper - Prevent compass from loading chunks - ? this - : new LodestoneTracker(Optional.empty(), true); - } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch b/paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch deleted file mode 100644 index b9c55e83135c..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -index 1a413a0dbc63478ece9533f81ac5f1edd5d1f71b..66977396551bb2c3e0b602f4c1fc4b94d3a31777 100644 ---- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -+++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -@@ -46,14 +46,14 @@ public record ApplyStatusEffectsConsumeEffect(List effects, f - } - - @Override -- public boolean apply(final Level level, final ItemStack stack, final LivingEntity user) { -+ public boolean apply(final Level level, final ItemStack stack, final LivingEntity user, final org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { // CraftBukkit - if (user.getRandom().nextFloat() >= this.probability) { - return false; - } else { - boolean anyApplied = false; - - for (MobEffectInstance effect : this.effects) { -- if (user.addEffect(new MobEffectInstance(effect))) { -+ if (user.addEffect(new MobEffectInstance(effect), cause)) { // CraftBukkit - anyApplied = true; - } - } diff --git a/paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch similarity index 54% rename from paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch rename to paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index bc69eda6f58b..78267026348b 100644 --- a/paper-server/patches/rejected/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,27 +1,21 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/com/mojang/math/OctahedralGroup.java b/com/mojang/math/OctahedralGroup.java -index 9b0864614728596b9c885305d540fd8a39277aee..9be2c8e912f52a3099b9a358ed3e5b17f31dd4ae 100644 --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -99,6 +99,12 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -99,6 +_,14 @@ .map(f -> Arrays.stream(values()).filter(s -> f.compose(s) == IDENTITY).findAny().get()) .toArray(OctahedralGroup[]::new); ++ // Paper start - Avoid Lazy Initialization for Enum Fields + static { + for (OctahedralGroup octahedralGroup : values()) { -+ octahedralGroup.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields ++ octahedralGroup.initializeRotationDirections(); + } + } ++ // Paper end - Avoid Lazy Initialization for Enum Fields + - private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { + OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -139,7 +145,7 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -139,7 +_,7 @@ return this.name; } @@ -30,7 +24,7 @@ index 9b0864614728596b9c885305d540fd8a39277aee..9be2c8e912f52a3099b9a358ed3e5b17 if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, facing -> { Direction.Axis oldAxis = facing.getAxis(); -@@ -150,6 +156,11 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -150,6 +_,11 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch new file mode 100644 index 000000000000..17c5ea52bfc2 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/advancements/criterion/LocationPredicate.java ++++ b/net/minecraft/advancements/criterion/LocationPredicate.java +@@ -46,7 +_,7 @@ + return false; + } + +- if (this.dimension.isPresent() && this.dimension.get() != level.dimension()) { ++ if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? level.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(level))) { // Paper - Add option for strict advancement dimension checks + return false; + } + diff --git a/paper-server/patches/rejected/net/minecraft/core/Direction.java.patch b/paper-server/patches/sources/net/minecraft/core/Direction.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/core/Direction.java.patch rename to paper-server/patches/sources/net/minecraft/core/Direction.java.patch index 58e852aecd2d..9d42e33e9aff 100644 --- a/paper-server/patches/rejected/net/minecraft/core/Direction.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Direction.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java -index a47cff508b912c9eb2e545710f37fe8105c37ca2..3f516ffd7a76f1d17daaa865f7446803b8217bcc 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -63,6 +63,12 @@ public enum Direction implements StringRepresentable { +@@ -63,6 +_,12 @@ .sorted(Comparator.comparingInt(d -> d.data2d)) .toArray(Direction[]::new); @@ -18,10 +10,10 @@ index a47cff508b912c9eb2e545710f37fe8105c37ca2..3f516ffd7a76f1d17daaa865f7446803 + private final int adjZ; + // Paper end - Perf: Inline shift direction fields + - private Direction( + Direction( final int data3d, final int oppositeIndex, -@@ -81,6 +87,11 @@ public enum Direction implements StringRepresentable { +@@ -81,6 +_,11 @@ this.normal = normal; this.normalVec3 = Vec3.atLowerCornerOf(normal); this.normalVec3f = new Vector3f(normal.getX(), normal.getY(), normal.getZ()); @@ -33,7 +25,7 @@ index a47cff508b912c9eb2e545710f37fe8105c37ca2..3f516ffd7a76f1d17daaa865f7446803 } public static Direction[] orderedByNearest(final Entity entity) { -@@ -253,15 +264,15 @@ public enum Direction implements StringRepresentable { +@@ -253,15 +_,15 @@ } public int getStepX() { diff --git a/paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch b/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch similarity index 58% rename from paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch rename to paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch index e2b9baa5bb86..78b3e1a0b6ac 100644 --- a/paper-server/patches/rejected/net/minecraft/core/HolderLookup.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch @@ -1,27 +1,17 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/HolderLookup.java b/net/minecraft/core/HolderLookup.java -index ff8a3ae629ec89a79c6508cd5f5bbcd15616802c..36dc097890a276768a1dabb9ff48e430ad833c8c 100644 --- a/net/minecraft/core/HolderLookup.java +++ b/net/minecraft/core/HolderLookup.java -@@ -69,6 +69,9 @@ public interface HolderLookup extends HolderGetter { +@@ -68,6 +_,7 @@ } - public interface RegistryLookup extends HolderLookup, HolderOwner { -+ + interface RegistryLookup extends HolderLookup, HolderOwner { + Optional getValueForCopying(ResourceKey resourceKey); // Paper - add method to get the value for pre-filling builders in the reg mod API -+ ResourceKey> key(); Lifecycle registryLifecycle(); -@@ -83,6 +86,13 @@ public interface HolderLookup extends HolderGetter { - Objects.requireNonNull(RegistryLookup.this); - } +@@ -78,6 +_,13 @@ + default HolderLookup.RegistryLookup filterElements(final Predicate filter) { + return new HolderLookup.RegistryLookup.Delegate() { + // Paper start - add getValueForCopying + @Override + public Optional getValueForCopying(final ResourceKey resourceKey) { @@ -32,17 +22,17 @@ index ff8a3ae629ec89a79c6508cd5f5bbcd15616802c..36dc097890a276768a1dabb9ff48e430 @Override public HolderLookup.RegistryLookup parent() { return RegistryLookup.this; -@@ -103,6 +113,13 @@ public interface HolderLookup extends HolderGetter { - public interface Delegate extends HolderLookup.RegistryLookup { - HolderLookup.RegistryLookup parent(); +@@ -97,6 +_,13 @@ + interface Delegate extends HolderLookup.RegistryLookup { + HolderLookup.RegistryLookup parent(); ++ + // Paper start - add getValueForCopying + @Override + default Optional getValueForCopying(ResourceKey resourceKey) { + return this.parent().getValueForCopying(resourceKey); + } + // Paper end - add getValueForCopying -+ + @Override default ResourceKey> key() { - return this.parent().key(); diff --git a/paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch similarity index 67% rename from paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch rename to paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch index 3b1d12debe1a..ab63e3224eb9 100644 --- a/paper-server/patches/rejected/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java -index 299d0e1a4304b6e95ccba2424488176ad2669ef7..3c1490ac7c259da04031db2f170e0c0a5f512191 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -33,17 +33,25 @@ import org.jspecify.annotations.Nullable; +@@ -33,17 +_,25 @@ public class MappedRegistry implements WritableRegistry { private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); @@ -39,23 +31,23 @@ index 299d0e1a4304b6e95ccba2424488176ad2669ef7..3c1490ac7c259da04031db2f170e0c0a @Override public Stream> listTags() { -@@ -114,6 +122,7 @@ public class MappedRegistry implements WritableRegistry { - this.toId.put(value, newId); - this.registrationInfos.put(key, registrationInfo); - this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); -+ this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API - return holder; - } +@@ -117,6 +_,7 @@ + this.toId.put(value, newId); + this.registrationInfos.put(key, registrationInfo); + this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); ++ this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API + return holder; } -@@ -275,6 +284,7 @@ public class MappedRegistry implements WritableRegistry { - return this; - } else { - this.frozen = true; -+ this.temporaryUnfrozenMap.clear(); // Paper - support pre-filling in registry mod API - this.byValue.forEach((value, holder) -> holder.bindValue((T)value)); - List unboundEntries = this.byKey - .entrySet() -@@ -522,4 +532,13 @@ public class MappedRegistry implements WritableRegistry { + +@@ -278,6 +_,7 @@ + } + + this.frozen = true; ++ this.temporaryUnfrozenMap.clear(); // Paper - support pre-filling in registry mod API + this.byValue.forEach((value, holder) -> holder.bindValue((T)value)); + List unboundEntries = this.byKey + .entrySet() +@@ -512,4 +_,13 @@ Stream> getTags(); } diff --git a/paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch b/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch similarity index 59% rename from paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch rename to paper-server/patches/sources/net/minecraft/core/Rotations.java.patch index fef9d2911a86..97edf73d1f85 100644 --- a/paper-server/patches/rejected/net/minecraft/core/Rotations.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/Rotations.java b/net/minecraft/core/Rotations.java -index 97a83c78923e707a1c3050842793084e37edf00e..5c3271029b0a09a6f3a4bc39e64f65f9ded46097 100644 --- a/net/minecraft/core/Rotations.java +++ b/net/minecraft/core/Rotations.java -@@ -26,11 +26,22 @@ public record Rotations(float x, float y, float z) { +@@ -26,10 +_,21 @@ output.writeFloat(value.z); } }; @@ -20,14 +12,13 @@ index 97a83c78923e707a1c3050842793084e37edf00e..5c3271029b0a09a6f3a4bc39e64f65f9 + SKIP_VALIDATION = false; + return rotations; + } -+ // Paper end - add internal method for skipping validation for plugins using userdev ++ // Paper end - add internal method for skipping validation for plugins using userdev - public Rotations(float x, float y, float z) { + public Rotations { + if (!SKIP_VALIDATION) { // Paper - add internal method for skipping validation for plugins using userdev x = !Float.isInfinite(x) && !Float.isNaN(x) ? x % 360.0F : 0.0F; y = !Float.isInfinite(y) && !Float.isNaN(y) ? y % 360.0F : 0.0F; z = !Float.isInfinite(z) && !Float.isNaN(z) ? z % 360.0F : 0.0F; + } // Paper - add internal method for skipping validation for plugins using userdev - this.x = x; - this.y = y; - this.z = z; + } + } diff --git a/paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch similarity index 67% rename from paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch rename to paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch index 80855d43a359..b9b280a6aeab 100644 --- a/paper-server/patches/rejected/net/minecraft/server/network/config/PrepareSpawnTask.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/network/config/PrepareSpawnTask.java b/net/minecraft/server/network/config/PrepareSpawnTask.java -index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2afb2e3943 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -37,10 +37,18 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -36,10 +_,18 @@ private final LevelLoadListener loadListener; private PrepareSpawnTask.@Nullable State state; @@ -30,7 +22,7 @@ index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2a } @Override -@@ -50,16 +58,58 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -49,16 +_,58 @@ .getPlayerList() .loadPlayerData(this.nameAndId) .map(tag -> TagValueInput.create(reporter, this.server.registryAccess(), tag)); @@ -94,7 +86,7 @@ index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2a Vec2 spawnAngle = loadedPosition.rotation().orElse(new Vec2(respawnData.yaw(), respawnData.pitch())); this.state = new PrepareSpawnTask.Preparing(spawnLevel, spawnPosition, spawnAngle); } -@@ -111,10 +161,11 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -110,10 +_,11 @@ } private final class Preparing implements PrepareSpawnTask.State { @@ -106,65 +98,65 @@ index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2a + private Vec2 spawnAngle; // Paper - remove final private @Nullable CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture eventFuture; // Paper - private final ChunkLoadCounter chunkLoadCounter; + private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); private Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { -@@ -136,6 +187,54 @@ public class PrepareSpawnTask implements ConfigurationTask { - } else { - Vec3 spawnPosition = this.spawnPosition.join(); - if (this.chunkLoadFuture == null) { -+ // Paper start - PlayerSpawnLocationEvent -+ if (this.eventFuture == null && org.spigotmc.event.player.PlayerSpawnLocationEvent.getHandlerList().getRegisteredListeners().length != 0) { -+ ServerPlayer player; -+ if (PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents != null) { -+ player = PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents; -+ } else { -+ player = new ServerPlayer( -+ PrepareSpawnTask.this.server, -+ PrepareSpawnTask.this.server.overworld(), -+ PrepareSpawnTask.this.profile, -+ net.minecraft.server.level.ClientInformation.createDefault() -+ ); -+ PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents = player; -+ } -+ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent( -+ player.getBukkitEntity(), -+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPosition, this.spawnLevel, this.spawnAngle.x, this.spawnAngle.y) +@@ -133,6 +_,54 @@ + + Vec3 spawnPosition = this.spawnPosition.join(); + if (this.chunkLoadFuture == null) { ++ // Paper start - PlayerSpawnLocationEvent ++ if (this.eventFuture == null && org.spigotmc.event.player.PlayerSpawnLocationEvent.getHandlerList().getRegisteredListeners().length != 0) { ++ ServerPlayer player; ++ if (PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents != null) { ++ player = PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents; ++ } else { ++ player = new ServerPlayer( ++ PrepareSpawnTask.this.server, ++ PrepareSpawnTask.this.server.overworld(), ++ PrepareSpawnTask.this.profile, ++ net.minecraft.server.level.ClientInformation.createDefault() + ); -+ ev.callEvent(); -+ spawnPosition = io.papermc.paper.util.MCUtil.toVec3(ev.getSpawnLocation()); -+ if (ev.getSpawnLocation().getWorld() != null) this.spawnLevel = ((org.bukkit.craftbukkit.CraftWorld) ev.getSpawnLocation().getWorld()).getHandle(); -+ this.spawnPosition = CompletableFuture.completedFuture(spawnPosition); -+ this.spawnAngle = new Vec2(ev.getSpawnLocation().getYaw(), ev.getSpawnLocation().getPitch()); ++ PrepareSpawnTask.this.listener.connection.savedPlayerForLegacyEvents = player; + } ++ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent( ++ player.getBukkitEntity(), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPosition, this.spawnLevel, this.spawnAngle.x, this.spawnAngle.y) ++ ); ++ ev.callEvent(); ++ spawnPosition = io.papermc.paper.util.MCUtil.toVec3(ev.getSpawnLocation()); ++ if (ev.getSpawnLocation().getWorld() != null) this.spawnLevel = ((org.bukkit.craftbukkit.CraftWorld) ev.getSpawnLocation().getWorld()).getHandle(); ++ this.spawnPosition = CompletableFuture.completedFuture(spawnPosition); ++ this.spawnAngle = new Vec2(ev.getSpawnLocation().getYaw(), ev.getSpawnLocation().getPitch()); ++ } + -+ if (this.eventFuture == null && io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent.getHandlerList().getRegisteredListeners().length != 0) { -+ final Vec3 spawnPositionFinal = spawnPosition; -+ this.eventFuture = CompletableFuture.supplyAsync(() -> { -+ io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent ev = new io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent( -+ PrepareSpawnTask.this.listener.paperConnection, -+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPositionFinal, this.spawnLevel, this.spawnAngle.x, this.spawnAngle.y), -+ PrepareSpawnTask.this.newPlayer -+ ); -+ ev.callEvent(); -+ return ev.getSpawnLocation(); -+ }, io.papermc.paper.connection.PaperConfigurationTask.CONFIGURATION_POOL); -+ } -+ if (this.eventFuture != null) { -+ if (!this.eventFuture.isDone()) { -+ return null; -+ } -+ org.bukkit.Location location = this.eventFuture.join(); -+ spawnPosition = io.papermc.paper.util.MCUtil.toVec3(location); -+ this.spawnLevel = ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(); -+ this.spawnPosition = CompletableFuture.completedFuture(spawnPosition); -+ this.spawnAngle = new Vec2(location.getYaw(), location.getPitch()); ++ if (this.eventFuture == null && io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent.getHandlerList().getRegisteredListeners().length != 0) { ++ final Vec3 spawnPositionFinal = spawnPosition; ++ this.eventFuture = CompletableFuture.supplyAsync(() -> { ++ io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent ev = new io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent( ++ PrepareSpawnTask.this.listener.paperConnection, ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(spawnPositionFinal, this.spawnLevel, this.spawnAngle.x, this.spawnAngle.y), ++ PrepareSpawnTask.this.newPlayer ++ ); ++ ev.callEvent(); ++ return ev.getSpawnLocation(); ++ }, io.papermc.paper.connection.PaperConfigurationTask.CONFIGURATION_POOL); ++ } ++ if (this.eventFuture != null) { ++ if (!this.eventFuture.isDone()) { ++ return null; + } -+ // Paper end - PlayerSpawnLocationEvent - ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition)); - this.chunkLoadCounter - .track( -@@ -178,15 +277,48 @@ public class PrepareSpawnTask implements ConfigurationTask { ++ org.bukkit.Location location = this.eventFuture.join(); ++ spawnPosition = io.papermc.paper.util.MCUtil.toVec3(location); ++ this.spawnLevel = ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(); ++ this.spawnPosition = CompletableFuture.completedFuture(spawnPosition); ++ this.spawnAngle = new Vec2(location.getYaw(), location.getPitch()); ++ } ++ // Paper end - PlayerSpawnLocationEvent + ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition)); + this.chunkLoadCounter + .track( +@@ -172,14 +_,47 @@ public ServerPlayer spawn(final Connection connection, final CommonListenerCookie cookie) { ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(this.spawnPosition)); this.spawnLevel.waitForEntities(spawnChunk, 3); @@ -183,7 +175,6 @@ index 00bdb2f00f485579ed3778d85dd17701abc859aa..b5d993095aa77bb132c513f73dbf6d2a + } + // Paper end - configuration api - possibly use legacy saved server player instance - ServerPlayer var7; try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(player.problemPath(), PrepareSpawnTask.LOGGER)) { Optional input = PrepareSpawnTask.this.server .getPlayerList() diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch index 277ac815882d..d34102f08aa1 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/bee/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/bee/Bee.java b/net/minecraft/world/entity/animal/bee/Bee.java -index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82ab531aa4b 100644 --- a/net/minecraft/world/entity/animal/bee/Bee.java +++ b/net/minecraft/world/entity/animal/bee/Bee.java -@@ -150,10 +150,26 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -149,10 +_,26 @@ private Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -36,7 +28,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.FIRE_IN_NEIGHBOR, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -200,9 +216,18 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -199,9 +_,18 @@ @Override protected void addAdditionalSaveData(final ValueOutput output) { @@ -55,7 +47,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -240,7 +265,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -239,7 +_,7 @@ } if (poisonTime > 0) { @@ -64,7 +56,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a } } -@@ -483,7 +508,11 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -482,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -77,7 +69,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a } } -@@ -515,7 +544,8 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -514,7 +_,8 @@ return this.getFlag(FLAG_ROLL); } @@ -87,7 +79,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a this.setFlag(FLAG_ROLL, rolling); } -@@ -576,7 +606,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -571,7 +_,7 @@ if (effect != null) { this.usePlayerItem(player, hand, heldItem); if (!this.level().isClientSide()) { @@ -96,18 +88,18 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a } return InteractionResult.SUCCESS; -@@ -644,8 +674,9 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { - if (this.isInvulnerableTo(level, source)) { +@@ -640,8 +_,9 @@ return false; - } else { -+ if (!super.hurtServer(level, source, damage)) return false; // CraftBukkit - Only stop pollinating if entity was damaged - this.beePollinateGoal.stopPollinating(); -- return super.hurtServer(level, source, damage); -+ return true; // CraftBukkit - Only stop pollinating if entity was damaged } + ++ if (!super.hurtServer(level, source, damage)) return false; // CraftBukkit - Only stop pollinating if entity was damaged + this.beePollinateGoal.stopPollinating(); +- return super.hurtServer(level, source, damage); ++ return true; // CraftBukkit - Only stop pollinating if entity was damaged } -@@ -1007,7 +1038,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { + @Override +@@ -981,7 +_,7 @@ } } @@ -116,7 +108,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, belowPos, 15); Bee.this.level().setBlockAndUpdate(belowPos, growState); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1032,7 +1063,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -1005,7 +_,7 @@ @Override protected void alertOther(final Mob other, final LivingEntity hurtByMob) { if (other instanceof Bee && this.mob.hasLineOfSight(hurtByMob)) { @@ -125,7 +117,7 @@ index 580cb79d8424b4f656b5b87a2e1e6636f69f7001..35039ae12ce121426b6fcf4784a9a82a } } } -@@ -1198,7 +1229,7 @@ public class Bee extends Animal implements FlyingAnimal, NeutralMob { +@@ -1162,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch similarity index 71% rename from paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 8fdbcfb6c9a4..447399ad416c 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java -index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1fb7406200 100644 --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -119,9 +119,20 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -119,9 +_,20 @@ .add(Attributes.STEP_HEIGHT, 1.0); } @@ -31,7 +23,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f AttributeInstance movementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED); if (target == null) { this.targetChangeTime = 0; -@@ -135,6 +146,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -135,6 +_,7 @@ movementSpeed.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -39,7 +31,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f } @Override -@@ -207,6 +219,15 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -207,6 +_,15 @@ } private boolean isBeingStaredBy(final Player player) { @@ -55,7 +47,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, this.getEyeY()); } -@@ -244,7 +265,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -244,7 +_,7 @@ protected void customServerAiStep(final ServerLevel level) { if (level.isBrightOutside() && this.tickCount >= this.targetChangeTime + 600) { float br = this.getLightLevelDependentMagicValue(); @@ -64,34 +56,35 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f this.setTarget(null); this.teleport(); } -@@ -354,21 +375,25 @@ public class EnderMan extends Monster implements NeutralMob { - return false; - } else { - AbstractThrownPotion thrownPotion = source.getDirectEntity() instanceof AbstractThrownPotion potion ? potion : null; -- if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { -+ if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { // Paper - EndermanEscapeEvent - diff on change - below logic relies on this path covering non-projectile damage. - boolean result = super.hurtServer(level, source, damage); - if (!(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0) { -+ if (this.tryEscape(source.is(net.minecraft.tags.DamageTypeTags.IS_DROWNING) ? com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.DROWN : com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper - EndermanEscapeEvent - this.teleport(); -+ } // Paper - EndermanEscapeEvent - } - - return result; - } else { - boolean hurtWithCleanWater = thrownPotion != null && this.hurtWithCleanWater(level, source, thrownPotion, damage); +@@ -355,21 +_,25 @@ + } -+ if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - EndermanEscapeEvent - for (int i = 0; i < 64; i++) { - if (this.teleport()) { - return true; - } - } + AbstractThrownPotion thrownPotion = source.getDirectEntity() instanceof AbstractThrownPotion potion ? potion : null; +- if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { ++ if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { // Paper - EndermanEscapeEvent - diff on change - below logic relies on this path covering non-projectile damage. + boolean result = super.hurtServer(level, source, damage); + if (!(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0) { +- this.teleport(); ++ if (this.tryEscape(source.is(net.minecraft.tags.DamageTypeTags.IS_DROWNING) ? com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.DROWN : com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper - EndermanEscapeEvent ++ this.teleport(); + } // Paper - EndermanEscapeEvent + } + + return result; + } else { + boolean hurtWithCleanWater = thrownPotion != null && this.hurtWithCleanWater(level, source, thrownPotion, damage); - return hurtWithCleanWater; ++ if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - EndermanEscapeEvent + for (int i = 0; i < 64; i++) { + if (this.teleport()) { + return true; + } } -@@ -393,6 +418,16 @@ public class EnderMan extends Monster implements NeutralMob { ++ } // Paper - EndermanEscapeEvent + + return hurtWithCleanWater; + } +@@ -393,6 +_,16 @@ this.entityData.set(DATA_STARED_AT, true); } @@ -108,7 +101,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -@@ -451,16 +486,19 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -451,16 +_,19 @@ int yt = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int zt = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); BlockPos pos = new BlockPos(xt, yt, zt); @@ -129,7 +122,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f } } } -@@ -552,7 +590,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -552,7 +_,7 @@ } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player)this.target)) { @@ -138,7 +131,7 @@ index 47d2ddede77c0ece534f21580dc582de07e5c9c7..55a7cac408614d0efdece87a5380bd1f this.enderman.teleport(); } -@@ -591,15 +629,18 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -591,15 +_,18 @@ int yt = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0); int zt = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0); BlockPos pos = new BlockPos(xt, yt, zt); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch new file mode 100644 index 000000000000..a11c50cc2da3 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/monster/Endermite.java ++++ b/net/minecraft/world/entity/monster/Endermite.java +@@ -123,7 +_,7 @@ + } + + if (this.life >= 2400) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } + } + } +@@ -139,7 +_,7 @@ + return true; + } + +- Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); ++ Player nearestPlayer = level.getNearestPlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); // Paper - Affects Spawning API + return nearestPlayer == null; + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch new file mode 100644 index 000000000000..3ec4199e6dfb --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/Monster.java ++++ b/net/minecraft/world/entity/monster/Monster.java +@@ -89,7 +_,7 @@ + } + + DimensionType dimensionType = level.dimensionType(); +- int blockLightLimit = dimensionType.monsterSpawnBlockLightLimit(); ++ int blockLightLimit = level.getLevel().paperConfig().entities.spawning.monsterSpawnMaxLightLevel.or(dimensionType.monsterSpawnBlockLightLimit()); // Paper - Configurable max block light for monster spawning + if (blockLightLimit < 15 && level.getBrightness(LightLayer.BLOCK, pos) > blockLightLimit) { + return false; + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch similarity index 54% rename from paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index dc356a6985ed..c4f045dd2a00 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java -index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99c62033d2 100644 --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -50,6 +50,10 @@ public class Phantom extends Mob implements Enemy { +@@ -49,6 +_,10 @@ private Vec3 moveTargetPoint = Vec3.ZERO; public @Nullable BlockPos anchorPoint; private Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; @@ -19,7 +11,7 @@ index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99 public Phantom(final EntityType type, final Level level) { super(type, level); -@@ -137,6 +141,13 @@ public class Phantom extends Mob implements Enemy { +@@ -136,6 +_,13 @@ } } @@ -33,7 +25,7 @@ index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99 @Override protected void checkFallDamage(final double ya, final boolean onGround, final BlockState onState, final BlockPos pos) { } -@@ -165,6 +176,10 @@ public class Phantom extends Mob implements Enemy { +@@ -164,6 +_,10 @@ super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -44,7 +36,7 @@ index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99 } @Override -@@ -172,6 +187,10 @@ public class Phantom extends Mob implements Enemy { +@@ -171,6 +_,10 @@ super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -55,15 +47,15 @@ index 9030068c40368f5b15e942ec1c778ce14f67a3f4..61ca77cceeacf0c4ebecf3bb66c4eb99 } @Override -@@ -240,8 +259,10 @@ public class Phantom extends Mob implements Enemy { +@@ -233,8 +_,10 @@ - for (Player player : players) { - if (Phantom.this.canAttack(level, player, TargetingConditions.DEFAULT)) { -- Phantom.this.setTarget(player); -+ if (!level().paperConfig().entities.behavior.phantomsOnlyAttackInsomniacs || EntitySelector.IS_INSOMNIAC.test(player)) { // Paper - Add phantom creative and insomniac controls -+ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit - reason - return true; -+ } // Paper - Add phantom creative and insomniac controls - } + for (Player player : players) { + if (Phantom.this.canAttack(level, player, TargetingConditions.DEFAULT)) { +- Phantom.this.setTarget(player); ++ if (!level().paperConfig().entities.behavior.phantomsOnlyAttackInsomniacs || EntitySelector.IS_INSOMNIAC.test(player)) { // Paper - Add phantom creative and insomniac controls ++ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit - reason + return true; ++ } // Paper - Add phantom creative and insomniac controls } } + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch similarity index 68% rename from paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch index ee46ac476dae..aa80f388768c 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,23 +1,15 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/Silverfish.java b/net/minecraft/world/entity/monster/Silverfish.java -index 626f3bb5fd7f85f3a15ce4ab424cf9bc7873cc19..ba4ba5dfb1e51e2f45b0b81012ed6be27362c55c 100644 --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -117,7 +117,7 @@ public class Silverfish extends Monster { - } else if (EntitySpawnReason.isSpawner(spawnReason)) { +@@ -120,7 +_,7 @@ return true; - } else { -- Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); -+ Player nearestPlayer = level.getNearestPlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); // Paper - Affects Spawning API - return nearestPlayer == null; } + +- Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); ++ Player nearestPlayer = level.getNearestPlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); // Paper - Affects Spawning API + return nearestPlayer == null; } -@@ -168,9 +168,14 @@ public class Silverfish extends Monster { + +@@ -172,9 +_,14 @@ BlockPos pos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockState = level.getBlockState(pos); if (InfestedBlock.isCompatibleHostBlock(blockState)) { @@ -33,7 +25,7 @@ index 626f3bb5fd7f85f3a15ce4ab424cf9bc7873cc19..ba4ba5dfb1e51e2f45b0b81012ed6be2 } } } -@@ -210,6 +215,12 @@ public class Silverfish extends Monster { +@@ -214,6 +_,12 @@ BlockState blockState = level.getBlockState(testPos); Block block = blockState.getBlock(); if (block instanceof InfestedBlock) { diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch similarity index 81% rename from paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch index 7f1cc555db5d..2faa1d0a05de 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/CartographyTableMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/CartographyTableMenu.java b/net/minecraft/world/inventory/CartographyTableMenu.java -index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5b43c8a8b 100644 --- a/net/minecraft/world/inventory/CartographyTableMenu.java +++ b/net/minecraft/world/inventory/CartographyTableMenu.java -@@ -16,6 +16,21 @@ import net.minecraft.world.level.block.Blocks; +@@ -15,6 +_,21 @@ import net.minecraft.world.level.saveddata.maps.MapItemSavedData; public class CartographyTableMenu extends AbstractContainerMenu { @@ -30,15 +22,11 @@ index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5 public static final int MAP_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; public static final int RESULT_SLOT = 2; -@@ -25,28 +40,8 @@ public class CartographyTableMenu extends AbstractContainerMenu { +@@ -24,20 +_,8 @@ private static final int USE_ROW_SLOT_END = 39; private final ContainerLevelAccess access; private long lastSoundTime; - public final Container container = new SimpleContainer(2) { -- { -- Objects.requireNonNull(CartographyTableMenu.this); -- } -- - @Override - public void setChanged() { - CartographyTableMenu.this.slotsChanged(this); @@ -46,10 +34,6 @@ index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5 - } - }; - private final ResultContainer resultContainer = new ResultContainer() { -- { -- Objects.requireNonNull(CartographyTableMenu.this); -- } -- - @Override - public void setChanged() { - CartographyTableMenu.this.slotsChanged(this); @@ -61,7 +45,7 @@ index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5 public CartographyTableMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -54,6 +49,34 @@ public class CartographyTableMenu extends AbstractContainerMenu { +@@ -45,6 +_,34 @@ public CartographyTableMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.CARTOGRAPHY_TABLE, containerId); @@ -95,8 +79,8 @@ index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5 + // Paper end - Add missing InventoryHolders - move down this.access = access; this.addSlot(new Slot(this.container, 0, 15, 15) { - { -@@ -101,10 +124,12 @@ public class CartographyTableMenu extends AbstractContainerMenu { + @Override +@@ -80,10 +_,12 @@ } }); this.addStandardInventorySlots(inventory, 8, 84); @@ -109,7 +93,7 @@ index 2ddf938949078e99e671c1196bbf552c5a7d25c0..b6b30a7067485bc28cf804f76deb39e5 return stillValid(this.access, player, Blocks.CARTOGRAPHY_TABLE); } -@@ -120,6 +145,7 @@ public class CartographyTableMenu extends AbstractContainerMenu { +@@ -99,6 +_,7 @@ } else { this.resultContainer.removeItemNoUpdate(2); } diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch similarity index 54% rename from paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 154aad422eab..e288a8f9255c 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -1,22 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/EnchantmentMenu.java b/net/minecraft/world/inventory/EnchantmentMenu.java -index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1d7965823 100644 --- a/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -32,23 +32,17 @@ import net.minecraft.world.level.block.EnchantingTableBlock; +@@ -31,19 +_,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { private static final Identifier EMPTY_SLOT_LAPIS_LAZULI = Identifier.withDefaultNamespace("container/slot/lapis_lazuli"); - private final Container enchantSlots = new SimpleContainer(2) { -- { -- Objects.requireNonNull(EnchantmentMenu.this); -- } -- - @Override - public void setChanged() { - super.setChanged(); @@ -37,7 +25,7 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 public EnchantmentMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -56,6 +50,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -51,6 +_,22 @@ public EnchantmentMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.ENCHANTMENT, containerId); @@ -59,8 +47,8 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 + // Paper end - Add missing InventoryHolders this.access = access; this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { - { -@@ -93,13 +103,14 @@ public class EnchantmentMenu extends AbstractContainerMenu { + @Override +@@ -80,13 +_,14 @@ this.addDataSlot(DataSlot.shared(this.levelClue, 0)); this.addDataSlot(DataSlot.shared(this.levelClue, 1)); this.addDataSlot(DataSlot.shared(this.levelClue, 2)); @@ -76,7 +64,7 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 this.access.execute((level, pos) -> { IdMap> holders = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int bookcases = 0; -@@ -132,6 +143,42 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -119,6 +_,42 @@ } } @@ -119,67 +107,67 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 this.broadcastChanges(); }); } else { -@@ -158,19 +205,52 @@ public class EnchantmentMenu extends AbstractContainerMenu { - return false; - } else { - this.access.execute((level, pos) -> { -- ItemStack enchantmentItem = itemStack; -+ ItemStack enchantmentItem = itemStack; // Paper - diff on change - List newEnchantment = this.getEnchantmentList(level.registryAccess(), itemStack, buttonId, this.costs[buttonId]); -- if (!newEnchantment.isEmpty()) { -- player.onEnchantmentPerformed(itemStack, enchantmentCost); -- if (itemStack.is(Items.BOOK)) { -- enchantmentItem = itemStack.transmuteCopy(Items.ENCHANTED_BOOK); +@@ -148,19 +_,55 @@ + } + + this.access.execute((level, pos) -> { +- ItemStack enchantmentItem = itemStack; ++ ItemStack enchantmentItem = itemStack; // Paper - diff on change + List newEnchantment = this.getEnchantmentList(level.registryAccess(), enchantmentItem, buttonId, this.costs[buttonId]); +- if (!newEnchantment.isEmpty()) { +- player.onEnchantmentPerformed(enchantmentItem, enchantmentCost); ++ // CraftBukkit start ++ IdMap> registry = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); ++ if (true || !newEnchantment.isEmpty()) { ++ java.util.Map enchants = new java.util.HashMap<>(); ++ for (EnchantmentInstance instance : newEnchantment) { ++ enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment()), instance.level()); ++ } ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(enchantmentItem); ++ Holder holder = registry.byId(this.enchantClue[buttonId]); ++ if (holder == null) return; ++ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(holder); ++ int hintedEnchantmentLevel = this.levelClue[buttonId]; ++ org.bukkit.event.enchantment.EnchantItemEvent event = new org.bukkit.event.enchantment.EnchantItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.getBukkitView(), this.access.getLocation().getBlock(), craftItemStack, this.costs[buttonId], enchants, hintedEnchantment, hintedEnchantmentLevel, buttonId); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ int itemLevel = event.getExpLevelCost(); ++ if (event.isCancelled() || (itemLevel > player.experienceLevel && !player.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) { ++ return; ++ } ++ // CraftBukkit end ++ // Paper start ++ enchantmentItem = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(craftItemStack, event.getItem()); ++ if (enchantmentItem != itemStack) { ++ this.enchantSlots.setItem(0, enchantmentItem); ++ } + if (enchantmentItem.is(Items.BOOK)) { +- enchantmentItem = itemStack.transmuteCopy(Items.ENCHANTED_BOOK); ++ enchantmentItem = enchantmentItem.transmuteCopy(Items.ENCHANTED_BOOK); + this.enchantSlots.setItem(0, enchantmentItem); + } ++ // Paper end ++ + // CraftBukkit start -+ IdMap> registry = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); -+ if (true || !newEnchantment.isEmpty()) { -+ // player.onEnchantmentPerformed(itemStack, enchantmentCost); // Moved down -+ java.util.Map enchants = new java.util.HashMap<>(); -+ for (EnchantmentInstance instance : newEnchantment) { -+ enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment()), instance.level()); -+ } -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(enchantmentItem); -+ Holder holder = registry.byId(this.enchantClue[buttonId]); -+ if (holder == null) return; -+ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(holder); -+ int hintedEnchantmentLevel = this.levelClue[buttonId]; -+ org.bukkit.event.enchantment.EnchantItemEvent event = new org.bukkit.event.enchantment.EnchantItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.getBukkitView(), this.access.getLocation().getBlock(), craftItemStack, this.costs[buttonId], enchants, hintedEnchantment, hintedEnchantmentLevel, buttonId); -+ level.getCraftServer().getPluginManager().callEvent(event); -+ int itemLevel = event.getExpLevelCost(); -+ if (event.isCancelled() || (itemLevel > player.experienceLevel && !player.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) { -+ return; -+ } -+ // CraftBukkit end -+ // Paper start -+ enchantmentItem = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(craftItemStack, event.getItem()); -+ if (enchantmentItem != itemStack) { - this.enchantSlots.setItem(0, enchantmentItem); - } -+ if (enchantmentItem.is(Items.BOOK)) { -+ enchantmentItem = enchantmentItem.transmuteCopy(Items.ENCHANTED_BOOK); -+ this.enchantSlots.setItem(0, enchantmentItem); ++ for (java.util.Map.Entry entry : event.getEnchantsToAdd().entrySet()) { ++ Holder enchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); ++ if (enchantment == null) { ++ continue; + } -+ // Paper end + -+ // CraftBukkit start -+ for (java.util.Map.Entry entry : event.getEnchantsToAdd().entrySet()) { -+ Holder enchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); -+ if (enchantment == null) { -+ continue; -+ } ++ enchantmentItem.enchant(enchantment, entry.getValue()); ++ } ++ // CraftBukkit end ++ player.onEnchantmentPerformed(enchantmentItem, enchantmentCost); -- for (EnchantmentInstance enchantment : newEnchantment) { -- enchantmentItem.enchant(enchantment.enchantment(), enchantment.level()); -+ enchantmentItem.enchant(enchantment, entry.getValue()); - } -+ // CraftBukkit end -+ player.onEnchantmentPerformed(itemStack, enchantmentCost); + for (EnchantmentInstance enchantment : newEnchantment) { + enchantmentItem.enchant(enchantment.enchantment(), enchantment.level()); + } -+ // CraftBukkit - TODO: let plugins change this - currency.consume(enchantmentCost, player); - if (currency.isEmpty()) { - this.enchantSlots.setItem(1, ItemStack.EMPTY); -@@ -215,6 +295,12 @@ public class EnchantmentMenu extends AbstractContainerMenu { ++ // CraftBukkit - TODO: let plugins change this + currency.consume(enchantmentCost, player); + if (currency.isEmpty()) { + this.enchantSlots.setItem(1, ItemStack.EMPTY); +@@ -204,6 +_,12 @@ return goldStack.isEmpty() ? 0 : goldStack.getCount(); } @@ -192,7 +180,7 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 public int getEnchantmentSeed() { return this.enchantmentSeed.get(); } -@@ -227,6 +313,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -216,6 +_,7 @@ @Override public boolean stillValid(final Player player) { @@ -200,7 +188,7 @@ index f9845fe76d5333fc051e656010b7ddacdbd7a636..97ff32f0d9a44dc8edd9990dcb614fb1 return stillValid(this.access, player, Blocks.ENCHANTING_TABLE); } -@@ -274,4 +361,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -263,4 +_,17 @@ return clicked; } diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch similarity index 82% rename from paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 37cec610efb4..e7b0142bc662 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/GrindstoneMenu.java b/net/minecraft/world/inventory/GrindstoneMenu.java -index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da0736342c8b 100644 --- a/net/minecraft/world/inventory/GrindstoneMenu.java +++ b/net/minecraft/world/inventory/GrindstoneMenu.java -@@ -22,6 +22,21 @@ import net.minecraft.world.level.block.LevelEvent; +@@ -21,6 +_,21 @@ import net.minecraft.world.phys.Vec3; public class GrindstoneMenu extends AbstractContainerMenu { @@ -30,16 +22,12 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -30,18 +45,8 @@ public class GrindstoneMenu extends AbstractContainerMenu { +@@ -29,14 +_,8 @@ private static final int INV_SLOT_END = 30; private static final int USE_ROW_SLOT_START = 30; private static final int USE_ROW_SLOT_END = 39; - private final Container resultSlots = new ResultContainer(); - private final Container repairSlots = new SimpleContainer(2) { -- { -- Objects.requireNonNull(GrindstoneMenu.this); -- } -- - @Override - public void setChanged() { - super.setChanged(); @@ -51,7 +39,7 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 private final ContainerLevelAccess access; public GrindstoneMenu(final int containerId, final Inventory inventory) { -@@ -50,6 +55,22 @@ public class GrindstoneMenu extends AbstractContainerMenu { +@@ -45,6 +_,22 @@ public GrindstoneMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.GRINDSTONE, containerId); @@ -73,8 +61,8 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 + // Paper end - Add missing InventoryHolders this.access = access; this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { - { -@@ -85,7 +106,11 @@ public class GrindstoneMenu extends AbstractContainerMenu { + @Override +@@ -68,7 +_,11 @@ public void onTake(final Player player, final ItemStack carried) { access.execute((level, pos) -> { if (level instanceof ServerLevel) { @@ -87,7 +75,7 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 } level.levelEvent(LevelEvent.SOUND_GRINDSTONE_USED, pos, 0); -@@ -122,6 +147,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { +@@ -105,6 +_,7 @@ } }); this.addStandardInventorySlots(inventory, 8, 84); @@ -95,7 +83,7 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 } @Override -@@ -129,11 +155,13 @@ public class GrindstoneMenu extends AbstractContainerMenu { +@@ -112,11 +_,13 @@ super.slotsChanged(container); if (container == this.repairSlots) { this.createResult(); @@ -110,7 +98,7 @@ index e64adfa8622fb6478125e66db85e1b2065f370da..945ffd3b7f3dc5c5bf6b35d015b3da07 this.broadcastChanges(); } -@@ -221,6 +249,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { +@@ -206,6 +_,7 @@ @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch similarity index 54% rename from paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch rename to paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch index 0708f1ddf11e..d59204c41915 100644 --- a/paper-server/patches/rejected/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/inventory/StonecutterMenu.java b/net/minecraft/world/inventory/StonecutterMenu.java -index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7db43a327 100644 --- a/net/minecraft/world/inventory/StonecutterMenu.java +++ b/net/minecraft/world/inventory/StonecutterMenu.java -@@ -26,7 +26,7 @@ public class StonecutterMenu extends AbstractContainerMenu { +@@ -25,7 +_,7 @@ private static final int USE_ROW_SLOT_START = 29; private static final int USE_ROW_SLOT_END = 38; private final ContainerLevelAccess access; @@ -17,25 +9,22 @@ index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7 private final Level level; private SelectableRecipe.SingleInputSet recipesForInput = SelectableRecipe.SingleInputSet.empty(); private ItemStack input = ItemStack.EMPTY; -@@ -34,19 +34,23 @@ public class StonecutterMenu extends AbstractContainerMenu { +@@ -33,15 +_,23 @@ final Slot inputSlot; final Slot resultSlot; private Runnable slotUpdateListener = () -> {}; - public final Container container = new SimpleContainer(1) { -- { -- Objects.requireNonNull(StonecutterMenu.this); -- } -+ public final Container container; // Paper - Add missing InventoryHolders - move down -+ private final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftStonecutterView view = null; -+ private final org.bukkit.entity.Player player; - - @Override - public void setChanged() { - super.setChanged(); - StonecutterMenu.this.slotsChanged(this); - StonecutterMenu.this.slotUpdateListener.run(); ++ public final Container container; // Paper - Add missing InventoryHolders - move down ++ private final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down ++ // CraftBukkit start ++ private org.bukkit.craftbukkit.inventory.view.@org.jspecify.annotations.Nullable CraftStonecutterView view = null; ++ private final org.bukkit.entity.Player player; ++ + @Override + public org.bukkit.craftbukkit.inventory.view.CraftStonecutterView getBukkitView() { + if (this.view != null) { @@ -52,7 +41,7 @@ index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7 public StonecutterMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -56,6 +60,23 @@ public class StonecutterMenu extends AbstractContainerMenu { +@@ -51,6 +_,23 @@ super(MenuType.STONECUTTER, containerId); this.access = access; this.level = inventory.player.level(); @@ -75,8 +64,8 @@ index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7 + // Paper end this.inputSlot = this.addSlot(new Slot(this.container, 0, 20, 33)); this.resultSlot = this.addSlot(new Slot(this.resultContainer, 1, 143, 33) { - { -@@ -92,6 +113,7 @@ public class StonecutterMenu extends AbstractContainerMenu { + @Override +@@ -83,6 +_,7 @@ }); this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlot(this.selectedRecipeIndex); @@ -84,7 +73,7 @@ index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7 } public int getSelectedRecipeIndex() { -@@ -112,6 +134,7 @@ public class StonecutterMenu extends AbstractContainerMenu { +@@ -103,6 +_,7 @@ @Override public boolean stillValid(final Player player) { @@ -92,44 +81,44 @@ index c1b7cae306e738f39352b18c66359f10ef3ed09b..e607855b32501eb5fb6a482e3be54eb7 return stillValid(this.access, player, Blocks.STONECUTTER); } -@@ -121,8 +144,34 @@ public class StonecutterMenu extends AbstractContainerMenu { - return false; - } else { - if (this.isValidRecipeIndex(buttonId)) { -- this.selectedRecipeIndex.set(buttonId); -- this.setupResultSlot(buttonId); -+ // Paper start - Add PlayerStonecutterRecipeSelectEvent -+ int recipeIndex = buttonId; -+ this.selectedRecipeIndex.set(recipeIndex); -+ this.selectedRecipeIndex.checkAndClearUpdateFlag(); // mark as changed -+ paperEventBlock: if (this.isValidRecipeIndex(buttonId)) { -+ final Optional> recipe = this.recipesForInput.entries().get(buttonId).recipe().recipe(); -+ if (recipe.isEmpty()) break paperEventBlock; // The recipe selected does not have an actual server recipe (presumably its the empty one). Cannot call the event, just break. +@@ -113,8 +_,34 @@ + } + + if (this.isValidRecipeIndex(buttonId)) { +- this.selectedRecipeIndex.set(buttonId); +- this.setupResultSlot(buttonId); ++ // Paper start - Add PlayerStonecutterRecipeSelectEvent ++ int recipeIndex = buttonId; ++ this.selectedRecipeIndex.set(recipeIndex); ++ this.selectedRecipeIndex.checkAndClearUpdateFlag(); // mark as changed ++ paperEventBlock: if (this.isValidRecipeIndex(buttonId)) { ++ final Optional> recipe = this.recipesForInput.entries().get(buttonId).recipe().recipe(); ++ if (recipe.isEmpty()) break paperEventBlock; // The recipe selected does not have an actual server recipe (presumably its the empty one). Cannot call the event, just break. + -+ io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) recipe.get().toBukkitRecipe()); -+ if (!event.callEvent()) { -+ player.containerMenu.sendAllDataToRemote(); -+ return false; -+ } ++ io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) recipe.get().toBukkitRecipe()); ++ if (!event.callEvent()) { ++ player.containerMenu.sendAllDataToRemote(); ++ return false; ++ } + -+ net.minecraft.resources.Identifier key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); -+ if (!recipe.get().id().identifier().equals(key)) { // If the recipe did NOT stay the same -+ for (int newRecipeIndex = 0; newRecipeIndex < this.recipesForInput.entries().size(); newRecipeIndex++) { -+ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().identifier().equals(key)).isPresent()) { -+ recipeIndex = newRecipeIndex; -+ break; -+ } ++ net.minecraft.resources.Identifier key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); ++ if (!recipe.get().id().identifier().equals(key)) { // If the recipe did NOT stay the same ++ for (int newRecipeIndex = 0; newRecipeIndex < this.recipesForInput.entries().size(); newRecipeIndex++) { ++ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().identifier().equals(key)).isPresent()) { ++ recipeIndex = newRecipeIndex; ++ break; + } + } + } -+ player.containerMenu.sendAllDataToRemote(); -+ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it -+ this.setupResultSlot(recipeIndex); -+ // Paper end - Add PlayerStonecutterRecipeSelectEvent - } ++ } ++ player.containerMenu.sendAllDataToRemote(); ++ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it ++ this.setupResultSlot(recipeIndex); ++ // Paper end - Add PlayerStonecutterRecipeSelectEvent + } - return true; -@@ -140,6 +189,7 @@ public class StonecutterMenu extends AbstractContainerMenu { + return true; +@@ -131,6 +_,7 @@ this.input = input.copy(); this.setupRecipeList(input); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch new file mode 100644 index 000000000000..4ab4beab795e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/component/LodestoneTracker.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/component/LodestoneTracker.java ++++ b/net/minecraft/world/item/component/LodestoneTracker.java +@@ -30,7 +_,7 @@ + } + + BlockPos blockPos = this.target.get().pos(); +- return level.isInWorldBounds(blockPos) && level.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos) ++ return level.isInWorldBounds(blockPos) && (!level.hasChunkAt(blockPos) || level.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) // Paper - Prevent compass from loading chunks + ? this + : new LodestoneTracker(Optional.empty(), true); + } else { diff --git a/paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch similarity index 60% rename from paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch index bf27d3312bbc..cb5804796867 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/component/ResolvableProfile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/ResolvableProfile.java.patch @@ -1,23 +1,15 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/component/ResolvableProfile.java b/net/minecraft/world/item/component/ResolvableProfile.java -index ee40ccbdc45678d94fdbb1d397dc5f29c32c1e7b..8b554b35c5670daf594d91cb276f93735242eb21 100644 --- a/net/minecraft/world/item/component/ResolvableProfile.java +++ b/net/minecraft/world/item/component/ResolvableProfile.java -@@ -46,7 +46,7 @@ public abstract sealed class ResolvableProfile implements TooltipProvider permit +@@ -46,7 +_,7 @@ private static ResolvableProfile create(final Either value, final PlayerSkin.Patch patch) { return value.map( full -> new ResolvableProfile.Static(Either.left(full), patch), -- partial -> (ResolvableProfile)(partial.properties.isEmpty() && partial.id.isPresent() != partial.name.isPresent() -+ partial -> (ResolvableProfile)(partial.properties.isEmpty() && partial.id.isPresent() != partial.name.isPresent() // Paper - diff on change - heuristic for dynamic vs static resolvable profile - used in CraftPlayerProfile#buildResolvable +- partial -> partial.properties.isEmpty() && partial.id.isPresent() != partial.name.isPresent() ++ partial -> partial.properties.isEmpty() && partial.id.isPresent() != partial.name.isPresent() // Paper - diff on change - heuristic for dynamic vs static resolvable profile - used in CraftPlayerProfile#buildResolvable ? partial.name .map(s -> new ResolvableProfile.Dynamic(Either.left(s), patch)) .orElseGet(() -> new ResolvableProfile.Dynamic(Either.right(partial.id.get()), patch)) -@@ -140,9 +140,10 @@ public abstract sealed class ResolvableProfile implements TooltipProvider permit +@@ -140,9 +_,10 @@ i -> i.group( ExtraCodecs.PLAYER_NAME.optionalFieldOf("name").forGetter(ResolvableProfile.Partial::name), UUIDUtil.CODEC.optionalFieldOf("id").forGetter(ResolvableProfile.Partial::id), diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch new file mode 100644 index 000000000000..b6adac3ac829 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +@@ -46,7 +_,7 @@ + } + + @Override +- public boolean apply(final Level level, final ItemStack stack, final LivingEntity user) { ++ public boolean apply(final Level level, final ItemStack stack, final LivingEntity user, final org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) { // CraftBukkit + if (user.getRandom().nextFloat() >= this.probability) { + return false; + } +@@ -54,7 +_,7 @@ + boolean anyApplied = false; + + for (MobEffectInstance effect : this.effects) { +- if (user.addEffect(new MobEffectInstance(effect))) { ++ if (user.addEffect(new MobEffectInstance(effect), cause)) { // CraftBukkit + anyApplied = true; + } + } From 5edbf61fa42e0bae6cab744a841b0e71d4493400 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 12 May 2026 22:10:03 +0100 Subject: [PATCH 10/16] 110 --- .../rcon/thread/QueryThreadGs4.java.patch | 135 ---- .../entity/BrushableBlockEntity.java.patch | 88 -- .../minecraft/network/Connection.java.patch | 141 ++-- .../network/FriendlyByteBuf.java.patch | 20 +- .../network/PacketProcessor.java.patch | 46 +- .../rcon/thread/QueryThreadGs4.java.patch | 127 +++ .../server/rcon/thread/RconClient.java.patch | 18 +- .../minecraft/world/entity/Entity.java.patch | 466 ++++++----- .../world/entity/ExperienceOrb.java.patch | 43 +- .../entity/InsideBlockEffectType.java.patch | 14 +- .../world/entity/LivingEntity.java.patch | 764 +++++++++--------- .../net/minecraft/world/entity/Mob.java.patch | 129 ++- .../world/entity/TamableAnimal.java.patch | 44 +- .../entity/ai/village/VillageSiege.java.patch | 16 +- .../world/entity/ambient/Bat.java.patch | 28 +- .../world/entity/animal/wolf/Wolf.java.patch | 32 +- .../entity/BeehiveBlockEntity.java.patch | 134 ++- .../entity/BrushableBlockEntity.java.patch | 80 ++ .../entity/CommandBlockEntity.java.patch | 19 +- .../block/entity/HopperBlockEntity.java.patch | 140 ++-- .../entity/LecternBlockEntity.java.patch | 28 +- .../block/entity/SignBlockEntity.java.patch | 26 +- 22 files changed, 1197 insertions(+), 1341 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/network/Connection.java.patch (70%) rename paper-server/patches/{rejected => sources}/net/minecraft/network/FriendlyByteBuf.java.patch (72%) rename paper-server/patches/{rejected => sources}/net/minecraft/network/PacketProcessor.java.patch (64%) create mode 100644 paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/rcon/thread/RconClient.java.patch (68%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/Entity.java.patch (85%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ExperienceOrb.java.patch (91%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/InsideBlockEffectType.java.patch (72%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/LivingEntity.java.patch (75%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/Mob.java.patch (81%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/TamableAnimal.java.patch (61%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/village/VillageSiege.java.patch (54%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ambient/Bat.java.patch (65%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/wolf/Wolf.java.patch (76%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch (63%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch (66%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch (70%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch (82%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch (90%) diff --git a/paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch deleted file mode 100644 index c0e2489359fb..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/net/minecraft/server/rcon/thread/QueryThreadGs4.java -index 8ca6abbd9796de29a9962183cd2cb496d0f43d8c..71d3306bd8b08510471ed9168c27ebf3faee8cde 100644 ---- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java -+++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -105,13 +105,32 @@ public class QueryThreadGs4 extends GenericThread { - NetworkDataOutputStream dos = new NetworkDataOutputStream(1460); - dos.write(0); - dos.writeBytes(this.getIdentBytes(packet.getSocketAddress())); -- dos.writeString(this.serverName); -+ // Paper start -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType queryType = -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType.BASIC; -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse queryResponse = com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.builder() -+ .motd(this.serverName) -+ .map(this.worldName) -+ .currentPlayers(this.serverInterface.getPlayerCount()) -+ .maxPlayers(this.maxPlayers) -+ .port(this.serverPort) -+ .hostname(this.hostIp) -+ .gameVersion(this.serverInterface.getServerVersion()) -+ .serverVersion(org.bukkit.Bukkit.getServer().getName() + " on " + org.bukkit.Bukkit.getServer().getBukkitVersion()) -+ .build(); -+ com.destroystokyo.paper.event.server.GS4QueryEvent queryEvent = -+ new com.destroystokyo.paper.event.server.GS4QueryEvent(queryType, packet.getAddress(), queryResponse); -+ queryEvent.callEvent(); -+ queryResponse = queryEvent.getResponse(); -+ -+ dos.writeString(queryResponse.getMotd()); - dos.writeString("SMP"); -- dos.writeString(this.worldName); -- dos.writeString(Integer.toString(this.serverInterface.getPlayerCount())); -- dos.writeString(Integer.toString(this.maxPlayers)); -- dos.writeShort((short)this.serverPort); -- dos.writeString(this.hostIp); -+ dos.writeString(queryResponse.getMap()); -+ dos.writeString(Integer.toString(queryResponse.getCurrentPlayers())); -+ dos.writeString(Integer.toString(queryResponse.getMaxPlayers())); -+ dos.writeShort((short) queryResponse.getPort()); -+ dos.writeString(queryResponse.getHostname()); -+ // Paper end - this.sendTo(dos.toByteArray(), packet); - LOGGER.debug("Status [{}]", socketAddress); - } -@@ -146,31 +165,76 @@ public class QueryThreadGs4 extends GenericThread { - this.rulesResponse.writeString("splitnum"); - this.rulesResponse.write(128); - this.rulesResponse.write(0); -+ // Paper start -+ // Pack plugins -+ java.util.List plugins = java.util.Collections.emptyList(); -+ org.bukkit.plugin.Plugin[] bukkitPlugins; -+ if (((net.minecraft.server.dedicated.DedicatedServer) this.serverInterface).server.getQueryPlugins() && (bukkitPlugins = org.bukkit.Bukkit.getPluginManager().getPlugins()).length > 0) { -+ plugins = java.util.stream.Stream.of(bukkitPlugins) -+ .map(plugin -> com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.PluginInformation.of(plugin.getName(), plugin.getDescription().getVersion())) -+ .collect(java.util.stream.Collectors.toList()); -+ } -+ -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse queryResponse = com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.builder() -+ .motd(this.serverName) -+ .map(this.worldName) -+ .currentPlayers(this.serverInterface.getPlayerCount()) -+ .maxPlayers(this.maxPlayers) -+ .port(this.serverPort) -+ .hostname(this.hostIp) -+ .plugins(plugins) -+ .players(this.serverInterface.getPlayerNames()) -+ .gameVersion(this.serverInterface.getServerVersion()) -+ .serverVersion(org.bukkit.Bukkit.getServer().getName() + " on " + org.bukkit.Bukkit.getServer().getBukkitVersion()) -+ .build(); -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType queryType = -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType.FULL; -+ com.destroystokyo.paper.event.server.GS4QueryEvent queryEvent = -+ new com.destroystokyo.paper.event.server.GS4QueryEvent(queryType, packet.getAddress(), queryResponse); -+ queryEvent.callEvent(); -+ queryResponse = queryEvent.getResponse(); - this.rulesResponse.writeString("hostname"); -- this.rulesResponse.writeString(this.serverName); -+ this.rulesResponse.writeString(queryResponse.getMotd()); - this.rulesResponse.writeString("gametype"); - this.rulesResponse.writeString("SMP"); - this.rulesResponse.writeString("game_id"); - this.rulesResponse.writeString("MINECRAFT"); - this.rulesResponse.writeString("version"); -- this.rulesResponse.writeString(this.serverInterface.getServerVersion()); -+ this.rulesResponse.writeString(queryResponse.getGameVersion()); - this.rulesResponse.writeString("plugins"); -- this.rulesResponse.writeString(this.serverInterface.getPluginNames()); -+ java.lang.StringBuilder pluginsString = new java.lang.StringBuilder(); -+ pluginsString.append(queryResponse.getServerVersion()); -+ if (!queryResponse.getPlugins().isEmpty()) { -+ pluginsString.append(": "); -+ java.util.Iterator iter = queryResponse.getPlugins().iterator(); -+ while (iter.hasNext()) { -+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.PluginInformation info = iter.next(); -+ pluginsString.append(info.getName()); -+ if (info.getVersion() != null) { -+ pluginsString.append(' ').append(info.getVersion().replace(";", ",")); -+ } -+ if (iter.hasNext()) { -+ pluginsString.append(';').append(' '); -+ } -+ } -+ } -+ this.rulesResponse.writeString(pluginsString.toString()); - this.rulesResponse.writeString("map"); -- this.rulesResponse.writeString(this.worldName); -+ this.rulesResponse.writeString(queryResponse.getMap()); - this.rulesResponse.writeString("numplayers"); -- this.rulesResponse.writeString(this.serverInterface.getPlayerCount() + ""); -+ this.rulesResponse.writeString(Integer.toString(queryResponse.getCurrentPlayers())); - this.rulesResponse.writeString("maxplayers"); -- this.rulesResponse.writeString(this.maxPlayers + ""); -+ this.rulesResponse.writeString(Integer.toString(queryResponse.getMaxPlayers())); - this.rulesResponse.writeString("hostport"); -- this.rulesResponse.writeString(this.serverPort + ""); -+ this.rulesResponse.writeString(Integer.toString(queryResponse.getPort())); - this.rulesResponse.writeString("hostip"); -- this.rulesResponse.writeString(this.hostIp); -+ this.rulesResponse.writeString(queryResponse.getHostname()); - this.rulesResponse.write(0); - this.rulesResponse.write(1); - this.rulesResponse.writeString("player_"); - this.rulesResponse.write(0); -- String[] players = this.serverInterface.getPlayerNames(); -+ String[] players = queryResponse.getPlayers().toArray(String[]::new); -+ // Paper end - - for (String player : players) { - this.rulesResponse.writeString(player); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch deleted file mode 100644 index 171cf02fedc0..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -index d84d7d687f48b899cdaab47912743d66106fafaa..cddfd5b5b1d3f991682a1f96b935636ca27c219d 100644 ---- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -+++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -67,9 +67,26 @@ public class BrushableBlockEntity extends BlockEntity { - return false; - } else { - this.coolDownEndsAtTick = gameTime + 10L; -+ // Paper start - EntityChangeBlockEvent -+ // The vanilla logic here is *so* backwards, we'd be moving basically *all* following calls down. -+ // Instead, compute vanilla ourselves up here and just replace the below usages with our computed values for a free diff-on-change. -+ final int currentCompletionStage = this.getCompletionState(); -+ final boolean enoughBrushesToBreak = ++this.brushCount >= REQUIRED_BRUSHES_TO_BREAK; -+ final int nextCompletionStage = this.getCompletionState(); -+ final boolean differentCompletionStages = currentCompletionStage != nextCompletionStage; -+ final BlockState nextBrokenBlockState = this.getBlockState().setValue(BlockStateProperties.DUSTED, nextCompletionStage); -+ if (enoughBrushesToBreak || differentCompletionStages) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( -+ user, this.worldPosition, enoughBrushesToBreak ? this.computeTurnsTo().defaultBlockState() : nextBrokenBlockState -+ )) { -+ this.brushCount--; -+ return false; -+ } -+ } -+ // Paper end - EntityChangeBlockEvent - this.unpackLootTable(level, user, brush); -- int previousCompletionState = this.getCompletionState(); -- if (++this.brushCount >= 10) { -+ int previousCompletionState = currentCompletionStage; // Paper - EntityChangeBlockEvent - use precomputed - diff on change -+ if (enoughBrushesToBreak) { // Paper - EntityChangeBlockEvent - use precomputed - diff on change - this.brushingCompleted(level, user, brush); - return true; - } else { -@@ -77,7 +94,7 @@ public class BrushableBlockEntity extends BlockEntity { - int completionState = this.getCompletionState(); - if (previousCompletionState != completionState) { - BlockState previousState = this.getBlockState(); -- BlockState state = previousState.setValue(BlockStateProperties.DUSTED, completionState); -+ BlockState state = nextBrokenBlockState; // Paper - EntityChangeBlockEvent - use precomputed - diff on change - level.setBlock(this.getBlockPos(), state, Block.UPDATE_ALL); - } - -@@ -118,6 +135,12 @@ public class BrushableBlockEntity extends BlockEntity { - this.dropContent(level, user, brush); - BlockState blockState = this.getBlockState(); - level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); -+ // Paper start - EntityChangeEvent - extract result block logic -+ this.brushingCompleteUpdateBlock(this.computeTurnsTo()); -+ } -+ -+ private Block computeTurnsTo() { -+ // Paper end - EntityChangeEvent - extract result block logic - Block turnsInto; - if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { - turnsInto = brushableBlock.getTurnsInto(); -@@ -125,6 +148,12 @@ public class BrushableBlockEntity extends BlockEntity { - turnsInto = Blocks.AIR; - } - -+ // Paper start - EntityChangeEvent - extract result block logic -+ return turnsInto; -+ } -+ -+ public void brushingCompleteUpdateBlock(final Block turnsInto) { -+ // Paper end - EntityChangeEvent - extract result block logic - level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); - } - -@@ -141,7 +170,12 @@ public class BrushableBlockEntity extends BlockEntity { - double zo = dropPos.getZ() + 0.5 * centerRange + halfSize; - ItemEntity entity = new ItemEntity(level, xo, yo, zo, this.item.split(level.getRandom().nextInt(21) + 10)); - entity.setDeltaMovement(Vec3.ZERO); -- level.addFreshEntity(entity); -+ // CraftBukkit start -+ if (user instanceof final ServerPlayer serverPlayer) { -+ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), serverPlayer, java.util.List.of(entity)); -+ } -+ // CraftBukkit end - this.item = ItemStack.EMPTY; - } - } diff --git a/paper-server/patches/rejected/net/minecraft/network/Connection.java.patch b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch similarity index 70% rename from paper-server/patches/rejected/net/minecraft/network/Connection.java.patch rename to paper-server/patches/sources/net/minecraft/network/Connection.java.patch index fc296bed14cb..dfb10ac330e0 100644 --- a/paper-server/patches/rejected/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d539fe0f0 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -68,6 +68,11 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -67,6 +_,11 @@ private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); public Channel channel; public SocketAddress address; @@ -20,7 +12,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d private volatile @Nullable PacketListener disconnectListener; private volatile @Nullable PacketListener packetListener; private @Nullable DisconnectionDetails disconnectionDetails; -@@ -81,6 +86,44 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -80,6 +_,44 @@ private boolean handlingFault; private volatile @Nullable DisconnectionDetails delayedDisconnect; private @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; @@ -65,7 +57,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d public Connection(final PacketFlow receiving) { this.receiving = receiving; -@@ -91,6 +134,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -90,6 +_,7 @@ super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -73,7 +65,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -102,15 +146,32 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -101,15 +_,32 @@ } @Override @@ -107,7 +99,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d this.disconnect(Component.translatable("disconnect.timeout")); } else { Component reason = Component.translatable("disconnect.genericReason", "Internal Exception: " + cause); -@@ -122,9 +183,11 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -121,9 +_,11 @@ details = new DisconnectionDetails(reason); } @@ -117,10 +109,10 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d - if (this.getSending() == PacketFlow.CLIENTBOUND) { + boolean doesDisconnectExist = this.packetListener.protocol() != ConnectionProtocol.STATUS && this.packetListener.protocol() != ConnectionProtocol.HANDSHAKING; // Paper + if (this.getSending() == PacketFlow.CLIENTBOUND && doesDisconnectExist) { // Paper - Packet packet = (Packet)(this.sendLoginDisconnect + Packet packet = this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(reason) - : new ClientboundDisconnectPacket(reason)); -@@ -141,6 +204,7 @@ public class Connection extends SimpleChannelInboundHandler> { + : new ClientboundDisconnectPacket(reason); +@@ -140,6 +_,7 @@ } } } @@ -128,68 +120,69 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d } @Override -@@ -150,10 +214,60 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -149,11 +_,60 @@ if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); - } else { -+ // Paper start - packet limiter -+ if (this.stopReadingPackets) { -+ return; -+ } -+ if (this.allPacketCounts != null || -+ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass())) { -+ long time = System.nanoTime(); -+ synchronized (PACKET_LIMIT_LOCK) { -+ if (this.allPacketCounts != null) { -+ this.allPacketCounts.updateAndAdd(1, time); -+ if (this.allPacketCounts.getRate() >= io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.maxPacketRate()) { -+ this.killForPacketSpam(); -+ return; -+ } + } +- ++ // Paper start - packet limiter ++ if (this.stopReadingPackets) { ++ return; ++ } ++ if (this.allPacketCounts != null || ++ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass())) { ++ long time = System.nanoTime(); ++ synchronized (PACKET_LIMIT_LOCK) { ++ if (this.allPacketCounts != null) { ++ this.allPacketCounts.updateAndAdd(1, time); ++ if (this.allPacketCounts.getRate() >= io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.maxPacketRate()) { ++ this.killForPacketSpam(); ++ return; + } ++ } + -+ for (Class check = packet.getClass(); check != Object.class; check = check.getSuperclass()) { -+ io.papermc.paper.configuration.GlobalConfiguration.PacketLimiter.PacketLimit packetSpecificLimit = -+ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.get(check); -+ if (packetSpecificLimit == null || !packetSpecificLimit.isEnabled()) { -+ continue; -+ } -+ io.papermc.paper.util.IntervalledCounter counter = this.packetSpecificLimits.computeIfAbsent((Class)check, (clazz) -> { -+ return new io.papermc.paper.util.IntervalledCounter((long)(packetSpecificLimit.interval() * 1.0e9)); -+ }); -+ counter.updateAndAdd(1, time); -+ if (counter.getRate() >= packetSpecificLimit.maxPacketRate()) { -+ switch (packetSpecificLimit.action()) { -+ case DROP: -+ return; -+ case KICK: -+ String deobfedPacketName = check.getName(); ++ for (Class check = packet.getClass(); check != Object.class; check = check.getSuperclass()) { ++ io.papermc.paper.configuration.GlobalConfiguration.PacketLimiter.PacketLimit packetSpecificLimit = ++ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.get(check); ++ if (packetSpecificLimit == null || !packetSpecificLimit.isEnabled()) { ++ continue; ++ } ++ io.papermc.paper.util.IntervalledCounter counter = this.packetSpecificLimits.computeIfAbsent((Class)check, (clazz) -> { ++ return new io.papermc.paper.util.IntervalledCounter((long)(packetSpecificLimit.interval() * 1.0e9)); ++ }); ++ counter.updateAndAdd(1, time); ++ if (counter.getRate() >= packetSpecificLimit.maxPacketRate()) { ++ switch (packetSpecificLimit.action()) { ++ case DROP: ++ return; ++ case KICK: ++ String deobfedPacketName = check.getName(); + -+ String playerName; -+ if (this.packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl impl) { -+ playerName = impl.getOwner().name(); -+ } else { -+ playerName = this.getLoggableAddress(net.minecraft.server.MinecraftServer.getServer().logIPs()); -+ } ++ String playerName; ++ if (this.packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl impl) { ++ playerName = impl.getOwner().name(); ++ } else { ++ playerName = this.getLoggableAddress(net.minecraft.server.MinecraftServer.getServer().logIPs()); ++ } + -+ Connection.LOGGER.warn("{} kicked for packet spamming: {}", playerName, deobfedPacketName.substring(deobfedPacketName.lastIndexOf(".") + 1)); -+ this.killForPacketSpam(); -+ return; -+ } ++ Connection.LOGGER.warn("{} kicked for packet spamming: {}", playerName, deobfedPacketName.substring(deobfedPacketName.lastIndexOf(".") + 1)); ++ this.killForPacketSpam(); ++ return; + } + } + } + } -+ // Paper end - packet limiter - if (packetListener.shouldHandleMessage(packet)) { - try { - genericsFtw(packet, packetListener); - } catch (RunningOnDifferentThreadException var5) { -+ } catch (io.papermc.paper.util.ServerStopRejectedExecutionException ignored) { // Paper - do not prematurely disconnect players on stop - } catch (RejectedExecutionException var6) { - this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); - } catch (ClassCastException var7) { -@@ -344,10 +458,30 @@ public class Connection extends SimpleChannelInboundHandler> { ++ } ++ // Paper end - packet limiter + if (packetListener.shouldHandleMessage(packet)) { + try { + genericsFtw(packet, packetListener); + } catch (RunningOnDifferentThreadException var5) { ++ } catch (io.papermc.paper.util.ServerStopRejectedExecutionException ignored) { // Paper - do not prematurely disconnect players on stop + } catch (RejectedExecutionException ignored) { + this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); + } catch (ClassCastException exception) { +@@ -343,10 +_,30 @@ } } @@ -220,7 +213,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -355,7 +489,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -354,7 +_,7 @@ } if (this.channel != null) { @@ -229,7 +222,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d } if (this.tickCount++ % 20 == 0) { -@@ -391,6 +525,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -390,6 +_,7 @@ } public void disconnect(final DisconnectionDetails details) { @@ -237,7 +230,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d if (this.channel == null) { this.delayedDisconnect = details; } -@@ -543,6 +678,14 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -534,6 +_,14 @@ } } @@ -252,7 +245,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d public void setupCompression(final int threshold, final boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder compressionDecoder) { -@@ -556,6 +699,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -547,6 +_,7 @@ } else { this.channel.pipeline().addAfter(HandlerNames.PREPENDER, HandlerNames.COMPRESS, new CompressionEncoder(threshold)); } @@ -260,7 +253,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d } else { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder) { this.channel.pipeline().remove(HandlerNames.DECOMPRESS); -@@ -564,6 +708,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -555,6 +_,7 @@ if (this.channel.pipeline().get(HandlerNames.COMPRESS) instanceof CompressionEncoder) { this.channel.pipeline().remove(HandlerNames.COMPRESS); } @@ -268,7 +261,7 @@ index db47458615e64f5db2f32cf9e9bcd55693a6318f..1511cbd2e6123a00d22694353ee4989d } } -@@ -581,6 +726,26 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -572,6 +_,26 @@ ); disconnectListener.onDisconnect(details); } diff --git a/paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch similarity index 72% rename from paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch rename to paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index 17d4ad7064ce..fe3cf91b56ef 100644 --- a/paper-server/patches/rejected/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/network/FriendlyByteBuf.java b/net/minecraft/network/FriendlyByteBuf.java -index 8048aaf25ef496470ba948787ae65d3251ebac9a..351e3b891121c42ceb10e2171e2565877aee519b 100644 --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -70,14 +70,20 @@ import org.jspecify.annotations.Nullable; +@@ -70,14 +_,20 @@ public class FriendlyByteBuf extends ByteBuf { private final ByteBuf source; @@ -29,7 +21,7 @@ index 8048aaf25ef496470ba948787ae65d3251ebac9a..351e3b891121c42ceb10e2171e256587 this.source = source; } -@@ -106,8 +112,13 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -106,8 +_,13 @@ } public void writeJsonWithCodec(final Codec codec, final T value) { @@ -44,12 +36,12 @@ index 8048aaf25ef496470ba948787ae65d3251ebac9a..351e3b891121c42ceb10e2171e256587 } public static IntFunction limitValue(final IntFunction original, final int limit) { -@@ -530,7 +541,7 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -530,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(output)); -- } catch (IOException var3) { -+ } catch (Exception var3) { // CraftBukkit - IOException -> Exception - throw new EncoderException(var3); +- } catch (IOException e) { ++ } catch (Exception e) { // CraftBukkit - IOException -> Exception + throw new EncoderException(e); } } diff --git a/paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch b/paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch similarity index 64% rename from paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch rename to paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch index f429ff4f9845..5b07c1540e5a 100644 --- a/paper-server/patches/rejected/net/minecraft/network/PacketProcessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/PacketProcessor.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java -index 82bd316d094e2c1a43938313fab2283035610ef3..197adf43de3618fbd4c72bb2a4736b1cd61fbee7 100644 --- a/net/minecraft/network/PacketProcessor.java +++ b/net/minecraft/network/PacketProcessor.java -@@ -19,15 +19,42 @@ public class PacketProcessor implements AutoCloseable { +@@ -19,16 +_,42 @@ this.runningThread = runningThread; } @@ -35,25 +27,27 @@ index 82bd316d094e2c1a43938313fab2283035610ef3..197adf43de3618fbd4c72bb2a4736b1c public void scheduleIfPossible(final T listener, final Packet packet) { if (this.closed) { - throw new RejectedExecutionException("Server already shutting down"); +- } +- +- this.packetsToBeHandled.add(new PacketProcessor.ListenerAndPacket<>(listener, packet)); + throw new io.papermc.paper.util.ServerStopRejectedExecutionException("Server already shutting down"); // Paper - do not prematurely disconnect players on stop - } else { -- this.packetsToBeHandled.add(new PacketProcessor.ListenerAndPacket<>(listener, packet)); -+ // Paper start - improve tick loop -+ // wake up main thread inbetween ticks to process packets -+ final boolean isEmpty = this.packetsToBeHandled.isEmpty(); -+ final ListenerAndPacket toAdd = new PacketProcessor.ListenerAndPacket<>(listener, packet); -+ this.packetsToBeHandled.add(toAdd); -+ if (isEmpty || this.packetsToBeHandled.peek() == toAdd) { -+ // only unpark if we are the first packet OR are at the head of the queue -+ // we unpark if we are at the head in case the main thread emptied the queue -+ // immediately before we added but after checking isEmpty -+ java.util.concurrent.locks.LockSupport.unpark(this.runningThread); -+ } -+ // Paper end - improve tick loop - } ++ } ++ // Paper start - improve tick loop ++ // wake up main thread inbetween ticks to process packets ++ final boolean isEmpty = this.packetsToBeHandled.isEmpty(); ++ final ListenerAndPacket toAdd = new PacketProcessor.ListenerAndPacket<>(listener, packet); ++ this.packetsToBeHandled.add(toAdd); ++ if (isEmpty || this.packetsToBeHandled.peek() == toAdd) { ++ // only unpark if we are the first packet OR are at the head of the queue ++ // we unpark if we are at the head in case the main thread emptied the queue ++ // immediately before we added but after checking isEmpty ++ java.util.concurrent.locks.LockSupport.unpark(this.runningThread); ++ } ++ // Paper end - improve tick loop } -@@ -44,8 +71,28 @@ public class PacketProcessor implements AutoCloseable { + public void processQueuedPackets() { +@@ -44,8 +_,28 @@ this.closed = true; } @@ -82,7 +76,7 @@ index 82bd316d094e2c1a43938313fab2283035610ef3..197adf43de3618fbd4c72bb2a4736b1c if (this.listener.shouldHandleMessage(this.packet)) { try { this.packet.handle(this.listener); -@@ -59,6 +106,12 @@ public class PacketProcessor implements AutoCloseable { +@@ -59,6 +_,12 @@ } else { PacketProcessor.LOGGER.debug("Ignoring packet due to disconnection: {}", this.packet); } diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch new file mode 100644 index 000000000000..97be1ffc6ade --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch @@ -0,0 +1,127 @@ +--- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java ++++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java +@@ -105,13 +_,32 @@ + NetworkDataOutputStream dos = new NetworkDataOutputStream(1460); + dos.write(0); + dos.writeBytes(this.getIdentBytes(packet.getSocketAddress())); +- dos.writeString(this.serverName); ++ // Paper start ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType queryType = ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType.BASIC; ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse queryResponse = com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.builder() ++ .motd(this.serverName) ++ .map(this.worldName) ++ .currentPlayers(this.serverInterface.getPlayerCount()) ++ .maxPlayers(this.maxPlayers) ++ .port(this.serverPort) ++ .hostname(this.hostIp) ++ .gameVersion(this.serverInterface.getServerVersion()) ++ .serverVersion(org.bukkit.Bukkit.getServer().getName() + " on " + org.bukkit.Bukkit.getServer().getBukkitVersion()) ++ .build(); ++ com.destroystokyo.paper.event.server.GS4QueryEvent queryEvent = ++ new com.destroystokyo.paper.event.server.GS4QueryEvent(queryType, packet.getAddress(), queryResponse); ++ queryEvent.callEvent(); ++ queryResponse = queryEvent.getResponse(); ++ ++ dos.writeString(queryResponse.getMotd()); + dos.writeString("SMP"); +- dos.writeString(this.worldName); +- dos.writeString(Integer.toString(this.serverInterface.getPlayerCount())); +- dos.writeString(Integer.toString(this.maxPlayers)); +- dos.writeShort((short)this.serverPort); +- dos.writeString(this.hostIp); ++ dos.writeString(queryResponse.getMap()); ++ dos.writeString(Integer.toString(queryResponse.getCurrentPlayers())); ++ dos.writeString(Integer.toString(queryResponse.getMaxPlayers())); ++ dos.writeShort((short) queryResponse.getPort()); ++ dos.writeString(queryResponse.getHostname()); ++ // Paper end + this.sendTo(dos.toByteArray(), packet); + LOGGER.debug("Status [{}]", socketAddress); + } +@@ -147,31 +_,76 @@ + this.rulesResponse.writeString("splitnum"); + this.rulesResponse.write(128); + this.rulesResponse.write(0); ++ // Paper start ++ // Pack plugins ++ java.util.List plugins = java.util.Collections.emptyList(); ++ org.bukkit.plugin.Plugin[] bukkitPlugins; ++ if (((net.minecraft.server.dedicated.DedicatedServer) this.serverInterface).server.getQueryPlugins() && (bukkitPlugins = org.bukkit.Bukkit.getPluginManager().getPlugins()).length > 0) { ++ plugins = java.util.stream.Stream.of(bukkitPlugins) ++ .map(plugin -> com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.PluginInformation.of(plugin.getName(), plugin.getDescription().getVersion())) ++ .collect(java.util.stream.Collectors.toList()); ++ } ++ ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse queryResponse = com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.builder() ++ .motd(this.serverName) ++ .map(this.worldName) ++ .currentPlayers(this.serverInterface.getPlayerCount()) ++ .maxPlayers(this.maxPlayers) ++ .port(this.serverPort) ++ .hostname(this.hostIp) ++ .plugins(plugins) ++ .players(this.serverInterface.getPlayerNames()) ++ .gameVersion(this.serverInterface.getServerVersion()) ++ .serverVersion(org.bukkit.Bukkit.getServer().getName() + " on " + org.bukkit.Bukkit.getServer().getBukkitVersion()) ++ .build(); ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType queryType = ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType.FULL; ++ com.destroystokyo.paper.event.server.GS4QueryEvent queryEvent = ++ new com.destroystokyo.paper.event.server.GS4QueryEvent(queryType, packet.getAddress(), queryResponse); ++ queryEvent.callEvent(); ++ queryResponse = queryEvent.getResponse(); + this.rulesResponse.writeString("hostname"); +- this.rulesResponse.writeString(this.serverName); ++ this.rulesResponse.writeString(queryResponse.getMotd()); + this.rulesResponse.writeString("gametype"); + this.rulesResponse.writeString("SMP"); + this.rulesResponse.writeString("game_id"); + this.rulesResponse.writeString("MINECRAFT"); + this.rulesResponse.writeString("version"); +- this.rulesResponse.writeString(this.serverInterface.getServerVersion()); ++ this.rulesResponse.writeString(queryResponse.getGameVersion()); + this.rulesResponse.writeString("plugins"); +- this.rulesResponse.writeString(this.serverInterface.getPluginNames()); ++ java.lang.StringBuilder pluginsString = new java.lang.StringBuilder(); ++ pluginsString.append(queryResponse.getServerVersion()); ++ if (!queryResponse.getPlugins().isEmpty()) { ++ pluginsString.append(": "); ++ java.util.Iterator iter = queryResponse.getPlugins().iterator(); ++ while (iter.hasNext()) { ++ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryResponse.PluginInformation info = iter.next(); ++ pluginsString.append(info.getName()); ++ if (info.getVersion() != null) { ++ pluginsString.append(' ').append(info.getVersion().replace(";", ",")); ++ } ++ if (iter.hasNext()) { ++ pluginsString.append(';').append(' '); ++ } ++ } ++ } ++ this.rulesResponse.writeString(pluginsString.toString()); + this.rulesResponse.writeString("map"); +- this.rulesResponse.writeString(this.worldName); ++ this.rulesResponse.writeString(queryResponse.getMap()); + this.rulesResponse.writeString("numplayers"); +- this.rulesResponse.writeString(this.serverInterface.getPlayerCount() + ""); ++ this.rulesResponse.writeString(Integer.toString(queryResponse.getCurrentPlayers())); + this.rulesResponse.writeString("maxplayers"); +- this.rulesResponse.writeString(this.maxPlayers + ""); ++ this.rulesResponse.writeString(Integer.toString(queryResponse.getMaxPlayers())); + this.rulesResponse.writeString("hostport"); +- this.rulesResponse.writeString(this.serverPort + ""); ++ this.rulesResponse.writeString(Integer.toString(queryResponse.getPort())); + this.rulesResponse.writeString("hostip"); +- this.rulesResponse.writeString(this.hostIp); ++ this.rulesResponse.writeString(queryResponse.getHostname()); + this.rulesResponse.write(0); + this.rulesResponse.write(1); + this.rulesResponse.writeString("player_"); + this.rulesResponse.write(0); +- String[] players = this.serverInterface.getPlayerNames(); ++ String[] players = queryResponse.getPlayers().toArray(String[]::new); ++ // Paper end + + for (String player : players) { + this.rulesResponse.writeString(player); diff --git a/paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch similarity index 68% rename from paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch rename to paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch index adeaa7991eb6..71a3892df1cd 100644 --- a/paper-server/patches/rejected/net/minecraft/server/rcon/thread/RconClient.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/rcon/thread/RconClient.java b/net/minecraft/server/rcon/thread/RconClient.java -index ccc9714c9c5f0281f46052f8a5d13f37d238f2c2..4151d3a705539a881c304a906fef40d90ba001fe 100644 --- a/net/minecraft/server/rcon/thread/RconClient.java +++ b/net/minecraft/server/rcon/thread/RconClient.java -@@ -23,11 +23,14 @@ public class RconClient extends GenericThread { +@@ -23,11 +_,14 @@ private final Socket client; private final byte[] buf = new byte[1460]; private final String rconPassword; @@ -25,7 +17,7 @@ index ccc9714c9c5f0281f46052f8a5d13f37d238f2c2..4151d3a705539a881c304a906fef40d9 this.client = socket; try { -@@ -37,6 +40,7 @@ public class RconClient extends GenericThread { +@@ -37,6 +_,7 @@ } this.rconPassword = rconPassword; @@ -33,12 +25,12 @@ index ccc9714c9c5f0281f46052f8a5d13f37d238f2c2..4151d3a705539a881c304a906fef40d9 } @Override -@@ -67,7 +71,7 @@ public class RconClient extends GenericThread { +@@ -67,7 +_,7 @@ String command = PktUtils.stringFromByteArray(this.buf, offset, read); try { - this.sendCmdResponse(requestid, this.serverInterface.runCommand(command)); + this.sendCmdResponse(requestid, this.serverInterface.runCommand(this.rconConsoleSource, command)); // CraftBukkit - } catch (Exception var15) { - this.sendCmdResponse(requestid, "Error executing: " + command + " (" + var15.getMessage() + ")"); + } catch (Exception e) { + this.sendCmdResponse(requestid, "Error executing: " + command + " (" + e.getMessage() + ")"); } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch similarity index 85% rename from paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 6ff9c4c59def..f9fe2e48ec56 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8354b6889 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -168,6 +168,105 @@ public abstract class Entity +@@ -168,6 +_,105 @@ SlotProvider, DebugValueSource, TypedInstance> { @@ -114,7 +106,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 private static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -243,7 +342,7 @@ public abstract class Entity +@@ -243,7 +_,7 @@ public double yOld; public double zOld; public boolean noPhysics; @@ -123,7 +115,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 public int tickCount; private int remainingFireTicks; private final EntityFluidInteraction fluidInteraction = new EntityFluidInteraction(Set.of(FluidTags.WATER, FluidTags.LAVA)); -@@ -278,7 +377,7 @@ public abstract class Entity +@@ -278,7 +_,7 @@ protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -132,7 +124,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -292,6 +391,7 @@ public abstract class Entity +@@ -292,6 +_,7 @@ public boolean hasVisualFire; private Vec3 lastKnownSpeed = Vec3.ZERO; private @Nullable Vec3 lastKnownPosition; @@ -140,7 +132,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 private @Nullable BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; private final ArrayDeque movementThisTick = new ArrayDeque<>(100); -@@ -299,6 +399,40 @@ public abstract class Entity +@@ -299,6 +_,40 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -181,7 +173,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 public Entity(final EntityType type, final Level level) { this.type = type; -@@ -320,6 +454,7 @@ public abstract class Entity +@@ -320,6 +_,7 @@ this.entityData = entityDataBuilder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -189,7 +181,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean isColliding(final BlockPos pos, final BlockState state) { -@@ -332,6 +467,12 @@ public abstract class Entity +@@ -332,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -202,7 +194,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 public boolean isSpectator() { return false; } -@@ -389,7 +530,7 @@ public abstract class Entity +@@ -389,7 +_,7 @@ } public boolean addTag(final String tag) { @@ -211,7 +203,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean removeTag(final String tag) { -@@ -397,12 +538,18 @@ public abstract class Entity +@@ -397,12 +_,18 @@ } public void kill(final ServerLevel level) { @@ -232,7 +224,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } protected abstract void defineSynchedData(SynchedEntityData.Builder entityData); -@@ -411,6 +558,48 @@ public abstract class Entity +@@ -411,6 +_,48 @@ return this.entityData; } @@ -281,7 +273,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 @Override public boolean equals(final Object obj) { return obj instanceof Entity && ((Entity)obj).id == this.id; -@@ -422,7 +611,13 @@ public abstract class Entity +@@ -422,7 +_,13 @@ } public void remove(final Entity.RemovalReason reason) { @@ -296,7 +288,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public void onClientRemoval() { -@@ -432,6 +627,15 @@ public abstract class Entity +@@ -432,6 +_,15 @@ } public void setPose(final Pose pose) { @@ -312,7 +304,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.entityData.set(DATA_POSE, pose); } -@@ -454,7 +658,33 @@ public abstract class Entity +@@ -454,7 +_,33 @@ return Mth.lengthSquared(dx, dz) < Mth.square(distanceXZ) && Mth.square(dy) < Mth.square(distanceY); } @@ -347,7 +339,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -464,8 +694,8 @@ public abstract class Entity +@@ -464,8 +_,8 @@ } public void setPos(final double x, final double y, final double z) { @@ -358,7 +350,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } protected final AABB makeBoundingBox() { -@@ -499,12 +729,28 @@ public abstract class Entity +@@ -499,12 +_,28 @@ } public void tick() { @@ -387,7 +379,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.computeSpeed(); this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -515,7 +761,7 @@ public abstract class Entity +@@ -515,7 +_,7 @@ this.boardingCooldown--; } @@ -396,7 +388,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -543,6 +789,10 @@ public abstract class Entity +@@ -543,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -407,7 +399,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } this.checkBelowWorld(); -@@ -568,11 +818,16 @@ public abstract class Entity +@@ -568,11 +_,16 @@ } public void setSharedFlagOnFire(final boolean value) { @@ -426,7 +418,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.onBelowWorld(); } } -@@ -600,15 +855,41 @@ public abstract class Entity +@@ -600,15 +_,41 @@ } public void lavaIgnite() { @@ -470,7 +462,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -623,6 +904,20 @@ public abstract class Entity +@@ -623,6 +_,20 @@ } public final void igniteForSeconds(final float numberOfSeconds) { @@ -491,7 +483,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.igniteForTicks(Mth.floor(numberOfSeconds * 20.0F)); } -@@ -647,7 +942,7 @@ public abstract class Entity +@@ -647,7 +_,7 @@ } protected void onBelowWorld() { @@ -500,7 +492,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean isFree(final double xa, final double ya, final double za) { -@@ -703,7 +998,28 @@ public abstract class Entity +@@ -703,7 +_,28 @@ return this.onGround; } @@ -529,7 +521,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (this.noPhysics) { this.setPos(this.getX() + delta.x, this.getY() + delta.y, this.getZ() + delta.z); this.horizontalCollision = false; -@@ -786,6 +1102,27 @@ public abstract class Entity +@@ -786,6 +_,27 @@ onBlock.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -557,7 +549,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission emission = this.getMovementEmission(); -@@ -799,6 +1136,13 @@ public abstract class Entity +@@ -799,6 +_,13 @@ profiler.pop(); } } @@ -571,7 +563,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } private void applyMovementEmissionAndPlaySound( -@@ -994,7 +1338,7 @@ public abstract class Entity +@@ -994,7 +_,7 @@ } protected BlockPos getOnPos(final float offset) { @@ -580,25 +572,25 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 BlockPos getOnPos = this.mainSupportingBlockPos.get(); if (!(offset > 1.0E-5F)) { return getOnPos; -@@ -1263,7 +1607,7 @@ public abstract class Entity - if (insideBlock) { - try { - boolean isPrecise = movedFar || deflatedBoundingBoxAtTarget.intersects(blockIntersection); -- effectCollector.advanceStep(iteration); -+ effectCollector.advanceStep(iteration, blockIntersection); // Paper - track position inside effect was triggered on - state.entityInside(this.level(), blockIntersection, this, effectCollector, isPrecise); - this.onInsideBlock(state); - } catch (Throwable var20) { -@@ -1277,7 +1621,7 @@ public abstract class Entity - } - - if (insideFluid) { +@@ -1266,7 +_,7 @@ + if (insideBlock) { + try { + boolean isPrecise = movedFar || deflatedBoundingBoxAtTarget.intersects(blockIntersection); - effectCollector.advanceStep(iteration); + effectCollector.advanceStep(iteration, blockIntersection); // Paper - track position inside effect was triggered on - state.getFluidState().entityInside(this.level(), blockIntersection, this, effectCollector); - } + state.entityInside(this.level(), blockIntersection, this, effectCollector, isPrecise); + this.onInsideBlock(state); + } catch (Throwable t) { +@@ -1280,7 +_,7 @@ + } + + if (insideFluid) { +- effectCollector.advanceStep(iteration); ++ effectCollector.advanceStep(iteration, blockIntersection); // Paper - track position inside effect was triggered on + state.getFluidState().entityInside(this.level(), blockIntersection, this, effectCollector); + } -@@ -1690,6 +2034,7 @@ public abstract class Entity +@@ -1692,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -606,7 +598,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public void absSnapTo(final double x, final double y, final double z) { -@@ -1699,6 +2044,7 @@ public abstract class Entity +@@ -1701,6 +_,7 @@ this.yo = y; this.zo = cz; this.setPos(cx, y, cz); @@ -614,7 +606,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public void snapTo(final Vec3 pos) { -@@ -1723,6 +2069,7 @@ public abstract class Entity +@@ -1725,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -622,7 +614,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public final void setOldPosAndRot() { -@@ -1789,6 +2136,7 @@ public abstract class Entity +@@ -1791,6 +_,7 @@ public void push(final Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -630,7 +622,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 double xa = entity.getX() - this.getX(); double za = entity.getZ() - this.getZ(); double dd = Mth.absMax(xa, za); -@@ -1824,8 +2172,24 @@ public abstract class Entity +@@ -1826,8 +_,24 @@ } public void push(final double xa, final double ya, final double za) { @@ -656,7 +648,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.needsSync = true; } } -@@ -1932,9 +2296,21 @@ public abstract class Entity +@@ -1934,8 +_,20 @@ } public boolean isPushable() { @@ -668,17 +660,16 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // Paper end - Climbing should not bypass cramming gamerule return false; } - ++ + // CraftBukkit start - collidable API + public boolean canCollideWithBukkit(Entity entity) { + return this.isPushable(); + } + // CraftBukkit end -+ + public void awardKillScore(final Entity victim, final DamageSource killingBlow) { if (victim instanceof ServerPlayer) { - CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer)victim, this, killingBlow); -@@ -1960,15 +2336,23 @@ public abstract class Entity +@@ -1962,17 +_,25 @@ } public boolean saveAsPassenger(final ValueOutput output) { @@ -693,20 +684,22 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // CraftBukkit end + if (this.removalReason != null && !this.removalReason.shouldSave() && !forceSerialization) { // Paper - Raw entity serialization API return false; - } else { -- String id = this.getEncodeId(); -- if (id == null) { -+ String id = this.getEncodeId(includeNonSaveable); // Paper - Raw entity serialization API -+ if ((!this.persist && !forceSerialization) || id == null) { // CraftBukkit - persist flag // Paper - Raw entity serialization API - return false; - } else { - output.putString("id", id); -- this.saveWithoutId(output); -+ this.saveWithoutId(output, includeAll, includeNonSaveable, forceSerialization); // CraftBukkit - pass on includeAll // Paper - Raw entity serialization API - return true; - } } -@@ -1979,14 +2363,34 @@ public abstract class Entity + +- String id = this.getEncodeId(); +- if (id == null) { ++ String id = this.getEncodeId(includeNonSaveable); // Paper - Raw entity serialization API ++ if ((!this.persist && !forceSerialization) || id == null) { // CraftBukkit - persist flag // Paper - Raw entity serialization API + return false; + } + + output.putString("id", id); +- this.saveWithoutId(output); ++ this.saveWithoutId(output, includeAll, includeNonSaveable, forceSerialization); // CraftBukkit - pass on includeAll // Paper - Raw entity serialization API + return true; + } + +@@ -1981,14 +_,34 @@ } public void saveWithoutId(final ValueOutput output) { @@ -741,7 +734,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1994,7 +2398,29 @@ public abstract class Entity +@@ -1996,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -771,16 +764,17 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -2017,9 +2443,14 @@ public abstract class Entity +@@ -2019,9 +_,14 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } - if (this.hasVisualFire) { - output.putBoolean("HasVisualFire", this.hasVisualFire); +- } + // Paper start - improve visual fire API + if (this.visualFire.equals(net.kyori.adventure.util.TriState.TRUE)) { + output.putBoolean("HasVisualFire", true); - } ++ } + if (this.visualFire != net.kyori.adventure.util.TriState.NOT_SET) { + output.putString("Paper.FireOverride", visualFire.name()); + } @@ -788,7 +782,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -2029,13 +2460,13 @@ public abstract class Entity +@@ -2031,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -804,11 +798,10 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 passengersList.discardLast(); } } -@@ -2044,6 +2475,34 @@ public abstract class Entity +@@ -2046,6 +_,33 @@ output.discard("Passengers"); } } -+ + // CraftBukkit start - stores eventually existing bukkit values + if (this.bukkitEntity != null) { + this.bukkitEntity.storeBukkitValues(output); @@ -836,10 +829,10 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + output.putBoolean("Paper.FreezeLock", true); + } + // Paper end - } catch (Throwable var7) { - CrashReport report = CrashReport.forThrowable(var7, "Saving entity NBT"); + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Saving entity NBT"); CrashReportCategory category = report.addCategory("Entity being saved"); -@@ -2089,7 +2548,20 @@ public abstract class Entity +@@ -2093,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -861,11 +854,10 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2100,6 +2572,59 @@ public abstract class Entity +@@ -2104,6 +_,58 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } -+ + // CraftBukkit start + // Spigot start + if (this instanceof net.minecraft.world.entity.LivingEntity) { @@ -918,10 +910,10 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + } + freezeLocked = input.getBooleanOr("Paper.FreezeLock", false); + // Paper end - } catch (Throwable var7) { - CrashReport report = CrashReport.forThrowable(var7, "Loading entity NBT"); + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Loading entity NBT"); CrashReportCategory category = report.addCategory("Entity being loaded"); -@@ -2113,7 +2638,13 @@ public abstract class Entity +@@ -2117,7 +_,13 @@ } public final @Nullable String getEncodeId() { @@ -934,9 +926,9 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + if (!includeNonSaveable && !this.getType().canSerialize()) { + // Paper end - Raw entity serialization API return null; - } else { - ResourceKey> typeId = this.typeHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Unregistered entity")); -@@ -2123,6 +2654,12 @@ public abstract class Entity + } + +@@ -2127,6 +_,12 @@ protected abstract void readAdditionalSaveData(ValueInput input); @@ -949,7 +941,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 protected abstract void addAdditionalSaveData(ValueOutput output); public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemLike resource) { -@@ -2134,11 +2671,59 @@ public abstract class Entity +@@ -2138,12 +_,57 @@ } public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemStack itemStack, final Vec3 offset) { @@ -975,26 +967,26 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // Paper end - Restore vanilla drops behavior if (itemStack.isEmpty()) { return null; - } else { -+ // CraftBukkit start - Capture drops for death event -+ if (this instanceof net.minecraft.world.entity.LivingEntity && !this.forceDrops) { -+ // Paper start - Restore vanilla drops behavior -+ ((net.minecraft.world.entity.LivingEntity)this).drops.add(new net.minecraft.world.entity.Entity.DefaultDrop(itemStack, dropStack -> { -+ ItemEntity dropEntity = new ItemEntity(this.level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, dropStack); // stack is copied before consumer -+ dropEntity.setDefaultPickUpDelay(); -+ this.level.addFreshEntity(dropEntity); -+ if (delayedAddConsumer != null) delayedAddConsumer.accept(dropEntity); -+ })); -+ // Paper end - Restore vanilla drops behavior -+ return null; -+ } -+ // CraftBukkit end - ItemEntity entity = new ItemEntity(level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, itemStack); -- entity.setDefaultPickUpDelay(); -+ entity.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) -+ // Paper start - Call EntityDropItemEvent -+ return this.spawnAtLocation(level, entity); + } +- ++ // CraftBukkit start - Capture drops for death event ++ if (this instanceof net.minecraft.world.entity.LivingEntity && !this.forceDrops) { ++ // Paper start - Restore vanilla drops behavior ++ ((net.minecraft.world.entity.LivingEntity)this).drops.add(new net.minecraft.world.entity.Entity.DefaultDrop(itemStack, dropStack -> { ++ ItemEntity dropEntity = new ItemEntity(this.level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, dropStack); // stack is copied before consumer ++ dropEntity.setDefaultPickUpDelay(); ++ this.level.addFreshEntity(dropEntity); ++ if (delayedAddConsumer != null) delayedAddConsumer.accept(dropEntity); ++ })); ++ // Paper end - Restore vanilla drops behavior ++ return null; + } ++ // CraftBukkit end + ItemEntity entity = new ItemEntity(level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, itemStack); +- entity.setDefaultPickUpDelay(); ++ entity.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) ++ // Paper start - Call EntityDropItemEvent ++ return this.spawnAtLocation(level, entity); + } + + public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemEntity entity) { @@ -1006,11 +998,10 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + return null; + } + // CraftBukkit end -+ { - level.addFreshEntity(entity); - return entity; - } -@@ -2183,6 +2768,15 @@ public abstract class Entity + level.addFreshEntity(entity); + return entity; + } +@@ -2187,6 +_,15 @@ for (Leashable mob : mobsToLeash) { if (mob.canHaveALeashAttachedTo(this)) { @@ -1026,7 +1017,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 mob.setLeashedTo(this, true); anyLeashed = true; } -@@ -2197,7 +2791,7 @@ public abstract class Entity +@@ -2201,7 +_,7 @@ } ItemStack heldItem = player.getItemInHand(hand); @@ -1035,17 +1026,17 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 heldItem.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob target -@@ -2210,11 +2804,13 @@ public abstract class Entity - if (this.isAlive() && this instanceof Leashable leashablex) { - if (leashablex.getLeashHolder() == player) { +@@ -2214,11 +_,13 @@ + if (this.isAlive() && this instanceof Leashable leashable) { + if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { - if (player.hasInfiniteMaterials()) { -- leashablex.removeLeash(); +- leashable.removeLeash(); - } else { -- leashablex.dropLeash(); +- leashable.dropLeash(); + // Paper start - EntityUnleashEvent + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerUnleashEntityEvent( -+ leashablex, player, hand, !player.hasInfiniteMaterials(), true ++ leashable, player, hand, !player.hasInfiniteMaterials(), true + )) { + return InteractionResult.PASS; } @@ -1053,31 +1044,31 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2231,9 +2827,22 @@ public abstract class Entity +@@ -2235,9 +_,22 @@ - if (leashablex.canHaveALeashAttachedTo(player)) { - if (leashablex.isLeashed()) { -- leashablex.dropLeash(); + if (leashable.canHaveALeashAttachedTo(player)) { + if (leashable.isLeashed()) { +- leashable.dropLeash(); + // Paper start - EntityUnleashEvent + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerUnleashEntityEvent( -+ leashablex, player, hand, true, true ++ leashable, player, hand, true, true + )) { + return InteractionResult.PASS; + } + // Paper end - EntityUnleashEvent -+ // leashablex.dropLeash(); // Paper - EntityUnleashEvent - moved into handlePlayerUnleashEntityEvent ++ // leashable.dropLeash(); // Paper - EntityUnleashEvent - moved into handlePlayerUnleashEntityEvent } + // Paper start - EntityLeashEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) { -+ ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(this, leashablex.getLeashHolder())); ++ ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); + return InteractionResult.PASS; + } + // Paper end - EntityLeashEvent - leashablex.setLeashedTo(player, true); + leashable.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemStack.shrink(1); -@@ -2247,7 +2856,13 @@ public abstract class Entity +@@ -2251,7 +_,13 @@ } public boolean shearOffAllLeashConnections(final @Nullable Player player) { @@ -1092,7 +1083,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (dropped && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2256,15 +2871,39 @@ public abstract class Entity +@@ -2260,15 +_,39 @@ } public boolean dropAllLeashConnections(final @Nullable Player player) { @@ -1136,7 +1127,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } if (dropped) { -@@ -2288,7 +2927,9 @@ public abstract class Entity +@@ -2292,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1146,37 +1137,31 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemStack, target); } -@@ -2356,11 +2997,11 @@ public abstract class Entity +@@ -2360,7 +_,7 @@ } public boolean startRiding(final Entity entityToRide, final boolean force, final boolean sendEventAndTriggers) { - if (entityToRide == this.vehicle) { + if (entityToRide == this.vehicle || entityToRide.level != this.level) { // Paper - Ensure entity passenger world matches ridden entity (bad plugins) return false; - } else if (!entityToRide.couldAcceptPassenger()) { + } + +@@ -2368,7 +_,7 @@ return false; -- } else if (!this.level().isClientSide() && !entityToRide.type.canSerialize()) { -+ } else if (!force && !this.level().isClientSide() && !entityToRide.type.canSerialize()) { // SPIGOT-7947: Allow force riding all entities + } + +- if (!this.level().isClientSide() && !entityToRide.type.canSerialize()) { ++ if (!force && !this.level().isClientSide() && !entityToRide.type.canSerialize()) { // SPIGOT-7947: Allow force riding all entities return false; - } else { - for (Entity vehicleEntity = entityToRide; vehicleEntity.vehicle != null; vehicleEntity = vehicleEntity.vehicle) { -@@ -2370,6 +3011,27 @@ public abstract class Entity - } + } - if (force || this.canRide(entityToRide) && entityToRide.canAddPassenger(this)) { -+ // CraftBukkit start -+ if (entityToRide.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && this.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { -+ org.bukkit.event.vehicle.VehicleEnterEvent event = new org.bukkit.event.vehicle.VehicleEnterEvent((org.bukkit.entity.Vehicle) entityToRide.getBukkitEntity(), this.getBukkitEntity()); -+ // Suppress during worldgen -+ if (this.valid) { -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ } -+ if (event.isCancelled()) { -+ return false; -+ } -+ } -+ -+ org.bukkit.event.entity.EntityMountEvent event = new org.bukkit.event.entity.EntityMountEvent(this.getBukkitEntity(), entityToRide.getBukkitEntity()); +@@ -2379,6 +_,27 @@ + } + + if (force || this.canRide(entityToRide) && entityToRide.canAddPassenger(this)) { ++ // CraftBukkit start ++ if (entityToRide.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && this.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { ++ org.bukkit.event.vehicle.VehicleEnterEvent event = new org.bukkit.event.vehicle.VehicleEnterEvent((org.bukkit.entity.Vehicle) entityToRide.getBukkitEntity(), this.getBukkitEntity()); + // Suppress during worldgen + if (this.valid) { + org.bukkit.Bukkit.getPluginManager().callEvent(event); @@ -1184,11 +1169,21 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + if (event.isCancelled()) { + return false; + } -+ // CraftBukkit end - if (this.isPassenger()) { - this.stopRiding(); - } -@@ -2402,10 +3064,16 @@ public abstract class Entity ++ } ++ ++ org.bukkit.event.entity.EntityMountEvent event = new org.bukkit.event.entity.EntityMountEvent(this.getBukkitEntity(), entityToRide.getBukkitEntity()); ++ // Suppress during worldgen ++ if (this.valid) { ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + if (this.isPassenger()) { + this.stopRiding(); + } +@@ -2410,10 +_,16 @@ } public void removeVehicle() { @@ -1206,7 +1201,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, oldVehicle.position); -@@ -2414,7 +3082,13 @@ public abstract class Entity +@@ -2422,7 +_,13 @@ } public void stopRiding() { @@ -1221,7 +1216,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } protected void addPassenger(final Entity passenger) { -@@ -2436,10 +3110,44 @@ public abstract class Entity +@@ -2444,11 +_,44 @@ } } @@ -1235,47 +1230,47 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // Paper end - Force entity dismount during teleportation if (passenger.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); - } else { -+ // CraftBukkit start -+ org.bukkit.craftbukkit.entity.CraftEntity craft = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); -+ Entity orig = craft == null ? null : craft.getHandle(); -+ if (this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && passenger.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { -+ org.bukkit.event.vehicle.VehicleExitEvent event = new org.bukkit.event.vehicle.VehicleExitEvent( -+ (org.bukkit.entity.Vehicle) this.getBukkitEntity(), -+ (org.bukkit.entity.LivingEntity) passenger.getBukkitEntity(), !suppressCancellation // Paper - Force entity dismount during teleportation -+ ); -+ // Suppress during worldgen -+ if (this.valid) { -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ } -+ org.bukkit.craftbukkit.entity.CraftEntity craftn = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); -+ Entity n = craftn == null ? null : craftn.getHandle(); -+ if (event.isCancelled() || n != orig) { -+ return false; -+ } -+ } -+ -+ org.bukkit.event.entity.EntityDismountEvent event = new org.bukkit.event.entity.EntityDismountEvent(passenger.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper - Force entity dismount during teleportation + } ++ // CraftBukkit start ++ org.bukkit.craftbukkit.entity.CraftEntity craft = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); ++ Entity orig = craft == null ? null : craft.getHandle(); ++ if (this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && passenger.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { ++ org.bukkit.event.vehicle.VehicleExitEvent event = new org.bukkit.event.vehicle.VehicleExitEvent( ++ (org.bukkit.entity.Vehicle) this.getBukkitEntity(), ++ (org.bukkit.entity.LivingEntity) passenger.getBukkitEntity(), !suppressCancellation // Paper - Force entity dismount during teleportation ++ ); + // Suppress during worldgen + if (this.valid) { + org.bukkit.Bukkit.getPluginManager().callEvent(event); + } -+ if (event.isCancelled()) { ++ org.bukkit.craftbukkit.entity.CraftEntity craftn = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); ++ Entity n = craftn == null ? null : craftn.getHandle(); ++ if (event.isCancelled() || n != orig) { + return false; + } -+ // CraftBukkit end - if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { - this.passengers = ImmutableList.of(); - } else { -@@ -2448,6 +3156,7 @@ public abstract class Entity ++ } - passenger.boardingCooldown = 60; ++ org.bukkit.event.entity.EntityDismountEvent event = new org.bukkit.event.entity.EntityDismountEvent(passenger.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper - Force entity dismount during teleportation ++ // Suppress during worldgen ++ if (this.valid) { ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { + this.passengers = ImmutableList.of(); + } else { +@@ -2456,6 +_,7 @@ } + + passenger.boardingCooldown = 60; + return true; // CraftBukkit } protected boolean canAddPassenger(final Entity passenger) { -@@ -2630,7 +3339,7 @@ public abstract class Entity +@@ -2638,7 +_,7 @@ } public boolean isCrouching() { @@ -1284,7 +1279,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean isSprinting() { -@@ -2646,7 +3355,7 @@ public abstract class Entity +@@ -2654,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1293,7 +1288,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean isVisuallyCrawling() { -@@ -2654,6 +3363,13 @@ public abstract class Entity +@@ -2662,6 +_,13 @@ } public void setSwimming(final boolean swimming) { @@ -1307,7 +1302,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2691,6 +3407,7 @@ public abstract class Entity +@@ -2699,6 +_,7 @@ } public @Nullable PlayerTeam getTeam() { @@ -1315,7 +1310,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2707,7 +3424,11 @@ public abstract class Entity +@@ -2715,7 +_,11 @@ } public void setInvisible(final boolean invisible) { @@ -1328,7 +1323,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public boolean getSharedFlag(@Entity.Flags final int flag) { -@@ -2724,7 +3445,7 @@ public abstract class Entity +@@ -2732,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1337,7 +1332,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public int getAirSupply() { -@@ -2732,10 +3453,24 @@ public abstract class Entity +@@ -2740,10 +_,24 @@ } public void setAirSupply(final int supply) { @@ -1363,7 +1358,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.setTicksFrozen(0); } -@@ -2762,11 +3497,42 @@ public abstract class Entity +@@ -2770,11 +_,42 @@ public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1374,6 +1369,9 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // CraftBukkit end if (this.remainingFireTicks == 0) { - this.igniteForSeconds(8.0F); +- } +- +- this.hurtServer(level, this.damageSources().lightningBolt(), 5.0F); + // CraftBukkit start - Call a combust event when lightning strikes + org.bukkit.event.entity.EntityCombustByEntityEvent entityCombustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F); + pluginManager.callEvent(entityCombustEvent); @@ -1385,9 +1383,8 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // Paper end - fix EntityCombustEvent cancellation + } + // CraftBukkit end - } - -- this.hurtServer(level, this.damageSources().lightningBolt(), 5.0F); ++ } ++ + // CraftBukkit start + final DamageSource damageSource = this.damageSources().lightningBolt().eventEntityDamager(lightningBolt); + if (thisBukkitEntity instanceof org.bukkit.entity.Hanging) { @@ -1408,7 +1405,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public void onAboveBubbleColumn(final boolean dragDown, final BlockPos pos) { -@@ -2916,26 +3682,30 @@ public abstract class Entity +@@ -2924,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1442,7 +1439,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 ); } -@@ -2959,6 +3729,13 @@ public abstract class Entity +@@ -2967,6 +_,13 @@ } public void restoreFrom(final Entity oldEntity) { @@ -1456,7 +1453,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput entityData = TagValueOutput.createWithContext(reporter, oldEntity.registryAccess()); oldEntity.saveWithoutId(entityData); -@@ -2969,8 +3746,66 @@ public abstract class Entity +@@ -2977,8 +_,66 @@ this.portalProcess = oldEntity.portalProcess; } @@ -1524,24 +1521,24 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 ServerLevel newLevel = transition.newLevel(); boolean otherDimension = newLevel.dimension() != serverLevel.dimension(); if (!transition.asPassenger()) { -@@ -3019,10 +3854,15 @@ public abstract class Entity - profiler.pop(); +@@ -3028,10 +_,15 @@ return null; - } else { -+ // Paper start - Fix item duplication and teleport issues -+ if (this instanceof Leashable leashable) { -+ leashable.dropLeash(); // Paper drop lead -+ } -+ // Paper end - Fix item duplication and teleport issues - newEntity.restoreFrom(this); - this.removeAfterChangingDimensions(); - newEntity.teleportSetPosition(PositionMoveRotation.of(this), PositionMoveRotation.of(transition), transition.relatives()); -- newLevel.addDuringTeleport(newEntity); -+ if (this.inWorld) newLevel.addDuringTeleport(newEntity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned + } - for (Entity newPassenger : newPassengers) { - newPassenger.startRiding(newEntity, true, false); -@@ -3109,9 +3949,17 @@ public abstract class Entity ++ // Paper start - Fix item duplication and teleport issues ++ if (this instanceof Leashable leashable) { ++ leashable.dropLeash(); // Paper drop lead ++ } ++ // Paper end - Fix item duplication and teleport issues + newEntity.restoreFrom(this); + this.removeAfterChangingDimensions(); + newEntity.teleportSetPosition(PositionMoveRotation.of(this), PositionMoveRotation.of(transition), transition.relatives()); +- newLevel.addDuringTeleport(newEntity); ++ if (this.inWorld) newLevel.addDuringTeleport(newEntity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned + + for (Entity newPassenger : newPassengers) { + newPassenger.startRiding(newEntity, true, false); +@@ -3117,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1562,7 +1559,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } if (this instanceof WaypointTransmitter waypoint && this.level instanceof ServerLevel serverLevel) { -@@ -3128,6 +3976,7 @@ public abstract class Entity +@@ -3136,6 +_,7 @@ } public boolean canTeleport(final Level from, final Level to) { @@ -1570,7 +1567,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { for (Entity passenger : this.getPassengers()) { if (passenger instanceof ServerPlayer player && !player.seenCredits) { -@@ -3246,7 +4095,7 @@ public abstract class Entity +@@ -3254,7 +_,7 @@ } } @@ -1579,7 +1576,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 final ServerLevel level, final double x, final double y, -@@ -3256,14 +4105,30 @@ public abstract class Entity +@@ -3264,14 +_,30 @@ final float newXRot, final boolean resetCamera ) { @@ -1612,7 +1609,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public void teleportTo(final double x, final double y, final double z) { -@@ -3374,7 +4239,26 @@ public abstract class Entity +@@ -3382,7 +_,26 @@ } public final void setBoundingBox(final AABB bb) { @@ -1640,7 +1637,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public final float getEyeHeight(final Pose pose) { -@@ -3398,6 +4282,12 @@ public abstract class Entity +@@ -3406,6 +_,12 @@ } public void stopSeenByPlayer(final ServerPlayer player) { @@ -1653,7 +1650,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public float rotate(final Rotation rotation) { -@@ -3456,21 +4346,32 @@ public abstract class Entity +@@ -3464,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1687,7 +1684,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } public int countPlayerPassengers() { -@@ -3478,6 +4379,7 @@ public abstract class Entity +@@ -3486,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1695,7 +1692,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 return this.countPlayerPassengers() == 1; } -@@ -3558,9 +4460,38 @@ public abstract class Entity +@@ -3566,9 +_,38 @@ return 0; } @@ -1735,7 +1732,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 this.position(), this.getRotationVector(), level, -@@ -3658,7 +4589,9 @@ public abstract class Entity +@@ -3666,7 +_,9 @@ public void setDeltaMovement(final Vec3 deltaMovement) { if (deltaMovement.isFinite()) { @@ -1745,7 +1742,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 } } -@@ -3729,8 +4662,34 @@ public abstract class Entity +@@ -3737,8 +_,34 @@ } public final void setPosRaw(final double x, final double y, final double z) { @@ -1780,10 +1777,11 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 int fx = Mth.floor(x); int fy = Mth.floor(y); int fz = Mth.floor(z); -@@ -3752,7 +4711,18 @@ public abstract class Entity +@@ -3760,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(player); } } +- } + // Paper start - Fix MC-44654 + if (this.getType().updateInterval() == Integer.MAX_VALUE) { + this.needsSync = true; @@ -1794,12 +1792,12 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 + // hanging has its own special logic + if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (forceBoundingBoxUpdate || this.position.x != x || this.position.y != y || this.position.z != z)) { + this.setBoundingBox(this.makeBoundingBox()); - } ++ } + // Paper end - Block invalid positions and bounding box } public void checkDespawn() { -@@ -3804,6 +4774,12 @@ public abstract class Entity +@@ -3812,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1812,7 +1810,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 public float getYRot() { return this.yRot; } -@@ -3854,7 +4830,9 @@ public abstract class Entity +@@ -3862,7 +_,9 @@ } @Override @@ -1823,7 +1821,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 if (this.removalReason == null) { this.removalReason = reason; } -@@ -3866,12 +4844,28 @@ public abstract class Entity +@@ -3874,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(reason); this.onRemoval(reason); @@ -1852,7 +1850,7 @@ index e8e6f5c2d72a203187b361acf9f5fd7d8e5f05de..29896cb17fcf8ab967a937e9b0e102a8 @Override public void setLevelCallback(final EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4093,4 +5087,14 @@ public abstract class Entity +@@ -4101,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch similarity index 91% rename from paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch index edaf16a29ab2..dfeb863c74a4 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,23 +1,14 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ExperienceOrb.java b/net/minecraft/world/entity/ExperienceOrb.java -index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d2b3e0ccf 100644 --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -43,13 +43,57 @@ public class ExperienceOrb extends Entity { +@@ -43,13 +_,57 @@ public int count = 1; private @Nullable Player followingPlayer; private final InterpolationHandler interpolation = new InterpolationHandler(this); -- + // Paper start + public java.util.@Nullable UUID sourceEntityId; + public java.util.@Nullable UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; -+ + + private void loadPaperNBT(ValueInput input) { + input.read("Paper.ExpData", net.minecraft.nbt.CompoundTag.CODEC).ifPresent(expData -> { + this.sourceEntityId = expData.read("source", net.minecraft.core.UUIDUtil.CODEC).orElse(null); @@ -68,7 +59,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d this.setPos(pos); if (!level.isClientSide()) { this.setYRot(this.random.nextFloat() * 360.0F); -@@ -146,12 +190,13 @@ public class ExperienceOrb extends Entity { +@@ -146,12 +_,13 @@ this.age++; if (this.age >= 6000) { @@ -83,7 +74,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); if (nearestPlayer != null && !nearestPlayer.isSpectator() && !nearestPlayer.isDeadOrDying()) { -@@ -161,7 +206,24 @@ public class ExperienceOrb extends Entity { +@@ -161,7 +_,24 @@ } } @@ -109,7 +100,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d Vec3 delta = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -191,18 +253,24 @@ public class ExperienceOrb extends Entity { +@@ -191,18 +_,24 @@ } public static void awardWithDirection(final ServerLevel level, final Vec3 pos, final Vec3 roughDirection, int amount) { @@ -136,7 +127,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d List orbs = level.getEntities(EntityTypeTest.forClass(ExperienceOrb.class), box, orbx -> canMerge(orbx, id, value)); if (!orbs.isEmpty()) { ExperienceOrb orb = orbs.get(0); -@@ -219,13 +287,18 @@ public class ExperienceOrb extends Entity { +@@ -219,13 +_,18 @@ } private static boolean canMerge(final ExperienceOrb orb, final int id, final int value) { @@ -157,16 +148,16 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d } private void setUnderwaterMovement() { -@@ -250,7 +323,7 @@ public class ExperienceOrb extends Entity { - this.markHurt(); - this.health = (int)(this.health - damage); - if (this.health <= 0) { -- this.discard(); -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - } +@@ -251,7 +_,7 @@ + this.markHurt(); + this.health = (int)(this.health - damage); + if (this.health <= 0) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause + } - return true; -@@ -261,32 +334,34 @@ public class ExperienceOrb extends Entity { + return true; +@@ -261,32 +_,34 @@ protected void addAdditionalSaveData(final ValueOutput output) { output.putShort("Health", (short)this.health); output.putShort("Age", (short)this.age); @@ -207,7 +198,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d } } } -@@ -298,9 +373,19 @@ public class ExperienceOrb extends Entity { +@@ -298,9 +_,19 @@ ItemStack itemStack = selected.get().itemStack(); int toRepairFromXpAmount = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemStack, amount); int repair = Math.min(toRepairFromXpAmount, itemStack.getDamageValue()); @@ -228,7 +219,7 @@ index f3db7fc83ec00e7d1a9fb25b932ddb620f87f1b3..e302c6198d71782b524391329aa5c89d if (remaining > 0) { return this.repairPlayerItems(player, remaining); } -@@ -346,6 +431,24 @@ public class ExperienceOrb extends Entity { +@@ -346,6 +_,24 @@ } public static int getExperienceValue(final int maxValue) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch similarity index 72% rename from paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch index eb7fd4935f55..3090807a9501 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/InsideBlockEffectType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/InsideBlockEffectType.java b/net/minecraft/world/entity/InsideBlockEffectType.java -index 56c7c5025db50d78f3c532b3d821028a8d904298..d2e967831d08af16cb08741fad89e2e0e532744a 100644 --- a/net/minecraft/world/entity/InsideBlockEffectType.java +++ b/net/minecraft/world/entity/InsideBlockEffectType.java -@@ -6,22 +6,35 @@ import net.minecraft.world.level.block.BaseFireBlock; +@@ -6,22 +_,35 @@ public enum InsideBlockEffectType { FREEZE(entity -> { entity.setIsInPowderSnow(true); @@ -26,11 +18,11 @@ index 56c7c5025db50d78f3c532b3d821028a8d904298..d2e967831d08af16cb08741fad89e2e0 - private final Consumer effect; + private final Applier effect; // Paper - track position inside effect was triggered on - private InsideBlockEffectType(final Consumer effect) { + InsideBlockEffectType(final Consumer effect) { + // Paper start - track position inside effect was triggered on + this((entity, block) -> effect.accept(entity)); + } -+ private InsideBlockEffectType(final Applier effect) { ++ InsideBlockEffectType(final Applier effect) { + // Paper end - track position inside effect was triggered on this.effect = effect; } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch similarity index 75% rename from paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 6f69f0d771cb..b15501d0a383 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9bc749f28b 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -140,6 +140,17 @@ import org.jetbrains.annotations.Contract; +@@ -140,6 +_,17 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -26,7 +18,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -269,11 +280,25 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -269,11 +_,25 @@ private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); public @Nullable Vec3 currentImpulseImpactPos; public @Nullable Entity currentExplosionCause; @@ -53,7 +45,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -365,7 +390,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -365,7 +_,13 @@ double scale = Math.min(0.2F + power / 15.0, 2.5); int particles = (int)(150.0 * scale); @@ -67,7 +59,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } -@@ -550,7 +581,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -550,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -76,7 +68,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } -@@ -652,7 +683,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -652,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -85,7 +77,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public void setDiscardFriction(final boolean discardFriction) { -@@ -664,10 +695,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -664,10 +_,15 @@ } public void onEquipItem(final EquipmentSlot slot, final ItemStack oldStack, final ItemStack stack) { @@ -102,7 +94,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.level() .playSeededSound( null, -@@ -694,12 +730,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -694,12 +_,12 @@ } @Override @@ -117,7 +109,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.brain.clearMemories(); } -@@ -716,11 +752,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -716,11 +_,17 @@ effect.onMobRemoved(level, this, reason); } @@ -135,7 +127,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -755,7 +797,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -755,7 +_,12 @@ } } @@ -148,40 +140,40 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + // Paper end - Extend dropItem API if (itemStack.isEmpty()) { return null; - } else if (this.level().isClientSide()) { -@@ -764,6 +811,31 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - } else { - ItemEntity entity = this.createItemStackToDrop(itemStack, randomly, thrownFromHand); - if (entity != null) { -+ // CraftBukkit start - fire PlayerDropItemEvent -+ if (entityOperation != null) entityOperation.accept((org.bukkit.entity.Item) entity.getBukkitEntity()); -+ if (callEvent && this.getBukkitEntity() instanceof org.bukkit.entity.Player player) { -+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entity.getBukkitEntity(); -+ -+ org.bukkit.event.player.PlayerDropItemEvent event = new org.bukkit.event.player.PlayerDropItemEvent(player, drop); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ org.bukkit.inventory.ItemStack inHandItem = player.getInventory().getItemInMainHand(); -+ if (thrownFromHand && inHandItem.getAmount() == 0) { -+ // The complete stack was dropped -+ player.getInventory().setItemInMainHand(drop.getItemStack()); -+ } else if (thrownFromHand && inHandItem.isSimilar(drop.getItemStack()) && inHandItem.getAmount() < inHandItem.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { -+ // Only one item is dropped -+ inHandItem.setAmount(inHandItem.getAmount() + 1); -+ player.getInventory().setItemInMainHand(inHandItem); -+ } else { -+ // Fallback -+ player.getInventory().addItem(drop.getItemStack()); -+ } -+ return null; + } +@@ -767,6 +_,31 @@ + + ItemEntity entity = this.createItemStackToDrop(itemStack, randomly, thrownFromHand); + if (entity != null) { ++ // CraftBukkit start - fire PlayerDropItemEvent ++ if (entityOperation != null) entityOperation.accept((org.bukkit.entity.Item) entity.getBukkitEntity()); ++ if (callEvent && this.getBukkitEntity() instanceof org.bukkit.entity.Player player) { ++ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entity.getBukkitEntity(); ++ ++ org.bukkit.event.player.PlayerDropItemEvent event = new org.bukkit.event.player.PlayerDropItemEvent(player, drop); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ org.bukkit.inventory.ItemStack inHandItem = player.getInventory().getItemInMainHand(); ++ if (thrownFromHand && inHandItem.getAmount() == 0) { ++ // The complete stack was dropped ++ player.getInventory().setItemInMainHand(drop.getItemStack()); ++ } else if (thrownFromHand && inHandItem.isSimilar(drop.getItemStack()) && inHandItem.getAmount() < inHandItem.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { ++ // Only one item is dropped ++ inHandItem.setAmount(inHandItem.getAmount() + 1); ++ player.getInventory().setItemInMainHand(inHandItem); ++ } else { ++ // Fallback ++ player.getInventory().addItem(drop.getItemStack()); + } ++ return null; + } -+ // CraftBukkit end - this.level().addFreshEntity(entity); - } ++ } ++ // CraftBukkit end + this.level().addFreshEntity(entity); + } -@@ -773,7 +845,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -775,7 +_,22 @@ @Override protected void readAdditionalSaveData(final ValueInput input) { @@ -205,7 +197,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -786,6 +873,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -788,6 +_,11 @@ this.effectsDirty = true; } @@ -217,7 +209,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -793,6 +885,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -795,6 +_,7 @@ input.getString("Team").ifPresent(teamName -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam team = scoreboard.getPlayerTeam(teamName); @@ -225,7 +217,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b boolean success = team != null && scoreboard.addPlayerToTeam(this.getStringUUID(), team); if (!success) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", teamName); -@@ -800,11 +893,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -802,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(sleepingPos -> { @@ -239,7 +231,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b }, this::clearSleepingPos); input.read("Brain", Brain.Packed.CODEC).ifPresent(packedBrain -> this.brain = this.makeBrain(packedBrain)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -823,15 +918,44 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -825,15 +_,44 @@ this.updateDirtyEffects(); } @@ -284,7 +276,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b iterator.remove(); this.onEffectsRemoved(List.of(effect)); } else if (effect.getDuration() % 600 == 0) { -@@ -840,6 +964,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -842,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -303,7 +295,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } else { for (MobEffectInstance effect : this.activeEffects.values()) { effect.tickClient(); -@@ -950,15 +1086,33 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -952,6 +_,11 @@ } public boolean removeAllEffects() { @@ -314,34 +306,36 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + // CraftBukkit end if (this.level().isClientSide()) { return false; - } else if (this.activeEffects.isEmpty()) { + } +@@ -960,10 +_,23 @@ return false; - } else { -- Map, MobEffectInstance> copy = Maps.newHashMap(this.activeEffects); -- this.activeEffects.clear(); -- this.onEffectsRemoved(copy.values()); -- return true; -+ // CraftBukkit start -+ List toRemove = new java.util.LinkedList<>(); -+ Iterator iterator = this.activeEffects.values().iterator(); -+ while (iterator.hasNext()) { -+ MobEffectInstance effect = iterator.next(); -+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); -+ if (event.isCancelled()) { -+ continue; -+ } -+ -+ iterator.remove(); -+ toRemove.add(effect); + } + +- Map, MobEffectInstance> copy = Maps.newHashMap(this.activeEffects); +- this.activeEffects.clear(); +- this.onEffectsRemoved(copy.values()); +- return true; ++ // CraftBukkit start ++ List toRemove = new java.util.LinkedList<>(); ++ Iterator iterator = this.activeEffects.values().iterator(); ++ while (iterator.hasNext()) { ++ MobEffectInstance effect = iterator.next(); ++ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); ++ if (event.isCancelled()) { ++ continue; + } + -+ this.onEffectsRemoved(toRemove); -+ return !toRemove.isEmpty(); -+ // CraftBukkit end - } ++ iterator.remove(); ++ toRemove.add(effect); ++ } ++ ++ this.onEffectsRemoved(toRemove); ++ return !toRemove.isEmpty(); ++ // CraftBukkit end } -@@ -984,23 +1138,71 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + public Collection getActiveEffects() { +@@ -988,24 +_,69 @@ } public final boolean addEffect(final MobEffectInstance newEffect) { @@ -372,50 +366,48 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + // CraftBukkit end if (!this.canBeAffected(newEffect)) { return false; - } else { - MobEffectInstance effect = this.activeEffects.get(newEffect.getEffect()); - boolean changed = false; -+ // CraftBukkit start -+ boolean override = false; -+ // Paper start - Properly update hidden effects -+ boolean addAsHiddenEffect = false; -+ if (effect != null) { -+ override = new MobEffectInstance(effect).update(newEffect); -+ addAsHiddenEffect = effect.getAmplifier() > newEffect.getAmplifier() && effect.isShorterDurationThan(newEffect); -+ // Paper end - Properly update hidden effects -+ } + } + + MobEffectInstance effect = this.activeEffects.get(newEffect.getEffect()); + boolean changed = false; ++ // Paper start ++ boolean override = false; ++ boolean addAsHiddenEffect = false; ++ if (effect != null) { ++ override = new MobEffectInstance(effect).update(newEffect); ++ addAsHiddenEffect = effect.getAmplifier() > newEffect.getAmplifier() && effect.isShorterDurationThan(newEffect); ++ } + -+ if (fireEvent) { // Paper - Don't fire sync event during generation ++ if (fireEvent) { + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, newEffect, cause, override); -+ override = event.isOverride(); // Paper - Don't fire sync event during generation ++ override = event.isOverride(); + if (event.isCancelled()) { + return false; + } -+ } // Paper - Don't fire sync event during generation -+ // CraftBukkit end - if (effect == null) { - this.activeEffects.put(newEffect.getEffect(), newEffect); - this.onEffectAdded(newEffect, source); - changed = true; - newEffect.onEffectAdded(this); -- } else if (effect.update(newEffect)) { -+ // CraftBukkit start -+ } else if (override) { // Paper - Don't fire sync event during generation -+ effect.update(newEffect); - this.onEffectUpdated(effect, true, source); - changed = true; -+ // Paper start - Properly update hidden effects -+ } else if (addAsHiddenEffect) { -+ if (effect.hiddenEffect == null) { -+ effect.hiddenEffect = new MobEffectInstance(newEffect); -+ } else { -+ effect.hiddenEffect.update(newEffect); -+ } -+ // Paper end - Properly update hidden effects - } ++ } ++ // Paper end + if (effect == null) { + this.activeEffects.put(newEffect.getEffect(), newEffect); + this.onEffectAdded(newEffect, source); + changed = true; + newEffect.onEffectAdded(this); +- } else if (effect.update(newEffect)) { ++ } else if (override) { // Paper - Don't fire sync event during generation ++ effect.update(newEffect); + this.onEffectUpdated(effect, true, source); + changed = true; ++ // Paper start - Properly update hidden effects ++ } else if (addAsHiddenEffect) { ++ if (effect.hiddenEffect == null) { ++ effect.hiddenEffect = new MobEffectInstance(newEffect); ++ } else { ++ effect.hiddenEffect.update(newEffect); ++ } ++ // Paper end - Properly update hidden effects + } - newEffect.onEffectStarted(this); -@@ -1035,11 +1237,35 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + newEffect.onEffectStarted(this); +@@ -1039,11 +_,35 @@ } public final @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect) { @@ -452,7 +444,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (effectInstance != null) { this.onEffectsRemoved(List.of(effectInstance)); return true; -@@ -1130,17 +1356,62 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1134,17 +_,62 @@ } public void heal(final float heal) { @@ -517,135 +509,135 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1152,7 +1423,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - public boolean hurtServer(final ServerLevel level, final DamageSource source, float damage) { - if (this.isInvulnerableTo(level, source)) { +@@ -1158,7 +_,7 @@ return false; -- } else if (this.isDeadOrDying()) { -+ } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die - return false; - } else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { + } + +- if (this.isDeadOrDying()) { ++ if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; -@@ -1168,35 +1439,58 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - - ItemStack itemInUse = this.getUseItem(); - float originalDamage = damage; -- float damageBlocked = this.applyItemBlocking(level, source, damage); -- damage -= damageBlocked; -+ float damageBlocked = this.applyItemBlocking(level, source, damage, true); // Paper -+ // damage -= damageBlocked; // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to allow modification - boolean blocked = damageBlocked > 0.0F; -- if (source.is(DamageTypeTags.IS_FREEZING) && this.is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount -+ if (false && source.is(DamageTypeTags.IS_FREEZING) && this.is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { - damage *= 5.0F; + } + +@@ -1177,35 +_,58 @@ + + float originalDamage = damage; + ItemStack itemInUse = this.getUseItem(); +- float damageBlocked = this.applyItemBlocking(level, source, damage); +- damage -= damageBlocked; ++ float damageBlocked = this.applyItemBlocking(level, source, damage, true); // Paper ++ // damage -= damageBlocked; // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to allow modification + boolean blocked = damageBlocked > 0.0F; +- if (source.is(DamageTypeTags.IS_FREEZING) && this.is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { ++ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount ++ if (false && source.is(DamageTypeTags.IS_FREEZING) && this.is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { + damage *= 5.0F; + } + +- if (source.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { ++ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage ++ if (false && source.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { + this.hurtHelmet(source, damage); + damage *= 0.75F; + } + ++ EntityDamageEvent event; // CraftBukkit // Paper - move this into the actual invuln check.... + if (Float.isNaN(damage) || Float.isInfinite(damage)) { + damage = Float.MAX_VALUE; + } + + boolean tookFullDamage = true; +- if (this.invulnerableTime > 10.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { ++ if (this.invulnerableTime > (float)this.invulnerableDuration / 2.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { // CraftBukkit - restore use of maxNoDamageTicks + if (damage <= this.lastHurt) { + return false; } -- if (source.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage -+ if (false && source.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { - this.hurtHelmet(source, damage); - damage *= 0.75F; +- this.actuallyHurt(level, source, damage - this.lastHurt); ++ // Paper start - only call damage event when actuallyHurt will be called - move call logic down ++ event = this.handleEntityDamage(source, damage, this.lastHurt); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction ++ damage = this.computeAmountFromEntityDamageEvent(event); ++ // Paper end - only call damage event when actuallyHurt will be called - move call logic down ++ ++ // CraftBukkit start ++ if (!this.actuallyHurt(level, source, (float)event.getFinalDamage(), event)) { // Paper - fix invulnerability reduction in EntityDamageEvent - no longer subtract lastHurt, that is part of the damage event calc now ++ return false; ++ } ++ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalDamage == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event. ++ // CraftBukkit end + this.lastHurt = damage; + tookFullDamage = false; + } else { ++ // Paper start - only call damage event when actuallyHurt will be called - move call logic down ++ event = this.handleEntityDamage(source, damage, 0); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction (none in this branch) ++ damage = this.computeAmountFromEntityDamageEvent(event); ++ // Paper end - only call damage event when actuallyHurt will be called - move call logic down ++ // CraftBukkit start ++ if (!this.actuallyHurt(level, source, (float)event.getFinalDamage(), event)) { ++ return false; ++ } ++ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalDamage == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event. + this.lastHurt = damage; +- this.invulnerableTime = 20; +- this.actuallyHurt(level, source, damage); ++ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks ++ // this.actuallyHurt(level, source, damage); ++ // CraftBukkit end + this.hurtDuration = 10; + this.hurtTime = this.hurtDuration; + } +@@ -1220,7 +_,7 @@ + level.broadcastDamageEvent(this, source); } -+ EntityDamageEvent event; // CraftBukkit // Paper - move this into the actual invuln check.... - if (Float.isNaN(damage) || Float.isInfinite(damage)) { - damage = Float.MAX_VALUE; +- if (!source.is(DamageTypeTags.NO_IMPACT) && (!blocked || damage > 0.0F)) { ++ if (!source.is(DamageTypeTags.NO_IMPACT) && !blocked) { // CraftBukkit - Prevent marking hurt if the damage is blocked + this.markHurt(); } - boolean tookFullDamage = true; -- if (this.invulnerableTime > 10.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { -+ if (this.invulnerableTime > (float)this.invulnerableDuration / 2.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { // CraftBukkit - restore use of maxNoDamageTicks - if (damage <= this.lastHurt) { - return false; +@@ -1236,7 +_,16 @@ + zd = source.getSourcePosition().z() - this.getZ(); } -- this.actuallyHurt(level, source, damage - this.lastHurt); -+ // Paper start - only call damage event when actuallyHurt will be called - move call logic down -+ event = this.handleEntityDamage(source, damage, this.lastHurt); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction -+ damage = this.computeAmountFromEntityDamageEvent(event); -+ // Paper end - only call damage event when actuallyHurt will be called - move call logic down -+ -+ // CraftBukkit start -+ if (!this.actuallyHurt(level, source, (float)event.getFinalDamage(), event)) { // Paper - fix invulnerability reduction in EntityDamageEvent - no longer subtract lastHurt, that is part of the damage event calc now -+ return false; +- this.knockback(0.4F, xd, zd); ++ // Paper start - Check distance in entity interactions; see for loop in knockback method ++ if (Math.abs(xd) > 200) { ++ xd = Math.random() - Math.random(); + } -+ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalDamage == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event. -+ // CraftBukkit end - this.lastHurt = damage; - tookFullDamage = false; - } else { -+ // Paper start - only call damage event when actuallyHurt will be called - move call logic down -+ event = this.handleEntityDamage(source, damage, 0); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction (none in this branch) -+ damage = this.computeAmountFromEntityDamageEvent(event); -+ // Paper end - only call damage event when actuallyHurt will be called - move call logic down -+ // CraftBukkit start -+ if (!this.actuallyHurt(level, source, (float)event.getFinalDamage(), event)) { -+ return false; ++ if (Math.abs(zd) > 200) { ++ zd = Math.random() - Math.random(); + } -+ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalDamage == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event. - this.lastHurt = damage; -- this.invulnerableTime = 20; -- this.actuallyHurt(level, source, damage); -+ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks -+ // this.actuallyHurt(level, source, damage); -+ // CraftBukkit end - this.hurtDuration = 10; - this.hurtTime = this.hurtDuration; - } -@@ -1211,7 +1505,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - level.broadcastDamageEvent(this, source); - } - -- if (!source.is(DamageTypeTags.NO_IMPACT) && (!blocked || damage > 0.0F)) { -+ if (!source.is(DamageTypeTags.NO_IMPACT) && !blocked) { // CraftBukkit - Prevent marking hurt if the damage is blocked - this.markHurt(); ++ // Paper end - Check distance in entity interactions ++ ++ this.knockback(0.4F, xd, zd, source.getDirectEntity(), source.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events + if (!blocked) { + this.indicateDamage(xd, zd); } +@@ -1245,19 +_,19 @@ + + if (this.isDeadOrDying()) { + if (!this.checkTotemDeathProtection(source)) { +- if (tookFullDamage) { +- this.makeSound(this.getDeathSound()); +- this.playSecondaryHurtSound(source); +- } ++ // Paper start - moved into CraftEventFactory event caller for cancellable death event ++ this.silentDeath = !tookFullDamage; // mark entity as dying silently ++ // Paper end -@@ -1226,8 +1520,16 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - xd = source.getSourcePosition().x() - this.getX(); - zd = source.getSourcePosition().z() - this.getZ(); - } -+ // Paper start - Check distance in entity interactions; see for loop in knockback method -+ if (Math.abs(xd) > 200) { -+ xd = Math.random() - Math.random(); -+ } -+ if (Math.abs(zd) > 200) { -+ zd = Math.random() - Math.random(); -+ } -+ // Paper end - Check distance in entity interactions - -- this.knockback(0.4F, xd, zd); -+ this.knockback(0.4F, xd, zd, source.getDirectEntity(), source.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events - if (!blocked) { - this.indicateDamage(xd, zd); - } -@@ -1236,19 +1538,19 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - - if (this.isDeadOrDying()) { - if (!this.checkTotemDeathProtection(source)) { -- if (tookFullDamage) { -- this.makeSound(this.getDeathSound()); -- this.playSecondaryHurtSound(source); -- } -+ // Paper start - moved into CraftEventFactory event caller for cancellable death event -+ this.silentDeath = !tookFullDamage; // mark entity as dying silently -+ // Paper end - - this.die(source); -+ this.silentDeath = false; // Paper - cancellable death event - reset to default - } - } else if (tookFullDamage) { - this.playHurtSound(source); - this.playSecondaryHurtSound(source); + this.die(source); ++ this.silentDeath = false; // Paper - cancellable death event - reset to default } + } else if (tookFullDamage) { + this.playHurtSound(source); + this.playSecondaryHurtSound(source); + } -- boolean success = !blocked || damage > 0.0F; -+ boolean success = !blocked; // CraftBukkit - Ensure to return false if damage is blocked - if (success) { - this.lastDamageSource = source; - this.lastDamageStamp = this.level().getGameTime(); -@@ -1274,6 +1576,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +- boolean success = !blocked || damage > 0.0F; ++ boolean success = !blocked; // CraftBukkit - Ensure to return false if damage is blocked + if (success) { + this.lastDamageSource = source; + this.lastDamageStamp = this.level().getGameTime(); +@@ -1282,6 +_,12 @@ } public float applyItemBlocking(final ServerLevel level, final DamageSource source, final float damage) { @@ -657,22 +649,22 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + // Paper end if (damage <= 0.0F) { return 0.0F; - } else { -@@ -1298,10 +1606,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - } - - float damageBlocked = blocksAttacks.resolveBlockedDamage(source, damage, angle); -+ if (!dryRun) { // Paper - blocksAttacks.hurtBlockingItem(this.level(), blockingWith, this, this.getUsedItemHand(), damageBlocked); -- if (damageBlocked > 0.0F && !source.is(DamageTypeTags.IS_PROJECTILE) && source.getDirectEntity() instanceof LivingEntity livingEntity) { -+ if (damageBlocked > 0.0F && !source.is(DamageTypeTags.IS_PROJECTILE) && source.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions - this.blockUsingItem(level, livingEntity); - } -+ } // Paper - - return damageBlocked; - } -@@ -1312,6 +1622,59 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + } +@@ -1308,10 +_,12 @@ + } + + float damageBlocked = blocksAttacks.resolveBlockedDamage(source, damage, angle); ++ if (!dryRun) { // Paper + blocksAttacks.hurtBlockingItem(this.level(), blockingWith, this, this.getUsedItemHand(), damageBlocked); +- if (damageBlocked > 0.0F && !source.is(DamageTypeTags.IS_PROJECTILE) && source.getDirectEntity() instanceof LivingEntity livingEntity) { ++ if (damageBlocked > 0.0F && !source.is(DamageTypeTags.IS_PROJECTILE) && source.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions + this.blockUsingItem(level, livingEntity); + } ++ } // Paper + + return damageBlocked; + } +@@ -1320,6 +_,59 @@ } } @@ -732,7 +724,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b public void playSecondaryHurtSound(final DamageSource source) { if (source.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1343,12 +1706,24 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1351,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -758,51 +750,54 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } private boolean checkTotemDeathProtection(final DamageSource killingDamage) { -@@ -1358,18 +1733,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - ItemStack protectionItem = null; - DeathProtection protection = null; - -+ // CraftBukkit start -+ InteractionHand usedHand = null; -+ ItemStack itemStack = ItemStack.EMPTY; - for (InteractionHand hand : InteractionHand.values()) { -- ItemStack itemStack = this.getItemInHand(hand); -+ itemStack = this.getItemInHand(hand); - protection = itemStack.get(DataComponents.DEATH_PROTECTION); - if (protection != null) { -+ usedHand = hand; - protectionItem = itemStack.copy(); -- itemStack.shrink(1); -+ // itemStack.shrink(1); - break; - } - } +@@ -1367,18 +_,39 @@ + ItemStack protectionItem = null; + DeathProtection protection = null; -- if (protectionItem != null) { -- if (this instanceof ServerPlayer player) { -+ final org.bukkit.inventory.EquipmentSlot handSlot = (usedHand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(usedHand) : null; -+ final EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot); -+ event.setCancelled(protectionItem == null); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ // Set death protection to null as the event was cancelled. Prevent any attempt at resurrection. -+ protection = null; -+ } else { -+ if (!itemStack.isEmpty() && protectionItem != null) { // Paper - only reduce item if actual totem was found -+ itemStack.shrink(1); -+ } -+ // Paper start - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled -+ // restore the previous behavior in that case by defaulting to vanilla's totem of undying effect -+ if (protection == null) { -+ protection = DeathProtection.TOTEM_OF_UNDYING; -+ } -+ // Paper end - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled -+ if (protectionItem != null && this instanceof final ServerPlayer player) { -+ // CraftBukkit end - player.awardStat(Stats.ITEM_USED.get(protectionItem.getItem())); - CriteriaTriggers.USED_TOTEM.trigger(player, protectionItem); - protectionItem.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); -@@ -1420,6 +1816,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin ++ // CraftBukkit start ++ InteractionHand usedHand = null; ++ ItemStack itemStack = ItemStack.EMPTY; + for (InteractionHand hand : InteractionHand.values()) { +- ItemStack itemStack = this.getItemInHand(hand); ++ itemStack = this.getItemInHand(hand); + protection = itemStack.get(DataComponents.DEATH_PROTECTION); + if (protection != null) { ++ usedHand = hand; + protectionItem = itemStack.copy(); ++ // itemStack.shrink(1); ++ break; ++ } ++ } ++ ++ final org.bukkit.inventory.EquipmentSlot handSlot = (usedHand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(usedHand) : null; ++ final EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot); ++ event.setCancelled(protectionItem == null); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ // Set death protection to null as the event was cancelled. Prevent any attempt at resurrection. ++ protection = null; ++ } else { ++ if (!itemStack.isEmpty() && protectionItem != null) { // Paper - only reduce item if actual totem was found + itemStack.shrink(1); +- break; +- } +- } +- +- if (protectionItem != null) { +- if (this instanceof ServerPlayer player) { ++ } ++ // Paper start - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled ++ // restore the previous behavior in that case by defaulting to vanilla's totem of undying effect ++ if (protection == null) { ++ protection = DeathProtection.TOTEM_OF_UNDYING; ++ } ++ // Paper end - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled ++ if (protectionItem != null && this instanceof final ServerPlayer player) { ++ // CraftBukkit end + player.awardStat(Stats.ITEM_USED.get(protectionItem.getItem())); + CriteriaTriggers.USED_TOTEM.trigger(player, protectionItem); + protectionItem.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); +@@ -1428,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity sourceEntity = source.getEntity(); LivingEntity killer = this.getKillCredit(); @@ -810,7 +805,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (killer != null) { killer.awardKillScore(this, source); } -@@ -1430,68 +1827,147 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1438,68 +_,147 @@ this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { @@ -956,6 +951,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().get(GameRules.MOB_DROPS) )) { - ExperienceOrb.award(level, this.position(), this.getExperienceReward(level, killer)); +- } + return this.getExperienceReward(level, killer); // CraftBukkit + } + return 0; // CraftBukkit @@ -966,12 +962,12 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time + ExperienceOrb.awardWithDirection(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, this.expToDrop, this instanceof ServerPlayer ? org.bukkit.entity.ExperienceOrb.SpawnReason.PLAYER_DEATH : org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, entity, this); // Paper + this.expToDrop = 0; - } ++ } + // CraftBukkit end } protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { -@@ -1603,9 +2079,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1611,9 +_,14 @@ } public void knockback(double power, double xd, double zd) { @@ -988,7 +984,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b Vec3 deltaMovement = this.getDeltaMovement(); while (xd * xd + zd * zd < 1.0E-5F) { -@@ -1614,11 +2095,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1622,11 +_,22 @@ } Vec3 deltaVector = new Vec3(xd, 0.0, zd).normalize().scale(power); @@ -1012,7 +1008,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } -@@ -1709,7 +2201,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1717,7 +_,7 @@ @Override public boolean isAlive() { @@ -1021,7 +1017,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public boolean isLookingAtMe( -@@ -1764,10 +2256,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1772,10 +_,15 @@ boolean damaged = super.causeFallDamage(effectiveFallDistance, damageModifier, damageSource); int dmg = this.calculateFallDamage(effectiveFallDistance, damageModifier); if (dmg > 0) { @@ -1038,7 +1034,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b return true; } else { return damaged; -@@ -1865,7 +2362,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1873,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(final DamageSource damageSource, float damage) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1047,18 +1043,18 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b damage = CombatRules.getDamageAfterAbsorb( this, damage, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1878,7 +2375,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { +@@ -1887,7 +_,8 @@ return damage; - } else { -- if (this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { -+ // CraftBukkit - Moved to handleEntityDamage(DamageSource, float) -+ if (false && this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { - int absorbValue = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; - int absorb = 25 - absorbValue; - float v = damage * absorb; -@@ -1915,24 +2413,181 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } + +- if (this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { ++ // CraftBukkit - Moved to handleEntityDamage(DamageSource, float) ++ if (false && this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + int absorbValue = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; + int absorb = 25 - absorbValue; + float v = damage * absorb; +@@ -1925,25 +_,181 @@ + return damage; } - protected void actuallyHurt(final ServerLevel level, final DamageSource source, float dmg) { @@ -1144,9 +1140,10 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (!this.isInvulnerableTo(level, source)) { - dmg = this.getDamageAfterArmorAbsorb(source, dmg); - dmg = this.getDamageAfterMagicAbsorb(source, dmg); -- float var10 = Math.max(dmg - this.getAbsorptionAmount(), 0.0F); -- this.setAbsorptionAmount(this.getAbsorptionAmount() - (dmg - var10)); -- float absorbedDamage = dmg - var10; +- float originalDamage = dmg; +- dmg = Math.max(dmg - this.getAbsorptionAmount(), 0.0F); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - (originalDamage - dmg)); +- float absorbedDamage = originalDamage - dmg; + if (event.isCancelled()) { + return false; + } @@ -1201,10 +1198,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b serverPlayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(absorbedDamage * 10.0F)); } -- if (var10 != 0.0F) { -- this.getCombatTracker().recordDamage(source, var10); -- this.setHealth(this.getHealth() - var10); -- this.setAbsorptionAmount(this.getAbsorptionAmount() - var10); +- if (dmg != 0.0F) { + // CraftBukkit start + if (dmg > 0 || !human) { + if (human) { @@ -1215,8 +1209,9 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + } + } + // CraftBukkit end -+ this.getCombatTracker().recordDamage(source, dmg); -+ this.setHealth(this.getHealth() - dmg); + this.getCombatTracker().recordDamage(source, dmg); + this.setHealth(this.getHealth() - dmg); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg); + // CraftBukkit start + if (!human) { + this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg); @@ -1249,7 +1244,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public CombatTracker getCombatTracker() { -@@ -1960,7 +2615,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1971,7 +_,17 @@ } public final void setArrowCount(final int count) { @@ -1268,7 +1263,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public final int getStingerCount() { -@@ -2010,7 +2675,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2021,7 +_,7 @@ @Override public void handleDamageEvent(final DamageSource source) { this.walkAnimation.setSpeed(1.5F); @@ -1277,7 +1272,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(source); -@@ -2139,7 +2804,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2150,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1286,7 +1281,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } protected void updateSwingTime() { -@@ -2246,7 +2911,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2257,7 +_,13 @@ } public void setItemSlot(final EquipmentSlot slot, final ItemStack itemStack) { @@ -1301,7 +1296,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public float getArmorCoverPercentage() { -@@ -2339,14 +3010,27 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2350,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1322,14 +1317,14 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + } + } + // Paper end - Prevent excessive velocity through repeated crits - this.setDeltaMovement(movement.x, Math.max((double)jumpPower, movement.y), movement.z); + this.setDeltaMovement(movement.x, Math.max(jumpPower, movement.y), movement.z); if (this.isSprinting()) { float angle = this.getYRot() * Mth.DEG_TO_RAD; + if (canCrit) // Paper - Prevent excessive velocity through repeated crits this.addDeltaMovement(new Vec3(-Mth.sin(angle) * 0.2, 0.0, Mth.cos(angle) * 0.2)); } -@@ -2533,8 +3217,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2544,8 +_,10 @@ } public void stopFallFlying() { @@ -1340,7 +1335,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } private Vec3 updateFallFlyingMovement(Vec3 movement) { -@@ -2678,7 +3364,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2689,7 +_,7 @@ public void causeExtraKnockback(final Entity target, final float knockback, final Vec3 oldMovement) { if (knockback > 0.0F && target instanceof LivingEntity livingTarget) { @@ -1349,7 +1344,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2754,37 +3440,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2765,37 +_,15 @@ profiler.pop(); profiler.push("rangeChecks"); @@ -1360,19 +1355,15 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b - while (this.getYRot() - this.yRotO >= 180.0F) { - this.yRotO += 360.0F; - } -+ // Paper start - stop large pitch and yaw changes from crashing the server -+ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; - +- - while (this.yBodyRot - this.yBodyRotO < -180.0F) { - this.yBodyRotO -= 360.0F; - } -+ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; - +- - while (this.yBodyRot - this.yBodyRotO >= 180.0F) { - this.yBodyRotO += 360.0F; - } -+ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; - +- - while (this.getXRot() - this.xRotO < -180.0F) { - this.xRotO -= 360.0F; - } @@ -1388,12 +1379,19 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b - while (this.yHeadRot - this.yHeadRotO >= 180.0F) { - this.yHeadRotO += 360.0F; - } ++ // Paper start - stop large pitch and yaw changes from crashing the server ++ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; ++ ++ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; ++ ++ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; ++ + this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; + // Paper end - stop large pitch and yaw changes from crashing the server profiler.pop(); if (this.isFallFlying()) { -@@ -2865,6 +3529,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2877,6 +_,11 @@ } public void onAttack() { @@ -1405,7 +1403,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public void detectEquipmentUpdates() { -@@ -2879,16 +3548,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2891,16 +_,39 @@ private @Nullable Map collectEquipmentChanges() { Map changedItems = null; @@ -1445,7 +1443,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b AttributeMap attributes = this.getAttributes(); if (!previous.isEmpty()) { this.stopLocationBasedEffects(previous, slot, attributes); -@@ -2913,6 +3605,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2925,6 +_,8 @@ } } } @@ -1454,7 +1452,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } return changedItems; -@@ -2944,7 +3638,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2956,7 +_,7 @@ itemsToSend.add(Pair.of(slot, newItemToStore)); this.lastEquipmentItems.put(slot, newItemToStore); }); @@ -1463,7 +1461,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } protected void tickHeadTurn(final float yBodyRotT) { -@@ -3030,8 +3724,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3042,8 +_,10 @@ if (!inWaterAndHasFluidHeight || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || inWaterAndHasFluidHeight && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1474,7 +1472,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -3072,7 +3768,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3084,7 +_,7 @@ profiler.pop(); if (this.level() instanceof ServerLevel serverLevel) { profiler.push("freezing"); @@ -1483,7 +1481,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -3093,6 +3789,20 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3105,6 +_,20 @@ this.pushEntities(); profiler.pop(); @@ -1504,7 +1502,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3115,6 +3825,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3127,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1512,7 +1510,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3151,10 +3862,25 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3163,10 +_,25 @@ } protected void pushEntities() { @@ -1539,24 +1537,24 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (maxCramming > 0 && pushableEntities.size() > maxCramming - 1 && this.random.nextInt(4) == 0) { int count = 0; -@@ -3170,7 +3896,16 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3182,7 +_,16 @@ } } + // Paper start - Cap entity collisions + this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); - for (Entity entityx : pushableEntities) { + for (Entity entity : pushableEntities) { + if (this.numCollisions >= this.level().paperConfig().collisions.maxEntityCollisions) { + break; + } + -+ entityx.numCollisions++; ++ entity.numCollisions++; + this.numCollisions++; + // Paper end - Cap entity collisions - this.doPush(entityx); + this.doPush(entity); } } -@@ -3179,16 +3914,32 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3191,16 +_,32 @@ protected void checkAutoSpinAttack(final AABB old, final AABB current) { AABB minmax = old.minmax(current); List entities = this.level().getEntities(this, minmax); @@ -1590,7 +1588,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.autoSpinAttackTicks = 0; } -@@ -3211,10 +3962,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3223,10 +_,10 @@ } @Override @@ -1604,7 +1602,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.dismountVehicle(oldVehicle); } } -@@ -3241,7 +3992,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3253,7 +_,7 @@ } public void onItemPickup(final ItemEntity entity) { @@ -1613,7 +1611,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (thrower instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)thrower, entity.getItem(), this); } -@@ -3253,7 +4004,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3265,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1622,17 +1620,17 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } -@@ -3269,7 +4020,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - } else { - Vec3 from = new Vec3(this.getX(), this.getEyeY(), this.getZ()); - Vec3 to = new Vec3(target.getX(), eyeHeight, target.getZ()); -- return !(to.distanceTo(from) > 128.0) -+ // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists -+ return !(to.distanceToSqr(from) > Mth.square(128.0)) // Paper - Perf: Use distance squared - && this.level().clip(new ClipContext(from, to, blockCollidingContext, fluidCollidingContext, this)).getType() == HitResult.Type.MISS; - } +@@ -3282,7 +_,8 @@ + + Vec3 from = new Vec3(this.getX(), this.getEyeY(), this.getZ()); + Vec3 to = new Vec3(target.getX(), eyeHeight, target.getZ()); +- return !(to.distanceTo(from) > 128.0) ++ // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists ++ return !(to.distanceToSqr(from) > Mth.square(128.0)) // Paper - Perf: Use distance squared + && this.level().clip(new ClipContext(from, to, blockCollidingContext, fluidCollidingContext, this)).getType() == HitResult.Type.MISS; } -@@ -3290,14 +4042,28 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + +@@ -3302,13 +_,27 @@ @Override public boolean isPickable() { @@ -1644,9 +1642,10 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b @Override public boolean isPushable() { - return this.isAlive() && !this.isSpectator() && !this.onClimbable(); +- } + return this.isCollidable(this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule); - } - ++ } ++ + @Override + public boolean isCollidable(boolean ignoreClimbing) { + return this.isAlive() && !this.isSpectator() && (ignoreClimbing || !this.onClimbable()) && this.collides; // CraftBukkit @@ -1659,11 +1658,10 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b + return this.isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); + } + // CraftBukkit end -+ + @Override public float getYHeadRot() { - return this.yHeadRot; -@@ -3327,7 +4093,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3339,7 +_,7 @@ } public final void setAbsorptionAmount(final float absorptionAmount) { @@ -1672,7 +1670,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } protected void internalSetAbsorptionAmount(final float absorptionAmount) { -@@ -3354,6 +4120,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3366,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1688,7 +1686,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3401,7 +4176,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3413,7 +_,12 @@ protected void updateUsingItem(final ItemStack useItem) { useItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1702,7 +1700,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.completeUsingItem(); } } -@@ -3427,10 +4207,19 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3439,10 +_,19 @@ } public void startUsingItem(final InteractionHand hand) { @@ -1724,7 +1722,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3457,7 +4246,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3469,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1736,7 +1734,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } } } -@@ -3500,9 +4292,41 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3512,9 +_,41 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1779,7 +1777,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } this.stopUsingItem(); -@@ -3534,6 +4358,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3546,6 +_,7 @@ ItemStack itemInUsedHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInUsedHand, this.useItem)) { this.useItem = itemInUsedHand; @@ -1787,7 +1785,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3554,7 +4379,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3566,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1799,8 +1797,8 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b } public boolean isBlocking() { -@@ -3577,6 +4405,60 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - } +@@ -3589,6 +_,60 @@ + return null; } + // CraftBukkit start @@ -1860,7 +1858,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3595,6 +4477,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3607,6 +_,12 @@ } public boolean randomTeleport(final double xx, final double yy, final double zz, final boolean showParticles) { @@ -1873,7 +1871,7 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b double xo = this.getX(); double yo = this.getY(); double zo = this.getZ(); -@@ -3617,16 +4505,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3629,16 +_,39 @@ } if (landed) { @@ -1913,15 +1911,15 @@ index 0797118778ff3c04701038a746612bb7aed5be9c..8b0abe9c7a3907419f6e4d55ea22fb9b - return false; + // this.teleportTo(xo, yo, zo); // CraftBukkit - already set the location back + return Optional.of(false); // CraftBukkit - } else { - if (showParticles) { - level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3636,7 +4547,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - pathfinderMob.getNavigation().stop(); - } + } -- return true; -+ return Optional.of(true); // CraftBukkit + if (showParticles) { +@@ -3649,7 +_,7 @@ + pathfinderMob.getNavigation().stop(); } + +- return true; ++ return Optional.of(true); // CraftBukkit } + public boolean isAffectedByPotions() { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch similarity index 81% rename from paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index d266713e7b4f..d677fa937ba7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c45d39fc2 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -92,6 +92,14 @@ import net.minecraft.world.phys.Vec3; +@@ -92,6 +_,14 @@ import net.minecraft.world.ticks.ContainerSingleItem; import org.jspecify.annotations.Nullable; @@ -23,7 +15,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c public abstract class Mob extends LivingEntity implements Targeting, EquipmentUser, Leashable { private static final EntityDataAccessor DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE); private static final int MOB_FLAG_NO_AI = 1; -@@ -127,6 +135,7 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -127,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; @@ -31,7 +23,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c public GoalSelector targetSelector; private @Nullable LivingEntity target; private final Sensing sensing; -@@ -139,6 +148,8 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -139,6 +_,8 @@ private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -40,7 +32,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c protected Mob(final EntityType type, final Level level) { super(type, level); -@@ -244,7 +255,44 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -244,7 +_,44 @@ } public void setTarget(final @Nullable LivingEntity target) { @@ -86,7 +78,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } @Override -@@ -383,13 +431,27 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -383,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -116,7 +108,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,6 +463,13 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -401,6 +_,13 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -130,7 +122,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } @Override -@@ -465,6 +534,11 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -465,6 +_,11 @@ for (ItemEntity entity : this.level() .getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(pickupReach.getX(), pickupReach.getY(), pickupReach.getZ()))) { if (!entity.isRemoved() && !entity.getItem().isEmpty() && !entity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, entity.getItem())) { @@ -142,7 +134,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c this.pickUpItem(serverLevel, entity); } } -@@ -515,18 +589,24 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -515,18 +_,24 @@ protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { ItemStack itemStack = entity.getItem(); @@ -169,27 +161,28 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c EquipmentSlot slot = this.getEquipmentSlotForItem(itemStack); if (!this.isEquippableInSlot(itemStack, slot)) { return ItemStack.EMPTY; -@@ -539,10 +619,18 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs - canReplace = current.isEmpty(); +@@ -539,11 +_,18 @@ + current = this.getItemBySlot(slot); + canReplace = current.isEmpty(); + } +- +- if (canReplace && this.canHoldItem(itemStack)) { ++ // CraftBukkit start ++ boolean canPickup = canReplace && this.canHoldItem(itemStack); ++ if (entity != null) { ++ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entity, 0, !canPickup).isCancelled(); ++ } ++ if (canPickup) { ++ // CraftBukkit end + double dropChance = this.dropChances.byEquipment(slot); + if (!current.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < dropChance) { ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(level, current); ++ this.forceDrops = false; // CraftBukkit } -- if (canReplace && this.canHoldItem(itemStack)) { -+ // CraftBukkit start -+ boolean canPickup = canReplace && this.canHoldItem(itemStack); -+ if (entity != null) { -+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entity, 0, !canPickup).isCancelled(); -+ } -+ if (canPickup) { -+ // CraftBukkit end - double dropChance = this.dropChances.byEquipment(slot); - if (!current.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < dropChance) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(level, current); -+ this.forceDrops = false; // CraftBukkit - } - - ItemStack toEquip = slot.limit(itemStack); -@@ -651,25 +739,38 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs + ItemStack toEquip = slot.limit(itemStack); +@@ -651,25 +_,38 @@ return this.isPassenger() || this.isLeashed(); } @@ -241,7 +234,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c this.noActionTime = 0; } } -@@ -681,6 +782,15 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -681,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -257,7 +250,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c ProfilerFiller profiler = Profiler.get(); profiler.push("sensing"); this.sensing.tick(); -@@ -859,14 +969,69 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -855,14 +_,69 @@ public boolean stillValid(final Player player) { return player.getVehicle() == Mob.this || player.isWithinEntityInteractionRange(Mob.this, 4.0); } @@ -327,7 +320,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c ItemStack itemStack = this.getItemBySlot(slot); float dropChance = this.dropChances.byEquipment(slot); if (dropChance != 0.0F) { -@@ -886,7 +1051,13 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -882,7 +_,13 @@ } this.spawnAtLocation(level, itemStack); @@ -341,7 +334,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } } } -@@ -910,7 +1081,9 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -906,7 +_,9 @@ slotsPreventedFromDropping.add(slot); } else if (this.dropChances.isPreserved(slot)) { this.setItemSlot(slot, ItemStack.EMPTY); @@ -351,7 +344,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } } } -@@ -1210,6 +1383,22 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -1206,6 +_,22 @@ final EntitySpawnReason spawnReason, final ConversionParams.AfterConversion afterConversion ) { @@ -373,35 +366,35 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c + // Paper end - entity zap event - allow cancellation of conversion post creation if (this.isRemoved()) { return null; - } else { -@@ -1218,13 +1407,23 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs - return null; - } else { - params.type().convert(this, newMob, params); -- afterConversion.finalizeConversion(newMob); -+ if (!afterConversion.finalizeConversionOrCancel(newMob)) return null; // Paper - entity zap event - return null if conversion was cancelled -+ // CraftBukkit start -+ if (transformReason == null) { -+ // Special handling for slime split and pig lightning -+ return newMob; -+ } + } +@@ -1216,13 +_,23 @@ + } + + params.type().convert(this, newMob, params); +- afterConversion.finalizeConversion(newMob); ++ if (!afterConversion.finalizeConversionOrCancel(newMob)) return null; // Paper - entity zap event - return null if conversion was cancelled ++ // CraftBukkit start ++ if (transformReason == null) { ++ // Special handling for slime split and pig lightning ++ return newMob; ++ } + -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, newMob, transformReason).isCancelled()) { -+ return null; -+ } -+ // CraftBukkit end - if (this.level() instanceof ServerLevel serverLevel) { -- serverLevel.addFreshEntity(newMob); -+ serverLevel.addFreshEntity(newMob, creatureSpawnReason); // CraftBukkit - } ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, newMob, transformReason).isCancelled()) { ++ return null; ++ } ++ // CraftBukkit end + if (this.level() instanceof ServerLevel serverLevel) { +- serverLevel.addFreshEntity(newMob); ++ serverLevel.addFreshEntity(newMob, creatureSpawnReason); // CraftBukkit + } - if (params.type().shouldDiscardAfterConversion()) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause - } + if (params.type().shouldDiscardAfterConversion()) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause + } - return newMob; -@@ -1235,7 +1434,17 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs + return newMob; +@@ -1231,7 +_,17 @@ public @Nullable T convertTo( final EntityType entityType, final ConversionParams params, final ConversionParams.AfterConversion afterConversion ) { @@ -420,7 +413,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } @Override -@@ -1276,7 +1485,17 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -1272,7 +_,17 @@ public boolean startRiding(final Entity entity, final boolean force, final boolean sendEventAndTriggers) { boolean result = super.startRiding(entity, force, sendEventAndTriggers); if (result && this.isLeashed()) { @@ -439,7 +432,7 @@ index 582db701c7021502a0393f23933bae46260bf8d3..c7c53ef16e104ebc48aeb8719783fb4c } return result; -@@ -1439,7 +1658,7 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs +@@ -1435,7 +_,7 @@ Set availableGoals = this.goalSelector.getAvailableGoals(); List goalInfo = new ArrayList<>(availableGoals.size()); availableGoals.forEach( diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch similarity index 61% rename from paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch index 0be7554a7a7f..f3b22e359887 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/TamableAnimal.java b/net/minecraft/world/entity/TamableAnimal.java -index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd350f1c5b 100644 --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -80,7 +80,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { +@@ -79,7 +_,7 @@ } this.orderedToSit = input.getBooleanOr("Sitting", false); @@ -17,7 +9,7 @@ index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd } @Override -@@ -136,7 +136,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { +@@ -135,7 +_,7 @@ protected void feed(final Player player, final InteractionHand hand, final ItemStack itemStack, final float healingFactor, final float defaultHeal) { FoodProperties foodProperties = itemStack.get(DataComponents.FOOD); this.usePlayerItem(player, hand, itemStack); @@ -26,7 +18,7 @@ index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd this.playEatingSound(); } -@@ -145,6 +145,13 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { +@@ -144,6 +_,13 @@ } public void setInSittingPose(final boolean value) { @@ -40,7 +32,7 @@ index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd byte current = this.entityData.get(DATA_FLAGS_ID); if (value) { this.entityData.set(DATA_FLAGS_ID, (byte)(current | 1)); -@@ -225,7 +232,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { +@@ -224,7 +_,12 @@ if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof ServerPlayer serverPlayer) { @@ -54,19 +46,19 @@ index b6b570eae32f435fc9d83c0e0c1b945e668fb9f2..1e8e68128092bfc7f33d3e789058f7fd } super.die(source); -@@ -268,7 +280,14 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { - if (!this.canTeleportTo(new BlockPos(x, y, z))) { +@@ -268,7 +_,14 @@ return false; - } else { -- this.snapTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot()); -+ // CraftBukkit start -+ org.bukkit.event.entity.EntityTeleportEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, x + 0.5, y, z + 0.5); -+ if (event.isCancelled() || event.getTo() == null) { -+ return false; -+ } -+ org.bukkit.Location to = event.getTo(); -+ this.snapTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); -+ // CraftBukkit end - this.navigation.stop(); - return true; } + +- this.snapTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot()); ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityTeleportEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, x + 0.5, y, z + 0.5); ++ if (event.isCancelled() || event.getTo() == null) { ++ return false; ++ } ++ org.bukkit.Location to = event.getTo(); ++ this.snapTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ // CraftBukkit end + this.navigation.stop(); + return true; + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch similarity index 54% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index 60fbb39d56ef..36798fdc2f68 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -1,18 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/village/VillageSiege.java b/net/minecraft/world/entity/ai/village/VillageSiege.java -index e3aa405f3b5434576c40e7877b6ba0fb6527ec50..cfe8961610c3972e8dca68cf67281a20e6c4bc4e 100644 --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -102,11 +102,12 @@ public class VillageSiege implements CustomSpawner { +@@ -102,11 +_,12 @@ zombie.finalizeSpawn(level, level.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); - } catch (Exception var5) { - LOGGER.warn("Failed to create zombie for village siege at {}", spawnPos, var5); -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var5); // Paper - ServerExceptionEvent + } catch (Exception e) { + LOGGER.warn("Failed to create zombie for village siege at {}", spawnPos, e); ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(e); // Paper - ServerExceptionEvent return; } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch similarity index 65% rename from paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index 8fc4947e29da..3a1e67502bbd 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java -index 08ee116f06c6e9710a552a9d610437a00c5c3c09..c2831ffb9a4765a628f8f005dc1218405301e926 100644 --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -84,7 +84,7 @@ public class Bat extends AmbientCreature { +@@ -84,7 +_,7 @@ } @Override @@ -17,7 +9,7 @@ index 08ee116f06c6e9710a552a9d610437a00c5c3c09..c2831ffb9a4765a628f8f005dc121840 return false; } -@@ -138,13 +138,13 @@ public class Bat extends AmbientCreature { +@@ -138,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -33,7 +25,7 @@ index 08ee116f06c6e9710a552a9d610437a00c5c3c09..c2831ffb9a4765a628f8f005dc121840 this.setResting(false); if (!isSilent) { level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, pos, 0); -@@ -175,7 +175,7 @@ public class Bat extends AmbientCreature { +@@ -175,7 +_,7 @@ float rotDiff = Mth.wrapDegrees(yRotD - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + rotDiff); @@ -42,12 +34,12 @@ index 08ee116f06c6e9710a552a9d610437a00c5c3c09..c2831ffb9a4765a628f8f005dc121840 this.setResting(true); } } -@@ -200,7 +200,7 @@ public class Bat extends AmbientCreature { - if (this.isInvulnerableTo(level, source)) { +@@ -201,7 +_,7 @@ return false; - } else { -- if (this.isResting()) { -+ if (this.isResting() && org.bukkit.craftbukkit.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent - this.setResting(false); - } + } + +- if (this.isResting()) { ++ if (this.isResting() && org.bukkit.craftbukkit.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(false); + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index 7b2883451e4a..baad5b92c99b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,22 +1,14 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/wolf/Wolf.java b/net/minecraft/world/entity/animal/wolf/Wolf.java -index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce754ecfe3 100644 --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -396,16 +396,18 @@ public class Wolf extends TamableAnimal implements NeutralMob { - if (this.isInvulnerableTo(level, source)) { +@@ -396,15 +_,18 @@ return false; - } else { -+ if (!super.hurtServer(level, source, damage)) return false; // CraftBukkit - this.setOrderedToSit(false); -- return super.hurtServer(level, source, damage); -+ return true; // CraftBukkit } + ++ if (!super.hurtServer(level, source, damage)) return false; // CraftBukkit + this.setOrderedToSit(false); +- return super.hurtServer(level, source, damage); ++ return true; // CraftBukkit ++ } @Override @@ -30,7 +22,7 @@ index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce ItemStack armorBefore = this.getBodyArmorItem(); int damageBefore = armorBefore.getDamageValue(); int maxDamage = armorBefore.getMaxDamage(); -@@ -417,6 +419,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -416,6 +_,7 @@ ); } } @@ -38,7 +30,7 @@ index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce } private boolean canArmorAbsorb(final DamageSource source) { -@@ -427,7 +430,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -426,7 +_,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -47,7 +39,7 @@ index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -477,7 +480,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -476,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -56,7 +48,7 @@ index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce return InteractionResult.SUCCESS.withoutItem(); } -@@ -486,6 +489,25 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -485,6 +_,25 @@ DyeColor color = itemStack.get(DataComponents.DYE); if (color != null && color != this.getCollarColor()) { @@ -82,7 +74,7 @@ index fe27384253ab05220eee70e75371a70ca8da7929..ff518efcfeaa660020d051c3427b90ce this.setCollarColor(color); itemStack.consume(1, player); return InteractionResult.SUCCESS; -@@ -500,7 +522,7 @@ public class Wolf extends TamableAnimal implements NeutralMob { +@@ -499,7 +_,7 @@ } private void tryToTame(final Player player) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch similarity index 63% rename from paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index e67bad1d0b1b..b9d27d8405fa 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2bf84f3a75 100644 --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -86,6 +86,7 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -86,6 +_,7 @@ public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600; private List stored = Lists.newArrayList(); public @Nullable BlockPos savedFlowerPos; @@ -16,7 +8,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b public BeehiveBlockEntity(final BlockPos worldPosition, final BlockState blockState) { super(BlockEntityType.BEEHIVE, worldPosition, blockState); -@@ -119,16 +120,17 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -119,16 +_,17 @@ } public boolean isFull() { @@ -36,7 +28,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b } else { bee.setStayOutOfHiveCountdown(400); } -@@ -138,10 +140,15 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -138,10 +_,15 @@ } private List releaseAllOccupants(final BlockState state, final BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { @@ -53,7 +45,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b ); if (!spawned.isEmpty()) { super.setChanged(); -@@ -155,6 +162,12 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -155,6 +_,12 @@ return this.stored.size(); } @@ -66,7 +58,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b public static int getHoneyLevel(final BlockState blockState) { return blockState.getValue(BeehiveBlock.HONEY_LEVEL); } -@@ -165,7 +178,16 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -165,7 +_,16 @@ } public void addOccupant(final Bee bee) { @@ -84,7 +76,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b bee.stopRiding(); bee.ejectPassengers(); bee.dropLeash(); -@@ -190,7 +212,7 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -180,7 +_,7 @@ this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -93,7 +85,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b super.setChanged(); } } -@@ -199,6 +221,12 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -189,6 +_,12 @@ this.stored.add(new BeehiveBlockEntity.BeeData(occupant)); } @@ -106,7 +98,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b private static boolean releaseOccupant( final Level level, final BlockPos blockPos, -@@ -207,8 +235,9 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -197,8 +_,9 @@ final @Nullable List spawned, final BeehiveBlockEntity.BeeReleaseStatus releaseStatus, final @Nullable BlockPos savedFlowerPos @@ -116,62 +108,62 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b + if (!force && level.environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, blockPos) // CraftBukkit && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { return false; - } else { -@@ -220,6 +249,17 @@ public class BeehiveBlockEntity extends BlockEntity { - } else { - Entity entity = beeData.createEntity(level, blockPos); - if (entity != null) { -+ // CraftBukkit start -+ if (entity instanceof Bee) { -+ float bbWidth = entity.getBbWidth(); -+ double delta = frontBlocked ? 0.0 : 0.55 + bbWidth / 2.0F; -+ double spawnX = blockPos.getX() + 0.5 + delta * facing.getStepX(); -+ double spawnY = blockPos.getY() + 0.5 - entity.getBbHeight() / 2.0F; -+ double spawnZ = blockPos.getZ() + 0.5 + delta * facing.getStepZ(); -+ entity.snapTo(spawnX, spawnY, spawnZ, entity.getYRot(), entity.getXRot()); -+ } -+ if (!level.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below -+ // CraftBukkit end - if (entity instanceof Bee bee) { - RandomSource random = level.getRandom(); - if (savedFlowerPos != null && !bee.hasSavedFlowerPos() && random.nextFloat() < 0.9F) { -@@ -236,7 +276,13 @@ public class BeehiveBlockEntity extends BlockEntity { - levelIncrease--; - } - -- level.setBlockAndUpdate(blockPos, state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + levelIncrease)); -+ // Paper start - Fire EntityChangeBlockEvent in more places -+ BlockState newBlockState = state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + levelIncrease); -+ -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos, newBlockState)) { -+ level.setBlockAndUpdate(blockPos, newBlockState); -+ } -+ // Paper end - Fire EntityChangeBlockEvent in more places - } + } +@@ -212,6 +_,17 @@ + + Entity entity = beeData.createEntity(level, blockPos); + if (entity != null) { ++ // CraftBukkit start ++ if (entity instanceof Bee) { ++ float bbWidth = entity.getBbWidth(); ++ double delta = frontBlocked ? 0.0 : 0.55 + bbWidth / 2.0F; ++ double spawnX = blockPos.getX() + 0.5 + delta * facing.getStepX(); ++ double spawnY = blockPos.getY() + 0.5 - entity.getBbHeight() / 2.0F; ++ double spawnZ = blockPos.getZ() + 0.5 + delta * facing.getStepZ(); ++ entity.snapTo(spawnX, spawnY, spawnZ, entity.getYRot(), entity.getXRot()); ++ } ++ if (!level.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below ++ // CraftBukkit end + if (entity instanceof Bee bee) { + RandomSource random = level.getRandom(); + if (savedFlowerPos != null && !bee.hasSavedFlowerPos() && random.nextFloat() < 0.9F) { +@@ -228,7 +_,13 @@ + levelIncrease--; } - } -@@ -245,17 +291,19 @@ public class BeehiveBlockEntity extends BlockEntity { - spawned.add(bee); - } -+ /* CraftBukkit start - move up - float bbWidth = entity.getBbWidth(); - double delta = frontBlocked ? 0.0 : 0.55 + bbWidth / 2.0F; - double spawnX = blockPos.getX() + 0.5 + delta * facing.getStepX(); - double spawnY = blockPos.getY() + 0.5 - entity.getBbHeight() / 2.0F; - double spawnZ = blockPos.getZ() + 0.5 + delta * facing.getStepZ(); - entity.snapTo(spawnX, spawnY, spawnZ, entity.getYRot(), entity.getXRot()); -+ */ // CraftBukkit end +- level.setBlockAndUpdate(blockPos, state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + levelIncrease)); ++ // Paper start - Fire EntityChangeBlockEvent in more places ++ BlockState newBlockState = state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + levelIncrease); ++ ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos, newBlockState)) { ++ level.setBlockAndUpdate(blockPos, newBlockState); ++ } ++ // Paper end - Fire EntityChangeBlockEvent in more places + } } - - level.playSound(null, blockPos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1.0F, 1.0F); - level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(entity, level.getBlockState(blockPos))); -- return level.addFreshEntity(entity); -+ return true; // CraftBukkit - moved up - } else { - return false; } -@@ -283,6 +331,11 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -237,17 +_,19 @@ + spawned.add(bee); + } + ++ /* CraftBukkit start - move up + float bbWidth = entity.getBbWidth(); + double delta = frontBlocked ? 0.0 : 0.55 + bbWidth / 2.0F; + double spawnX = blockPos.getX() + 0.5 + delta * facing.getStepX(); + double spawnY = blockPos.getY() + 0.5 - entity.getBbHeight() / 2.0F; + double spawnZ = blockPos.getZ() + 0.5 + delta * facing.getStepZ(); + entity.snapTo(spawnX, spawnY, spawnZ, entity.getYRot(), entity.getXRot()); ++ */ // CraftBukkit end + } + + level.playSound(null, blockPos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1.0F, 1.0F); + level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(entity, level.getBlockState(blockPos))); +- return level.addFreshEntity(entity); ++ return true; // CraftBukkit - moved up + } else { + return false; + } +@@ -273,6 +_,11 @@ changed = true; iterator.remove(); } @@ -183,7 +175,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b } } -@@ -304,9 +357,10 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -294,9 +_,10 @@ @Override protected void loadAdditional(final ValueInput input) { super.loadAdditional(input); @@ -195,7 +187,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b } @Override -@@ -314,12 +368,13 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -304,12 +_,13 @@ super.saveAdditional(output); output.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees()); output.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); @@ -210,7 +202,7 @@ index a1a359314e0803b22c63fb649c4377e4719bef7f..62d7a44f139c28a38b14833380e2ec2b List bees = components.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees(); bees.forEach(this::storeBee); } -@@ -347,15 +402,18 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -337,15 +_,18 @@ private static class BeeData { private final BeehiveBlockEntity.Occupant occupant; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch new file mode 100644 index 000000000000..d378e5992172 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -0,0 +1,80 @@ +--- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +@@ -68,9 +_,26 @@ + } + + this.coolDownEndsAtTick = gameTime + 10L; ++ // Paper start - EntityChangeBlockEvent ++ // The vanilla logic here is *so* backwards, we'd be moving basically *all* following calls down. ++ // Instead, compute vanilla ourselves up here and just replace the below usages with our computed values for a free diff-on-change. ++ final int currentCompletionStage = this.getCompletionState(); ++ final boolean enoughBrushesToBreak = ++this.brushCount >= REQUIRED_BRUSHES_TO_BREAK; ++ final int nextCompletionStage = this.getCompletionState(); ++ final boolean differentCompletionStages = currentCompletionStage != nextCompletionStage; ++ final BlockState nextBrokenBlockState = this.getBlockState().setValue(BlockStateProperties.DUSTED, nextCompletionStage); ++ if (enoughBrushesToBreak || differentCompletionStages) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( ++ user, this.worldPosition, enoughBrushesToBreak ? this.computeTurnsTo().defaultBlockState() : nextBrokenBlockState ++ )) { ++ this.brushCount--; ++ return false; ++ } ++ } ++ // Paper end - EntityChangeBlockEvent + this.unpackLootTable(level, user, brush); +- int previousCompletionState = this.getCompletionState(); +- if (++this.brushCount >= 10) { ++ int previousCompletionState = currentCompletionStage; // Paper - EntityChangeBlockEvent - use precomputed - diff on change ++ if (enoughBrushesToBreak) { // Paper - EntityChangeBlockEvent - use precomputed - diff on change + this.brushingCompleted(level, user, brush); + return true; + } +@@ -79,7 +_,7 @@ + int completionState = this.getCompletionState(); + if (previousCompletionState != completionState) { + BlockState previousState = this.getBlockState(); +- BlockState state = previousState.setValue(BlockStateProperties.DUSTED, completionState); ++ BlockState state = nextBrokenBlockState; // Paper - EntityChangeBlockEvent - use precomputed - diff on change + level.setBlock(this.getBlockPos(), state, Block.UPDATE_ALL); + } + +@@ -118,6 +_,12 @@ + this.dropContent(level, user, brush); + BlockState blockState = this.getBlockState(); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); ++ // Paper start - EntityChangeEvent - extract result block logic ++ this.brushingCompleteUpdateBlock(this.computeTurnsTo()); ++ } ++ ++ private Block computeTurnsTo() { ++ // Paper end - EntityChangeEvent - extract result block logic + Block turnsInto; + if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { + turnsInto = brushableBlock.getTurnsInto(); +@@ -125,6 +_,12 @@ + turnsInto = Blocks.AIR; + } + ++ // Paper start - EntityChangeEvent - extract result block logic ++ return turnsInto; ++ } ++ ++ public void brushingCompleteUpdateBlock(final Block turnsInto) { ++ // Paper end - EntityChangeEvent - extract result block logic + level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); + } + +@@ -141,7 +_,12 @@ + double zo = dropPos.getZ() + 0.5 * centerRange + halfSize; + ItemEntity entity = new ItemEntity(level, xo, yo, zo, this.item.split(level.getRandom().nextInt(21) + 10)); + entity.setDeltaMovement(Vec3.ZERO); +- level.addFreshEntity(entity); ++ // CraftBukkit start ++ if (user instanceof final ServerPlayer serverPlayer) { ++ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), serverPlayer, java.util.List.of(entity)); ++ } ++ // CraftBukkit end + this.item = ItemStack.EMPTY; + } + } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch similarity index 66% rename from paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index bc76607fdbdf..c499c7bb49e5 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,17 +1,10 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/CommandBlockEntity.java b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -index 8846095f59bb5278610698280aa1006c484dc19b..9051256d40c0fd0d2edb050cd317b4cd372e4cf4 100644 --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -32,6 +32,18 @@ public class CommandBlockEntity extends BlockEntity { - Objects.requireNonNull(CommandBlockEntity.this); - } - +@@ -27,6 +_,19 @@ + private boolean auto = false; + private boolean conditionMet = false; + private final BaseCommandBlock commandBlock = new BaseCommandBlock() { ++ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { @@ -27,7 +20,7 @@ index 8846095f59bb5278610698280aa1006c484dc19b..9051256d40c0fd0d2edb050cd317b4cd @Override public void setCommand(final String command) { super.setCommand(command); -@@ -52,7 +64,7 @@ public class CommandBlockEntity extends BlockEntity { +@@ -47,7 +_,7 @@ Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, facing.toYRot()), level, diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch similarity index 70% rename from paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index 9569982384a9..c21f5d8cc865 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0eb7d26455 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -39,6 +39,40 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -39,6 +_,40 @@ private long tickedGameTime; private Direction facing; @@ -49,7 +41,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e public HopperBlockEntity(final BlockPos worldPosition, final BlockState blockState) { super(BlockEntityType.HOPPER, worldPosition, blockState); this.facing = blockState.getValue(HopperBlock.FACING); -@@ -99,7 +133,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -99,7 +_,12 @@ entity.tickedGameTime = level.getGameTime(); if (!entity.isOnCooldown()) { entity.setCooldown(0); @@ -63,66 +55,65 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e } } -@@ -120,7 +159,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - } +@@ -121,7 +_,7 @@ + } - if (changed) { -- entity.setCooldown(8); -+ entity.setCooldown(level.spigotConfig.hopperTransfer); // Spigot - setChanged(level, pos, state); - return true; - } -@@ -153,14 +192,47 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - ItemStack itemStack = self.getItem(slot); - if (!itemStack.isEmpty()) { - int originalCount = itemStack.getCount(); -- ItemStack result = addItem(self, container, self.removeItem(slot, 1), direction); -+ // CraftBukkit start - Call event when pushing items into other inventories -+ ItemStack original = itemStack.copy(); -+ org.bukkit.craftbukkit.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror( -+ self.removeItem(slot, level.spigotConfig.hopperAmount) -+ ); // Spigot -+ -+ org.bukkit.inventory.Inventory destinationInventory; -+ // Have to special case large chests as they work oddly -+ if (container instanceof final net.minecraft.world.CompoundContainer compoundContainer) { -+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); -+ } else if (container.getOwner() != null) { -+ destinationInventory = container.getOwner().getInventory(); -+ } else { -+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventory(container); -+ } + if (changed) { +- entity.setCooldown(8); ++ entity.setCooldown(level.spigotConfig.hopperTransfer); // Spigot + setChanged(level, pos, state); + return true; + } +@@ -155,14 +_,46 @@ + ItemStack itemStack = self.getItem(slot); + if (!itemStack.isEmpty()) { + int originalCount = itemStack.getCount(); +- ItemStack result = addItem(self, container, self.removeItem(slot, 1), direction); ++ // CraftBukkit start - Call event when pushing items into other inventories ++ ItemStack original = itemStack.copy(); ++ org.bukkit.craftbukkit.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror( ++ self.removeItem(slot, level.spigotConfig.hopperAmount) ++ ); // Spigot + -+ org.bukkit.event.inventory.InventoryMoveItemEvent event = new org.bukkit.event.inventory.InventoryMoveItemEvent( -+ self.getOwner().getInventory(), -+ oitemstack, -+ destinationInventory, -+ true -+ ); -+ if (!event.callEvent()) { -+ self.setItem(slot, original); -+ self.setCooldown(level.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot -+ return false; -+ } -+ int origCount = event.getItem().getAmount(); // Spigot -+ ItemStack result = HopperBlockEntity.addItem(self, container, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction); -+ // CraftBukkit end ++ org.bukkit.inventory.Inventory destinationInventory; ++ // Have to special case large chests as they work oddly ++ if (container instanceof final net.minecraft.world.CompoundContainer compoundContainer) { ++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); ++ } else if (container.getOwner() != null) { ++ destinationInventory = container.getOwner().getInventory(); ++ } else { ++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventory(container); ++ } + - if (result.isEmpty()) { - container.setChanged(); - return true; - } ++ org.bukkit.event.inventory.InventoryMoveItemEvent event = new org.bukkit.event.inventory.InventoryMoveItemEvent( ++ self.getOwner().getInventory(), ++ oitemstack, ++ destinationInventory, ++ true ++ ); ++ if (!event.callEvent()) { ++ self.setItem(slot, original); ++ self.setCooldown(level.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot ++ return false; ++ } ++ int origCount = event.getItem().getAmount(); // Spigot ++ ItemStack result = HopperBlockEntity.addItem(self, container, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction); ++ // CraftBukkit end + if (result.isEmpty()) { + container.setChanged(); + return true; + } - itemStack.setCount(originalCount); -- if (originalCount == 1) { -+ // Spigot start -+ itemStack.shrink(origCount - result.getCount()); -+ if (originalCount <= level.spigotConfig.hopperAmount) { -+ // Spigot end - self.setItem(slot, itemStack); - } - } -@@ -223,7 +295,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + itemStack.setCount(originalCount); +- if (originalCount == 1) { ++ // Spigot start ++ itemStack.shrink(origCount - result.getCount()); ++ if (originalCount <= level.spigotConfig.hopperAmount) { ++ // Spigot end + self.setItem(slot, itemStack); + } + } +@@ -223,7 +_,7 @@ Direction direction = Direction.DOWN; for (int slot : getSlots(container, direction)) { @@ -131,7 +122,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e return true; } } -@@ -245,18 +317,55 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -245,18 +_,55 @@ } } @@ -190,7 +181,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e container.setItem(slot, itemStack); } } -@@ -266,12 +375,20 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -266,12 +_,20 @@ public static boolean addItem(final Container container, final ItemEntity entity) { boolean changed = false; @@ -212,7 +203,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e } else { entity.setItem(result); } -@@ -317,11 +434,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -317,11 +_,18 @@ boolean success = false; boolean wasEmpty = container.isEmpty(); if (current.isEmpty()) { @@ -233,7 +224,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e int count = Math.min(itemStack.getCount(), space); itemStack.shrink(count); current.grow(count); -@@ -335,7 +459,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -335,7 +_,7 @@ skipTickCount = 1; } @@ -242,10 +233,11 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e } container.setChanged(); -@@ -345,12 +469,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -344,13 +_,57 @@ + return itemStack; } - ++ + // CraftBukkit start + private static @Nullable Container runHopperInventorySearchEvent( + Container container, @@ -263,7 +255,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e + return (event.getInventory() != null) ? ((org.bukkit.craftbukkit.inventory.CraftInventory) event.getInventory()).getInventory() : null; + } + // CraftBukkit end -+ + private static @Nullable Container getAttachedContainer(final Level level, final BlockPos blockPos, final HopperBlockEntity self) { - return getContainerAt(level, blockPos.relative(self.facing)); + // Paper start @@ -301,7 +293,7 @@ index dabeb8a17da029a678d0d714cc61ba0f675fb2cd..0703e50ca36fbc084ed06811678efd0e } public static List getItemsAtAndAbove(final Level level, final Hopper hopper) { -@@ -374,6 +542,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -374,6 +_,7 @@ } private static @Nullable Container getBlockContainer(final Level level, final BlockPos pos, final BlockState state) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch similarity index 82% rename from paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index eb136e23f409..06c6f167d4d7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/LecternBlockEntity.java b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b6a64bf6e 100644 --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -36,11 +36,56 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -35,7 +_,56 @@ public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -16,10 +8,10 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b + // CraftBukkit start - add fields and methods + public final Container bookAccess = new LecternInventory(); + public class LecternInventory implements Container { - { - Objects.requireNonNull(LecternBlockEntity.this); - } - ++ { ++ Objects.requireNonNull(LecternBlockEntity.this); ++ } ++ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = 1; + @@ -66,7 +58,7 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b @Override public int getContainerSize() { return 1; -@@ -84,11 +129,19 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -79,11 +_,19 @@ @Override public void setItem(final int slot, final ItemStack itemStack) { @@ -87,7 +79,7 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b } @Override -@@ -170,7 +223,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -161,7 +_,7 @@ if (newPage != this.page) { this.page = newPage; this.setChanged(); @@ -96,7 +88,7 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b } } -@@ -192,6 +245,36 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -183,6 +_,36 @@ return book; } @@ -133,7 +125,7 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b private CommandSourceStack createCommandSourceStack(final @Nullable Player player, final ServerLevel level) { String textName; Component displayName; -@@ -205,7 +288,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -196,7 +_,7 @@ Vec3 pos = Vec3.atCenterOf(this.worldPosition); return new CommandSourceStack( @@ -142,7 +134,7 @@ index 753158f0f517a792d99a96bc57b08950baac569b..1d5ff873a3a7ce1f450bfc6f855e3c6b ); } -@@ -246,7 +329,7 @@ public class LecternBlockEntity extends BlockEntity implements Clearable, MenuPr +@@ -237,7 +_,7 @@ @Override public AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch similarity index 90% rename from paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index cbd38a436a3a..54c714051140 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/entity/SignBlockEntity.java b/net/minecraft/world/level/block/entity/SignBlockEntity.java -index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bdabf9eba9 100644 --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -59,10 +59,15 @@ public class SignBlockEntity extends BlockEntity { +@@ -59,10 +_,15 @@ } public boolean isFacingFrontText(final Player player) { @@ -26,7 +18,7 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd float signYRot = sign.getYRotationDegrees(this.getBlockState()); float playerYRot = (float)(Mth.atan2(zd, xd) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(signYRot, playerYRot) <= 90.0F; -@@ -130,11 +135,13 @@ public class SignBlockEntity extends BlockEntity { +@@ -130,11 +_,13 @@ public void updateSignText(final Player player, final boolean frontText, final List lines) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { @@ -41,7 +33,7 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd } } -@@ -143,19 +150,41 @@ public class SignBlockEntity extends BlockEntity { +@@ -143,19 +_,41 @@ return this.setText(function.apply(text), isFrontText); } @@ -86,9 +78,9 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd return text; } -@@ -194,7 +223,23 @@ public class SignBlockEntity extends BlockEntity { - Style style = message.getStyle(); - switch (style.getClickEvent()) { +@@ -195,7 +_,23 @@ + ClickEvent event = style.getClickEvent(); + switch (event) { case ClickEvent.RunCommand command: - level.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(player, level, pos), command.command()); + // Paper start - Fix commands from signs not firing command events @@ -111,7 +103,7 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd hasAnyClickCommand = true; break; case ClickEvent.ShowDialog dialog: -@@ -213,11 +258,55 @@ public class SignBlockEntity extends BlockEntity { +@@ -214,11 +_,55 @@ return hasAnyClickCommand; } @@ -146,7 +138,7 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd + private CommandSourceStack createCommandSourceStack(final @Nullable Player player, final ServerLevel level, final BlockPos pos) { + // CraftBukkit end String textName = player == null ? "Sign" : player.getPlainTextName(); - Component displayName = (Component)(player == null ? Component.literal("Sign") : player.getDisplayName()); + Component displayName = player == null ? Component.literal("Sign") : player.getDisplayName(); + // Paper start - Fix commands from signs not firing command events + CommandSource commandSource = level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this.commandSource) { + @Override @@ -169,7 +161,7 @@ index ef7763aa1c47faad0ad1f931653f69bb6d8c28c8..4dabcf092bc17d17bec26baf5c94b7bd ); } -@@ -236,12 +325,17 @@ public class SignBlockEntity extends BlockEntity { +@@ -237,12 +_,17 @@ } public @Nullable UUID getPlayerWhoMayEdit() { From e604fe252ecf5f012d15ee1fe4154c204a97e5f3 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 13 May 2026 12:40:40 +0100 Subject: [PATCH 11/16] 130 --- .../chat/contents/SelectorContents.java.patch | 19 --- .../NetworkRegistryLoadTask.java.patch | 19 --- .../ItemStackTheFlatteningFix.java.patch | 19 --- .../ai/goal/target/TargetGoal.java.patch | 28 ----- .../entity/vehicle/VehicleEntity.java.patch | 59 ---------- .../level/storage/SavedDataStorage.java.patch | 28 ----- .../chat/contents/SelectorContents.java.patch | 11 ++ .../minecraft/resources/Identifier.java.patch | 19 +-- .../NetworkRegistryLoadTask.java.patch | 11 ++ .../dedicated/DedicatedServer.java.patch | 111 ++++++++---------- .../ItemStackTheFlatteningFix.java.patch | 11 ++ .../world/InteractionResult.java.patch | 20 +--- .../world/RandomizableContainer.java.patch | 35 ++---- .../world/effect/MobEffectInstance.java.patch | 30 ++--- .../world/effect/WeavingMobEffect.java.patch | 18 +-- .../ai/goal/target/TargetGoal.java.patch | 20 ++++ .../GroundPathNavigation.java.patch | 24 ++-- .../ai/navigation/PathNavigation.java.patch | 64 +++++----- .../animal/armadillo/Armadillo.java.patch | 34 ++---- .../entity/monster/zombie/Zombie.java.patch | 80 ++++++------- .../entity/vehicle/VehicleEntity.java.patch | 53 +++++++++ .../level/block/grower/TreeGrower.java.patch | 30 ++--- .../level/levelgen/PatrolSpawner.java.patch | 26 ++-- .../level/redstone/NeighborUpdater.java.patch | 14 +-- .../storage/PlayerDataStorage.java.patch | 22 ++-- .../level/storage/SavedDataStorage.java.patch | 20 ++++ 26 files changed, 332 insertions(+), 493 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/resources/Identifier.java.patch (75%) create mode 100644 paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/dedicated/DedicatedServer.java.patch (79%) create mode 100644 paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/InteractionResult.java.patch (64%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/RandomizableContainer.java.patch (75%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/effect/MobEffectInstance.java.patch (55%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/effect/WeavingMobEffect.java.patch (66%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch (50%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch (61%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch (58%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/monster/zombie/Zombie.java.patch (79%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/block/grower/TreeGrower.java.patch (82%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch (79%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/redstone/NeighborUpdater.java.patch (71%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/storage/PlayerDataStorage.java.patch (76%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch b/paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch deleted file mode 100644 index 1abc156e0efa..000000000000 --- a/paper-server/patches/rejected/net/minecraft/network/chat/contents/SelectorContents.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/network/chat/contents/SelectorContents.java b/net/minecraft/network/chat/contents/SelectorContents.java -index a3cd99bcf2b5c4efb245b3ae96ac3e12bdb987b3..06d0674e3e9460b44a63504c2ea5a3b0a277e973 100644 ---- a/net/minecraft/network/chat/contents/SelectorContents.java -+++ b/net/minecraft/network/chat/contents/SelectorContents.java -@@ -37,7 +37,7 @@ public record SelectorContents(CompilableString selector, Option - if (source == null) { - return Component.empty(); - } else { -- Optional resolvedSeparator = ComponentUtils.resolve(context, this.separator, recursionDepth); -+ Optional resolvedSeparator = ComponentUtils.resolveSeparator(context, this.separator, recursionDepth); // Paper - validate separator - return ComponentUtils.formatList(this.selector.compiled().findEntities(source), resolvedSeparator, Entity::getDisplayName); - } - } diff --git a/paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch b/paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch deleted file mode 100644 index 25be2bf2dfe5..000000000000 --- a/paper-server/patches/rejected/net/minecraft/resources/NetworkRegistryLoadTask.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/resources/NetworkRegistryLoadTask.java b/net/minecraft/resources/NetworkRegistryLoadTask.java -index 9b51116f171a024b8851f8e4f5aedb11d692dc28..98026e9ea60fe3d12a1206cc4d4b5933f9a29055 100644 ---- a/net/minecraft/resources/NetworkRegistryLoadTask.java -+++ b/net/minecraft/resources/NetworkRegistryLoadTask.java -@@ -79,7 +79,7 @@ public class NetworkRegistryLoadTask extends RegistryLoadTask { - } - - return Util.sequence(elements).thenAcceptAsync(pendingRegistrations -> { -- this.registerElements(pendingRegistrations.stream()); -+ this.registerElements(pendingRegistrations.stream(), null); // Paper - this code is only used on the client - Map, List>> pendingTags = TagLoader.loadTagsFromNetwork(registryEntries.tags(), this.readOnlyRegistry()); - this.registerTags(pendingTags); - }, executor); diff --git a/paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch b/paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch deleted file mode 100644 index 6573f0223478..000000000000 --- a/paper-server/patches/rejected/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java -index f03f3c50990083492628cb28ae30a794f9110479..63ba05d7e0411bb6c9fde0e7c4dafa540eb1890d 100644 ---- a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java -+++ b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java -@@ -423,7 +423,7 @@ public class ItemStackTheFlatteningFix extends DataFix { - if (DAMAGE_IDS.contains(id.get().getSecond())) { - Typed tag = input.getOrCreateTyped(tagF); - Dynamic tagRest = tag.get(DSL.remainderFinder()); -- tagRest = tagRest.set("Damage", tagRest.createInt(data)); -+ if (data != 0) tagRest = tagRest.set("Damage", tagRest.createInt(data)); // CraftBukkit - output = output.set(tagF, tag.set(DSL.remainderFinder(), tagRest)); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch deleted file mode 100644 index 1171fc28657c..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -index 093bad31b64fa6b104bdfcc71b7b7f5956f5e198..a9fc45b2f2cc280fc84e07e1481172c78a3cd340 100644 ---- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -+++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -@@ -62,7 +62,7 @@ public abstract class TargetGoal extends Goal { - } - } - -- this.mob.setTarget(target); -+ this.mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); // CraftBukkit - return true; - } - } -@@ -82,7 +82,7 @@ public abstract class TargetGoal extends Goal { - - @Override - public void stop() { -- this.mob.setTarget(null); -+ this.mob.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit - this.targetMob = null; - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch deleted file mode 100644 index 028542407c1f..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/vehicle/VehicleEntity.java b/net/minecraft/world/entity/vehicle/VehicleEntity.java -index 45788af36374c01d846721d2530fe544671a8801..0e0fdc3cc76d6f0798daf0ccf4bcb6a3785c7216 100644 ---- a/net/minecraft/world/entity/vehicle/VehicleEntity.java -+++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java -@@ -32,12 +32,22 @@ public abstract class VehicleEntity extends Entity { - } - - @Override -- public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { -+ public boolean hurtServer(final ServerLevel level, final DamageSource source, float damage) { // Paper - unfinal damage - if (this.isRemoved()) { - return true; - } else if (this.isInvulnerableToBase(source)) { - return false; - } else { -+ // CraftBukkit start -+ org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); -+ org.bukkit.craftbukkit.damage.CraftDamageSource damageSourceBukkit = new org.bukkit.craftbukkit.damage.CraftDamageSource(source); -+ org.bukkit.entity.Entity attacker = net.minecraft.Optionull.map( -+ source.eventEntityDamager() != null ? source.eventEntityDamager() : source.getDirectEntity(), Entity::getBukkitEntity -+ ); -+ org.bukkit.event.vehicle.VehicleDamageEvent event = new org.bukkit.event.vehicle.VehicleDamageEvent(vehicle, damageSourceBukkit, attacker, damage); -+ if (!event.callEvent()) return false; -+ damage = (float) event.getDamage(); -+ // CraftBukkit end - this.setHurtDir(-this.getHurtDir()); - this.setHurtTime(10); - this.markHurt(); -@@ -46,9 +56,23 @@ public abstract class VehicleEntity extends Entity { - boolean creativePlayer = source.getEntity() instanceof Player player && player.getAbilities().instabuild; - if ((creativePlayer || !(this.getDamage() > 40.0F)) && !this.shouldSourceDestroy(source)) { - if (creativePlayer) { -- this.discard(); -+ // CraftBukkit start -+ org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, damageSourceBukkit, attacker); -+ if (!destroyEvent.callEvent()) { -+ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away -+ return true; -+ } -+ // CraftBukkit end -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - } - } else { -+ // CraftBukkit start -+ org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, damageSourceBukkit, attacker); -+ if (!destroyEvent.callEvent()) { -+ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away -+ return true; -+ } -+ // CraftBukkit end - this.destroy(level, source); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch deleted file mode 100644 index 21ff7692989c..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/storage/SavedDataStorage.java.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/storage/SavedDataStorage.java b/net/minecraft/world/level/storage/SavedDataStorage.java -index 9b9af027bab82c19d12c8b7e26bf3a940c6123e2..971c3f3311f5eb132817589ee5b7f65736c25b76 100644 ---- a/net/minecraft/world/level/storage/SavedDataStorage.java -+++ b/net/minecraft/world/level/storage/SavedDataStorage.java -@@ -156,7 +156,7 @@ public class SavedDataStorage implements AutoCloseable { - } else { - int threads = Util.maxAllowedExecutorThreads(); - int taskCount = tagsToSave.size(); -- if (taskCount > threads) { -+ if (false && taskCount > threads) { // Paper - Separate dimension data IO pool; just throw them into the fixed pool queue - this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(ignored -> { - List> tasks = new ArrayList<>(threads); - int bucketSize = Mth.positiveCeilDiv(taskCount, threads); -@@ -177,7 +177,7 @@ public class SavedDataStorage implements AutoCloseable { - ignored -> CompletableFuture.allOf( - tagsToSave.entrySet() - .stream() -- .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.ioPool())) -+ .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.DIMENSION_DATA_IO_POOL)) // Paper - Separate dimension data IO pool - .toArray(CompletableFuture[]::new) - ) - ); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch new file mode 100644 index 000000000000..f2cb018f102d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/SelectorContents.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/network/chat/contents/SelectorContents.java ++++ b/net/minecraft/network/chat/contents/SelectorContents.java +@@ -38,7 +_,7 @@ + return Component.empty(); + } + +- Optional resolvedSeparator = ComponentUtils.resolve(context, this.separator, recursionDepth); ++ Optional resolvedSeparator = ComponentUtils.resolveSeparator(context, this.separator, recursionDepth); // Paper - validate separator + return ComponentUtils.formatList(this.selector.compiled().findEntities(source), resolvedSeparator, Entity::getDisplayName); + } + diff --git a/paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch similarity index 75% rename from paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch rename to paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch index 84301abc706f..0313fcd319a9 100644 --- a/paper-server/patches/rejected/net/minecraft/resources/Identifier.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/resources/Identifier.java b/net/minecraft/resources/Identifier.java -index 36d1be7a09ff65ecca69240c5b819292d2e070ed..98ea140232e191f7c0fee8da77d02e957865de2a 100644 --- a/net/minecraft/resources/Identifier.java +++ b/net/minecraft/resources/Identifier.java -@@ -22,6 +22,7 @@ public final class Identifier implements Comparable { +@@ -22,12 +_,20 @@ public static final String DEFAULT_NAMESPACE = "minecraft"; public static final String REALMS_NAMESPACE = "realms"; public static final String ALLOWED_NAMESPACE_CHARACTERS = "[a-z0-9_.-]"; @@ -16,10 +8,9 @@ index 36d1be7a09ff65ecca69240c5b819292d2e070ed..98ea140232e191f7c0fee8da77d02e95 private final String namespace; private final String path; -@@ -30,6 +31,13 @@ public final class Identifier implements Comparable { - + private Identifier(final String namespace, final String path) { + assert isValidNamespace(namespace); assert isValidPath(path); - + // Paper start - Validate Identifier + // Check for the max network string length (capped at Short.MAX_VALUE) as well as the max bytes of a StringTag (length written as an unsigned short) + final int length = namespace.length() + path.length() + 1; @@ -30,7 +21,7 @@ index 36d1be7a09ff65ecca69240c5b819292d2e070ed..98ea140232e191f7c0fee8da77d02e95 this.namespace = namespace; this.path = path; } -@@ -242,7 +250,7 @@ public final class Identifier implements Comparable { +@@ -240,7 +_,7 @@ private static String assertValidNamespace(final String namespace, final String path) { if (!isValidNamespace(namespace)) { @@ -39,7 +30,7 @@ index 36d1be7a09ff65ecca69240c5b819292d2e070ed..98ea140232e191f7c0fee8da77d02e95 } else { return namespace; } -@@ -258,7 +266,7 @@ public final class Identifier implements Comparable { +@@ -256,7 +_,7 @@ private static String assertValidPath(final String namespace, final String path) { if (!isValidPath(path)) { diff --git a/paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch b/paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch new file mode 100644 index 000000000000..1ca69e52a7a0 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/resources/NetworkRegistryLoadTask.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/resources/NetworkRegistryLoadTask.java ++++ b/net/minecraft/resources/NetworkRegistryLoadTask.java +@@ -80,7 +_,7 @@ + } + + return Util.sequence(elements).thenAcceptAsync(pendingRegistrations -> { +- this.registerElements(pendingRegistrations.stream()); ++ this.registerElements(pendingRegistrations.stream(), null); // Paper - this code is only used on the client + Map, List>> pendingTags = TagLoader.loadTagsFromNetwork(registryEntries.tags(), this.readOnlyRegistry()); + this.registerTags(pendingTags); + }, executor); diff --git a/paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch rename to paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index dcf3e6b8aac3..401112c2a841 100644 --- a/paper-server/patches/rejected/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4193b14a4 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -84,9 +84,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -83,9 +_,9 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRIES = 2; @@ -20,7 +12,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 private @Nullable RconThread rconThread; public DedicatedServerSettings settings; private @Nullable MinecraftServerGui gui; -@@ -99,6 +99,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -98,6 +_,7 @@ private long lastHeartbeat; public DedicatedServer( @@ -28,7 +20,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 final Thread serverThread, final LevelStorageSource.LevelStorageAccess levelStorageSource, final PackRepository packRepository, -@@ -109,6 +110,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -108,6 +_,7 @@ final Services services ) { super( @@ -36,7 +28,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 serverThread, levelStorageSource, packRepository, -@@ -121,7 +123,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -120,7 +_,8 @@ true ); this.settings = settings; @@ -46,8 +38,8 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); if (settings.getProperties().codeOfConduct) { -@@ -211,6 +214,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - +@@ -206,6 +_,10 @@ + Thread consoleThread = new Thread("Server console handler") { @Override public void run() { + if (!org.bukkit.craftbukkit.Main.useConsole) return; // CraftBukkit @@ -57,9 +49,9 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String line; -@@ -221,16 +228,41 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - } catch (IOException var4) { - DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); +@@ -216,16 +_,41 @@ + } catch (IOException e) { + DedicatedServer.LOGGER.error("Exception handling console input", e); } + */ + // Paper end - Use TerminalConsoleAppender @@ -100,7 +92,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -241,8 +273,45 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -236,8 +_,45 @@ this.setLocalIp(properties.serverIp); } @@ -147,7 +139,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 InetAddress localAddress = null; if (!this.getLocalIp().isEmpty()) { localAddress = InetAddress.getByName(this.getLocalIp()); -@@ -251,46 +320,72 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -246,47 +_,73 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -161,9 +153,9 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 try { - this.getConnection().startTcpServerListener(localAddress, this.getPort()); + this.getConnection().startTcpServerListener(bindAddress); // Paper - Unix domain socket support - } catch (IOException var11) { + } catch (IOException e) { LOGGER.warn("**** FAILED TO BIND TO PORT!"); - LOGGER.warn("The exception was: {}", var11.toString()); + LOGGER.warn("The exception was: {}", e.toString()); LOGGER.warn("Perhaps a server is already running on that port?"); + if (true) throw new IllegalStateException("Failed to bind to port", var11); // Paper - Propagate failed to bind to port error return false; @@ -208,37 +200,38 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 if (!OldUsersConverter.areOldUserlistsRemoved()) { return false; - } else { -- this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); -+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // CraftBukkit - moved up - this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSubscribers(), RemoteDebugSampleType.TICK_TIME); - long levelNanoTime = Util.getNanos(); - this.services.nameToIdCache().resolveOfflineUsers(!this.usesAuthentication()); - LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); -- this.loadLevel(); -+ this.loadLevel(this.storageSource.getLevelId()); // CraftBukkit - long elapsed = Util.getNanos() - levelNanoTime; - String time = String.format(Locale.ROOT, "%.3fs", elapsed / 1.0E9); -- LOGGER.info("Done ({})! For help, type \"help\"", time); -+ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), time); // Paper - Improve startup message, add total time -+ this.initPostWorld(); // Paper - don't include plugins in world preparation time - if (properties.announcePlayerAchievements != null) { -- this.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this); -+ this.getAllLevels().forEach(l -> l.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this.overworld())); // Paper - per-world game rules - } + } - if (properties.enableQuery) { -@@ -303,7 +398,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.rconThread = RconThread.create(this); - } +- this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); ++ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // CraftBukkit - moved up + this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSubscribers(), RemoteDebugSampleType.TICK_TIME); + long levelNanoTime = Util.getNanos(); + this.services.nameToIdCache().resolveOfflineUsers(!this.usesAuthentication()); + LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); +- this.loadLevel(); ++ this.loadLevel(this.storageSource.getLevelId()); // CraftBukkit + long elapsed = Util.getNanos() - levelNanoTime; + String time = String.format(Locale.ROOT, "%.3fs", elapsed / 1.0E9); +- LOGGER.info("Done ({})! For help, type \"help\"", time); ++ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), time); // Paper - Improve startup message, add total time ++ this.initPostWorld(); // Paper - don't include plugins in world preparation time + if (properties.announcePlayerAchievements != null) { +- this.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this); ++ this.getAllLevels().forEach(l -> l.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this.overworld())); // Paper - per-world game rules + } -- if (this.getMaxTickLength() > 0L) { -+ if (false && this.getMaxTickLength() > 0L) { // Spigot - disable - Thread watchdog = new Thread(new ServerWatchdog(this)); - watchdog.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); - watchdog.setName("Server Watchdog"); -@@ -322,6 +417,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + if (properties.enableQuery) { +@@ -299,7 +_,7 @@ + this.rconThread = RconThread.create(this); } + +- if (this.getMaxTickLength() > 0L) { ++ if (false && this.getMaxTickLength() > 0L) { // Spigot - disable + Thread watchdog = new Thread(new ServerWatchdog(this)); + watchdog.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); + watchdog.setName("Server Watchdog"); +@@ -317,6 +_,12 @@ + return true; } + // Paper start @@ -250,7 +243,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -339,6 +440,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -334,6 +_,7 @@ @Override public void setUsingWhitelist(final boolean usingWhitelist) { @@ -258,7 +251,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 this.settings.update(p -> p.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -400,7 +502,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -395,7 +_,7 @@ @Override protected void forceDifficulty() { @@ -267,7 +260,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } public int viewDistance() { -@@ -456,11 +558,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -451,11 +_,11 @@ } if (this.rconThread != null) { @@ -281,8 +274,8 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } if (this.jsonRpcServer != null) { -@@ -470,6 +572,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - LOGGER.error("Interrupted while stopping the management server", (Throwable)var2); +@@ -465,6 +_,9 @@ + LOGGER.error("Interrupted while stopping the management server", e); } } + @@ -291,7 +284,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } @Override -@@ -479,12 +584,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -474,12 +_,20 @@ } public void handleConsoleInput(final String msg, final CommandSourceStack source) { @@ -315,7 +308,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 this.getCommands().performPrefixedCommand(input.source, input.msg); } } -@@ -624,12 +737,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -625,12 +_,15 @@ @Override public String getMotd() { @@ -333,7 +326,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } @Override -@@ -655,7 +771,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -656,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -346,7 +339,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } @Override -@@ -740,21 +860,60 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -741,21 +_,60 @@ @Override public String getPluginNames() { @@ -412,7 +405,7 @@ index 7bc4cfdc72725c88981997b4a4313daf6e2a802f..cf38c5f00e1f0e53dd6a2c48e9e968c4 } @Override -@@ -882,4 +1041,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -883,4 +_,15 @@ public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch new file mode 100644 index 000000000000..8a0b310f822e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java ++++ b/net/minecraft/util/datafix/fixes/ItemStackTheFlatteningFix.java +@@ -424,7 +_,7 @@ + if (DAMAGE_IDS.contains(id.get().getSecond())) { + Typed tag = input.getOrCreateTyped(tagF); + Dynamic tagRest = tag.get(DSL.remainderFinder()); +- tagRest = tagRest.set("Damage", tagRest.createInt(data)); ++ if (data != 0) tagRest = tagRest.set("Damage", tagRest.createInt(data)); // CraftBukkit + output = output.set(tagF, tag.set(DSL.remainderFinder(), tagRest)); + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch similarity index 64% rename from paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch rename to paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch index ee2984f15225..d5f39ad87c76 100644 --- a/paper-server/patches/rejected/net/minecraft/world/InteractionResult.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch @@ -1,27 +1,19 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/InteractionResult.java b/net/minecraft/world/InteractionResult.java -index 0b28d3cf89a1d354715dd5be9e4edd7c1f54321c..0e1476109ad6c096aad11c896f77da88ac514378 100644 --- a/net/minecraft/world/InteractionResult.java +++ b/net/minecraft/world/InteractionResult.java -@@ -30,18 +30,34 @@ public sealed interface InteractionResult - public record Pass() implements InteractionResult { +@@ -30,18 +_,34 @@ + record Pass() implements InteractionResult { } -- public record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext) implements InteractionResult { +- record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext) implements InteractionResult { + // Paper start - track more context in interaction result -+ public record PaperSuccessContext(net.minecraft.core.@Nullable BlockPos placedPos) { ++ record PaperSuccessContext(net.minecraft.core.@Nullable BlockPos placedPos) { + static PaperSuccessContext DEFAULT = new PaperSuccessContext(null); + + public PaperSuccessContext placedBlockAt(final net.minecraft.core.BlockPos pos) { + return new PaperSuccessContext(pos); + } + } -+ public record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext, PaperSuccessContext paperSuccessContext) implements InteractionResult { ++ record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext, PaperSuccessContext paperSuccessContext) implements InteractionResult { + public InteractionResult.Success configurePaper(final java.util.function.UnaryOperator edit) { + return new InteractionResult.Success(this.swingSource, this.itemContext, edit.apply(this.paperSuccessContext)); + } @@ -29,7 +21,7 @@ index 0b28d3cf89a1d354715dd5be9e4edd7c1f54321c..0e1476109ad6c096aad11c896f77da88 + public Success(final InteractionResult.SwingSource swingSource, final InteractionResult.ItemContext itemContext) { + this(swingSource, itemContext, PaperSuccessContext.DEFAULT); + } -+ // Paper end - track more context in interaction result ++ // Paper end - track more context in interaction result @Override public boolean consumesAction() { return true; diff --git a/paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch similarity index 75% rename from paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch rename to paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch index 1cbd4b534168..5de024776af7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/RandomizableContainer.java b/net/minecraft/world/RandomizableContainer.java -index bbc29d65f7e8cc6a193e67e2e9efce32664f5d21..9ab6a44c2847278d2ab30e936807f0e2bb9e56a8 100644 --- a/net/minecraft/world/RandomizableContainer.java +++ b/net/minecraft/world/RandomizableContainer.java -@@ -26,7 +26,7 @@ public interface RandomizableContainer extends Container { +@@ -26,7 +_,7 @@ void setLootTable(final @Nullable ResourceKey lootTable); @@ -17,7 +9,7 @@ index bbc29d65f7e8cc6a193e67e2e9efce32664f5d21..9ab6a44c2847278d2ab30e936807f0e2 this.setLootTable(lootTable); this.setLootTableSeed(seed); } -@@ -50,8 +50,9 @@ public interface RandomizableContainer extends Container { +@@ -50,8 +_,9 @@ default boolean tryLoadLootTable(final ValueInput base) { ResourceKey lootTable = base.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setLootTable(lootTable); @@ -28,19 +20,18 @@ index bbc29d65f7e8cc6a193e67e2e9efce32664f5d21..9ab6a44c2847278d2ab30e936807f0e2 } default boolean trySaveLootTable(final ValueOutput base) { -@@ -60,26 +61,42 @@ public interface RandomizableContainer extends Container { - return false; - } else { - base.store("LootTable", LootTable.KEY_CODEC, lootTable); -+ if (this.lootableData() != null) this.lootableData().saveNbt(base); // Paper - LootTable API - long lootTableSeed = this.getLootTableSeed(); - if (lootTableSeed != 0L) { - base.putLong("LootTableSeed", lootTableSeed); - } +@@ -61,25 +_,41 @@ + } -- return true; -+ return this.lootableData() == null; // Paper - only track the loot table if there is chance for replenish + base.store("LootTable", LootTable.KEY_CODEC, lootTable); ++ if (this.lootableData() != null) this.lootableData().saveNbt(base); // Paper - LootTable API + long lootTableSeed = this.getLootTableSeed(); + if (lootTableSeed != 0L) { + base.putLong("LootTableSeed", lootTableSeed); } + +- return true; ++ return this.lootableData() == null; // Paper - only track the loot table if there is chance for replenish } default void unpackLootTable(final @Nullable Player player) { @@ -73,7 +64,7 @@ index bbc29d65f7e8cc6a193e67e2e9efce32664f5d21..9ab6a44c2847278d2ab30e936807f0e2 LootParams.Builder params = new LootParams.Builder((ServerLevel)level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(worldPosition)); if (player != null) { params.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -88,4 +105,16 @@ public interface RandomizableContainer extends Container { +@@ -88,4 +_,16 @@ lootTable.fill(this, params.create(LootContextParamSets.CHEST), this.getLootTableSeed()); } } diff --git a/paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch similarity index 55% rename from paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch rename to paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch index e0cbc6fc72ee..35a27d0e23c2 100644 --- a/paper-server/patches/rejected/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,22 +1,14 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/effect/MobEffectInstance.java b/net/minecraft/world/effect/MobEffectInstance.java -index 4d1680e008848bc1db56db139c5138597e17a63b..24b870d1caade4d6bbf0c1bbb0e61a39e8f00d82 100644 --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -227,6 +227,7 @@ public class MobEffectInstance implements Comparable { - } else { - int tickCount = this.isInfiniteDuration() ? target.tickCount : this.duration; - if (this.effect.value().shouldApplyEffectTickThisTick(tickCount, this.amplifier) -+ && new io.papermc.paper.event.entity.EntityEffectTickEvent(target.getBukkitLivingEntity(), org.bukkit.craftbukkit.potion.CraftPotionEffectType.minecraftHolderToBukkit(this.effect), this.amplifier).callEvent() // Paper - Add EntityEffectTickEvent - && !this.effect.value().applyEffectTick(serverLevel, target, this.amplifier)) { - return false; - } else { -@@ -262,13 +263,16 @@ public class MobEffectInstance implements Comparable { +@@ -228,6 +_,7 @@ + + int tickCount = this.isInfiniteDuration() ? target.tickCount : this.duration; + if (this.effect.value().shouldApplyEffectTickThisTick(tickCount, this.amplifier) ++ && new io.papermc.paper.event.entity.EntityEffectTickEvent(target.getBukkitLivingEntity(), org.bukkit.craftbukkit.potion.CraftPotionEffectType.minecraftHolderToBukkit(this.effect), this.amplifier).callEvent() // Paper - Add EntityEffectTickEvent + && !this.effect.value().applyEffectTick(serverLevel, target, this.amplifier)) { + return false; + } +@@ -262,13 +_,16 @@ } private boolean downgradeToHiddenEffect() { @@ -38,7 +30,7 @@ index 4d1680e008848bc1db56db139c5138597e17a63b..24b870d1caade4d6bbf0c1bbb0e61a39 } public void onEffectStarted(final LivingEntity mob) { -@@ -425,7 +429,7 @@ public class MobEffectInstance implements Comparable { +@@ -425,7 +_,7 @@ .apply(i, MobEffectInstance.Details::create) ) ); @@ -47,7 +39,7 @@ index 4d1680e008848bc1db56db139c5138597e17a63b..24b870d1caade4d6bbf0c1bbb0e61a39 subCodec -> StreamCodec.composite( ByteBufCodecs.VAR_INT, MobEffectInstance.Details::amplifier, -@@ -437,7 +441,7 @@ public class MobEffectInstance implements Comparable { +@@ -437,7 +_,7 @@ MobEffectInstance.Details::showParticles, ByteBufCodecs.BOOL, MobEffectInstance.Details::showIcon, diff --git a/paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch similarity index 66% rename from paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch rename to paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch index ebc3962a15d8..5ceb689af4fd 100644 --- a/paper-server/patches/rejected/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/effect/WeavingMobEffect.java b/net/minecraft/world/effect/WeavingMobEffect.java -index 411746c83970e7c05e239c08e3f74338fd9ce07c..ba774a4c307b7c94c8fa6183f263084260903dd8 100644 --- a/net/minecraft/world/effect/WeavingMobEffect.java +++ b/net/minecraft/world/effect/WeavingMobEffect.java -@@ -27,11 +27,11 @@ class WeavingMobEffect extends MobEffect { +@@ -27,11 +_,11 @@ @Override public void onMobRemoved(final ServerLevel level, final LivingEntity mob, final int amplifier, final Entity.RemovalReason reason) { if (reason == Entity.RemovalReason.KILLED && (mob instanceof Player || level.getGameRules().get(GameRules.MOB_GRIEFING))) { @@ -22,11 +14,11 @@ index 411746c83970e7c05e239c08e3f74338fd9ce07c..ba774a4c307b7c94c8fa6183f2630842 Set positionsToTransform = Sets.newHashSet(); int cobwebCount = this.maxCobwebs.applyAsInt(random); -@@ -48,6 +48,7 @@ class WeavingMobEffect extends MobEffect { +@@ -48,6 +_,7 @@ } - for (BlockPos blockPosx : positionsToTransform) { + for (BlockPos blockPos : positionsToTransform) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPosx, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places - level.setBlock(blockPosx, Blocks.COBWEB.defaultBlockState(), Block.UPDATE_ALL); - level.levelEvent(LevelEvent.ANIMATION_SPAWN_COBWEB, blockPosx, 0); + level.setBlock(blockPos, Blocks.COBWEB.defaultBlockState(), Block.UPDATE_ALL); + level.levelEvent(LevelEvent.ANIMATION_SPAWN_COBWEB, blockPos, 0); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch new file mode 100644 index 000000000000..7ca76b3686cf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java ++++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java +@@ -67,7 +_,7 @@ + } + } + +- this.mob.setTarget(target); ++ this.mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); // CraftBukkit + return true; + } + +@@ -84,7 +_,7 @@ + + @Override + public void stop() { +- this.mob.setTarget(null); ++ this.mob.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit + this.targetMob = null; + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch similarity index 50% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch index 198521e863a8..73fb01ecad5e 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -index 1af5ff0e83d76d10b7e369acc4d97d12d845c385..2070a7b0a9c65c291f3bcbebfa9e30ed74b164cd 100644 --- a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -@@ -42,7 +42,7 @@ public class GroundPathNavigation extends PathNavigation { +@@ -42,7 +_,7 @@ } @Override @@ -17,16 +9,16 @@ index 1af5ff0e83d76d10b7e369acc4d97d12d845c385..2070a7b0a9c65c291f3bcbebfa9e30ed LevelChunk chunk = this.level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); if (chunk == null) { return null; -@@ -51,7 +51,7 @@ public class GroundPathNavigation extends PathNavigation { - pos = this.findSurfacePosition(chunk, pos, reachRange); - } - -- return super.createPath(pos, reachRange); -+ return super.createPath(pos, entity, reachRange); // Paper - EntityPathfindEvent +@@ -52,7 +_,7 @@ + pos = this.findSurfacePosition(chunk, pos, reachRange); } + +- return super.createPath(pos, reachRange); ++ return super.createPath(pos, entity, reachRange); // Paper - EntityPathfindEvent } -@@ -91,7 +91,7 @@ public class GroundPathNavigation extends PathNavigation { + final BlockPos findSurfacePosition(final LevelChunk chunk, BlockPos pos, final int reachRange) { +@@ -91,7 +_,7 @@ @Override public Path createPath(final Entity target, final int reachRange) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch similarity index 61% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index a4cf16aa17ee..edd296d0a661 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d2975d0d0b65 100644 --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -122,7 +122,12 @@ public abstract class PathNavigation { +@@ -122,7 +_,12 @@ } public @Nullable Path createPath(final BlockPos pos, final int reachRange) { @@ -22,7 +14,7 @@ index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d297 } public @Nullable Path createPath(final BlockPos pos, final int reachRange, final int maxPathLength) { -@@ -130,7 +135,7 @@ public abstract class PathNavigation { +@@ -130,7 +_,7 @@ } public @Nullable Path createPath(final Entity target, final int reachRange) { @@ -31,7 +23,7 @@ index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d297 } protected @Nullable Path createPath(final Set targets, final int radiusOffset, final boolean above, final int reachRange) { -@@ -140,6 +145,16 @@ public abstract class PathNavigation { +@@ -140,6 +_,16 @@ protected @Nullable Path createPath( final Set targets, final int radiusOffset, final boolean above, final int reachRange, final float maxPathLength ) { @@ -47,33 +39,33 @@ index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d297 + // Paper end - EntityPathfindEvent if (targets.isEmpty()) { return null; - } else if (this.mob.getY() < this.level.getMinY()) { -@@ -149,6 +164,23 @@ public abstract class PathNavigation { - } else if (this.path != null && !this.path.isDone() && targets.contains(this.targetPos)) { + } +@@ -156,6 +_,23 @@ return this.path; - } else { -+ // Paper start - EntityPathfindEvent -+ boolean copiedSet = false; -+ for (BlockPos possibleTarget : targets) { -+ if (!this.mob.level().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border -+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(possibleTarget, this.mob.level()), target == null ? null : target.getBukkitEntity()).callEvent()) { -+ if (!copiedSet) { -+ copiedSet = true; -+ targets = new java.util.HashSet<>(targets); -+ } -+ // note: since we copy the set this remove call is safe, since we're iterating over the old copy -+ targets.remove(possibleTarget); -+ if (targets.isEmpty()) { -+ return null; -+ } + } + ++ // Paper start - EntityPathfindEvent ++ boolean copiedSet = false; ++ for (BlockPos possibleTarget : targets) { ++ if (!this.mob.level().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(possibleTarget, this.mob.level()), target == null ? null : target.getBukkitEntity()).callEvent()) { ++ if (!copiedSet) { ++ copiedSet = true; ++ targets = new java.util.HashSet<>(targets); ++ } ++ // note: since we copy the set this remove call is safe, since we're iterating over the old copy ++ targets.remove(possibleTarget); ++ if (targets.isEmpty()) { ++ return null; + } + } -+ // Paper end - EntityPathfindEvent - ProfilerFiller profiler = Profiler.get(); - profiler.push("pathfind"); - BlockPos fromPos = above ? this.mob.blockPosition().above() : this.mob.blockPosition(); -@@ -168,6 +200,11 @@ public abstract class PathNavigation { - } ++ } ++ // Paper end - EntityPathfindEvent + ProfilerFiller profiler = Profiler.get(); + profiler.push("pathfind"); + BlockPos fromPos = above ? this.mob.blockPosition().above() : this.mob.blockPosition(); +@@ -172,6 +_,11 @@ + return path; } + // Paper start - Perf: Optimise pathfinding @@ -84,7 +76,7 @@ index c0303ffccfbd28f2190cce7f5f54d57b1cab6ccb..18cbe9735473eee408407e1f5944d297 public boolean moveTo(final double x, final double y, final double z, final double speedModifier) { return this.moveTo(this.createPath(x, y, z, 1), speedModifier); } -@@ -177,8 +214,23 @@ public abstract class PathNavigation { +@@ -181,8 +_,23 @@ } public boolean moveTo(final Entity target, final double speedModifier) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch similarity index 58% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index cbdcab177874..eebfeca11a01 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index 17edee3208fd482036be9e7c07a4f7edd23e44a8..03ec05a860781f85e58055d6f58893963781bd97 100644 --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -145,10 +145,12 @@ public class Armadillo extends Animal { +@@ -144,10 +_,12 @@ ArmadilloAi.updateActivity(this); profiler.pop(); if (this.isAlive() && --this.scuteTime <= 0 && this.shouldDropLoot(level)) { @@ -21,7 +13,7 @@ index 17edee3208fd482036be9e7c07a4f7edd23e44a8..03ec05a860781f85e58055d6f5889396 this.scuteTime = this.pickNextScuteDropTime(); } -@@ -285,8 +287,11 @@ public class Armadillo extends Animal { +@@ -284,8 +_,11 @@ } @Override @@ -35,7 +27,7 @@ index 17edee3208fd482036be9e7c07a4f7edd23e44a8..03ec05a860781f85e58055d6f5889396 if (!this.isNoAi() && !this.isDeadOrDying()) { if (source.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -297,6 +302,7 @@ public class Armadillo extends Animal { +@@ -296,6 +_,7 @@ this.rollOut(); } } @@ -43,13 +35,13 @@ index 17edee3208fd482036be9e7c07a4f7edd23e44a8..03ec05a860781f85e58055d6f5889396 } @Override -@@ -315,7 +321,9 @@ public class Armadillo extends Animal { - return false; - } else { - if (this.level() instanceof ServerLevel level) { -+ this.forceDrops = true; // CraftBukkit - this.dropFromEntityInteractLootTable(level, BuiltInLootTables.ARMADILLO_BRUSH, interactingEntity, tool, this::spawnAtLocation); -+ this.forceDrops = false; // CraftBukkit - this.playSound(SoundEvents.ARMADILLO_BRUSH); - this.gameEvent(GameEvent.ENTITY_INTERACT); - } +@@ -315,7 +_,9 @@ + } + + if (this.level() instanceof ServerLevel level) { ++ this.forceDrops = true; // CraftBukkit + this.dropFromEntityInteractLootTable(level, BuiltInLootTables.ARMADILLO_BRUSH, interactingEntity, tool, this::spawnAtLocation); ++ this.forceDrops = false; // CraftBukkit + this.playSound(SoundEvents.ARMADILLO_BRUSH); + this.gameEvent(GameEvent.ENTITY_INTERACT); + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index 7c2f58037ffc..8d29fc28d428 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/zombie/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/zombie/Zombie.java b/net/minecraft/world/entity/monster/zombie/Zombie.java -index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e9656233ce89 100644 --- a/net/minecraft/world/entity/monster/zombie/Zombie.java +++ b/net/minecraft/world/entity/monster/zombie/Zombie.java -@@ -71,8 +71,10 @@ import org.jspecify.annotations.Nullable; +@@ -70,8 +_,10 @@ public class Zombie extends Monster { private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); @@ -21,7 +13,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 ); private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( -@@ -96,13 +98,15 @@ public class Zombie extends Monster { +@@ -95,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; private static final int DEFAULT_IN_WATER_TIME = 0; @@ -38,7 +30,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } public Zombie(final Level level) { -@@ -111,7 +115,7 @@ public class Zombie extends Monster { +@@ -110,7 +_,7 @@ @Override protected void registerGoals() { @@ -47,7 +39,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -124,7 +128,7 @@ public class Zombie extends Monster { +@@ -123,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -56,7 +48,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -178,11 +182,16 @@ public class Zombie extends Monster { +@@ -177,11 +_,16 @@ @Override protected int getBaseExperienceReward(final ServerLevel level) { @@ -74,7 +66,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } @Override -@@ -233,6 +242,13 @@ public class Zombie extends Monster { +@@ -232,6 +_,13 @@ super.tick(); } @@ -88,7 +80,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 public void startUnderWaterConversion(final int time) { this.conversionTime = time; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -246,17 +262,28 @@ public class Zombie extends Monster { +@@ -245,17 +_,28 @@ } protected void convertToZombieType(final ServerLevel level, final EntityType zombieType) { @@ -121,7 +113,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 ZombieVillager zombieVillager = villager.convertTo( EntityType.ZOMBIE_VILLAGER, ConversionParams.single(villager, true, true), -@@ -268,18 +295,25 @@ public class Zombie extends Monster { +@@ -267,17 +_,24 @@ zombie.setGossips(villager.getGossips().copy()); zombie.setTradeOffers(villager.getOffers().copy()); zombie.setVillagerXp(villager.getVillagerXp()); @@ -141,38 +133,36 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 public boolean isSunSensitive() { - return true; +- } + return this.shouldBurnInDay; // Paper - Add more Zombie API - } - ++ } ++ + // Paper start - Add more Zombie API + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; + } + // Paper end - Add more Zombie API -+ + @Override public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { - if (!super.hurtServer(level, source, damage)) { -@@ -311,15 +345,15 @@ public class Zombie extends Monster { - if (SpawnPlacements.isSpawnPositionOk(type, level, spawnPos) - && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, spawnPos, level.getRandom())) { - reinforcement.setPos(xt, yt, zt); -- if (!level.hasNearbyAlivePlayer(xt, yt, zt, 7.0) -+ if (!level.hasNearbyAlivePlayerThatAffectsSpawning(xt, yt, zt, 7.0) // Paper - affects spawning api - && level.isUnobstructed(reinforcement) - && level.noCollision(reinforcement) - && (reinforcement.canSpawnInLiquids() || !level.containsAnyLiquid(reinforcement.getBoundingBox()))) { -- reinforcement.setTarget(target); -+ reinforcement.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); // CraftBukkit - reinforcement.finalizeSpawn( - level, level.getCurrentDifficultyAt(reinforcement.blockPosition()), EntitySpawnReason.REINFORCEMENT, null - ); -- level.addFreshEntityWithPassengers(reinforcement); -+ level.addFreshEntityWithPassengers(reinforcement, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit - AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); - AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); - double existingAmount = modifier != null ? modifier.amount() : 0.0; -@@ -344,7 +378,12 @@ public class Zombie extends Monster { +@@ -311,13 +_,13 @@ + if (SpawnPlacements.isSpawnPositionOk(type, level, spawnPos) + && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, spawnPos, level.getRandom())) { + reinforcement.setPos(xt, yt, zt); +- if (!level.hasNearbyAlivePlayer(xt, yt, zt, 7.0) ++ if (!level.hasNearbyAlivePlayerThatAffectsSpawning(xt, yt, zt, 7.0) // Paper - affects spawning api + && level.isUnobstructed(reinforcement) + && level.noCollision(reinforcement) + && (reinforcement.canSpawnInLiquids() || !level.containsAnyLiquid(reinforcement.getBoundingBox()))) { +- reinforcement.setTarget(target); ++ reinforcement.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); // CraftBukkit + reinforcement.finalizeSpawn(level, level.getCurrentDifficultyAt(reinforcement.blockPosition()), EntitySpawnReason.REINFORCEMENT, null); +- level.addFreshEntityWithPassengers(reinforcement); ++ level.addFreshEntityWithPassengers(reinforcement, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); + AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); + double existingAmount = modifier != null ? modifier.amount() : 0.0; +@@ -341,7 +_,12 @@ if (result) { float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < difficulty * 0.3F) { @@ -186,7 +176,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } } -@@ -406,6 +445,7 @@ public class Zombie extends Monster { +@@ -403,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -194,7 +184,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } @Override -@@ -420,13 +460,15 @@ public class Zombie extends Monster { +@@ -417,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -212,7 +202,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 return perished; } -@@ -461,7 +503,7 @@ public class Zombie extends Monster { +@@ -458,7 +_,7 @@ groupData = super.finalizeSpawn(level, difficulty, spawnReason, groupData); float difficultyModifier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -221,7 +211,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } if (groupData == null) { -@@ -488,7 +530,7 @@ public class Zombie extends Monster { +@@ -485,7 +_,7 @@ chicken.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken.setChickenJockey(true); this.startRiding(chicken, false, false); @@ -230,7 +220,7 @@ index 29ba52c524f187396e2c2fb09ded642b6350ab01..0008aa0ca02fc4ea67b795b3f0a0e965 } } } -@@ -514,7 +556,7 @@ public class Zombie extends Monster { +@@ -511,7 +_,7 @@ protected void onOffspringSpawnedFromEgg(final Player spawner, final Mob offspring) { if (this.level() instanceof ServerLevel serverLevel) { float difficultyModifier = serverLevel.getCurrentDifficultyAt(offspring.blockPosition()).getSpecialMultiplier(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch new file mode 100644 index 000000000000..dc8fbae460a4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch @@ -0,0 +1,53 @@ +--- a/net/minecraft/world/entity/vehicle/VehicleEntity.java ++++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java +@@ -32,7 +_,7 @@ + } + + @Override +- public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { ++ public boolean hurtServer(final ServerLevel level, final DamageSource source, float damage) { // Paper - unfinal damage + if (this.isRemoved()) { + return true; + } +@@ -41,6 +_,16 @@ + return false; + } + ++ // CraftBukkit start ++ org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); ++ org.bukkit.craftbukkit.damage.CraftDamageSource damageSourceBukkit = new org.bukkit.craftbukkit.damage.CraftDamageSource(source); ++ org.bukkit.entity.Entity attacker = net.minecraft.Optionull.map( ++ source.eventEntityDamager() != null ? source.eventEntityDamager() : source.getDirectEntity(), Entity::getBukkitEntity ++ ); ++ org.bukkit.event.vehicle.VehicleDamageEvent event = new org.bukkit.event.vehicle.VehicleDamageEvent(vehicle, damageSourceBukkit, attacker, damage); ++ if (!event.callEvent()) return false; ++ damage = (float) event.getDamage(); ++ // CraftBukkit end + this.setHurtDir(-this.getHurtDir()); + this.setHurtTime(10); + this.markHurt(); +@@ -49,9 +_,23 @@ + boolean creativePlayer = source.getEntity() instanceof Player player && player.getAbilities().instabuild; + if ((creativePlayer || !(this.getDamage() > 40.0F)) && !this.shouldSourceDestroy(source)) { + if (creativePlayer) { +- this.discard(); ++ // CraftBukkit start ++ org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, damageSourceBukkit, attacker); ++ if (!destroyEvent.callEvent()) { ++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause + } + } else { ++ // CraftBukkit start ++ org.bukkit.event.vehicle.VehicleDestroyEvent destroyEvent = new org.bukkit.event.vehicle.VehicleDestroyEvent(vehicle, damageSourceBukkit, attacker); ++ if (!destroyEvent.callEvent()) { ++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end + this.destroy(level, source); + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch similarity index 82% rename from paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 29d7a67561de..7875670c9a27 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/grower/TreeGrower.java b/net/minecraft/world/level/block/grower/TreeGrower.java -index 9c898521851528c0625e019a72b69a3916e5da0a..4fbd75fcb86b5520ceee3218a53a661c9fc0ab44 100644 --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -132,6 +132,7 @@ public final class TreeGrower { +@@ -132,6 +_,7 @@ .get(megaFeatureKey) .orElse(null); if (featureHolder != null) { @@ -16,17 +8,17 @@ index 9c898521851528c0625e019a72b69a3916e5da0a..4fbd75fcb86b5520ceee3218a53a661c for (int dx = 0; dx >= -1; dx--) { for (int dz = 0; dz >= -1; dz--) { if (isTwoByTwoSapling(state, level, pos, dx, dz)) { -@@ -164,6 +165,7 @@ public final class TreeGrower { - if (featureHolder == null) { - return false; - } else { -+ this.setTreeType(featureHolder); // CraftBukkit - ConfiguredFeature feature = featureHolder.value(); - BlockState emptyBlock = level.getFluidState(pos).createLegacyBlock(); - level.setBlock(pos, emptyBlock, Block.UPDATE_NONE); -@@ -210,4 +212,58 @@ public final class TreeGrower { - : OptionalInt.empty(); +@@ -166,6 +_,7 @@ + return false; } + ++ this.setTreeType(featureHolder); // CraftBukkit + ConfiguredFeature feature = featureHolder.value(); + BlockState emptyBlock = level.getFluidState(pos).createLegacyBlock(); + level.setBlock(pos, emptyBlock, Block.UPDATE_NONE); +@@ -210,4 +_,58 @@ + ? OptionalInt.of(treeConfig.trunkPlacer.getBaseHeight()) + : OptionalInt.empty(); } + + // CraftBukkit start diff --git a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch similarity index 79% rename from paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 1a08f4e973c4..126c0f28ad40 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/levelgen/PatrolSpawner.java b/net/minecraft/world/level/levelgen/PatrolSpawner.java -index 7a41b894b22c68a10667be43e2232d399ae9cd2a..17f9b46c5876f6f9f40246aacbf0f4b59958b4c1 100644 --- a/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -18,17 +18,51 @@ public class PatrolSpawner implements CustomSpawner { +@@ -18,17 +_,51 @@ @Override public void tick(final ServerLevel level, final boolean spawnEnemies) { @@ -67,12 +59,12 @@ index 7a41b894b22c68a10667be43e2232d399ae9cd2a..17f9b46c5876f6f9f40246aacbf0f4b5 if (!player.isSpectator()) { if (!level.isCloseToVillage(player.blockPosition(), 2)) { int x = (24 + random.nextInt(24)) * (random.nextBoolean() ? -1 : 1); -@@ -80,7 +114,7 @@ public class PatrolSpawner implements CustomSpawner { +@@ -83,7 +_,7 @@ - mob.setPos(pos.getX(), pos.getY(), pos.getZ()); - mob.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); -- level.addFreshEntityWithPassengers(mob); -+ level.addFreshEntityWithPassengers(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit - return true; - } else { - return false; + mob.setPos(pos.getX(), pos.getY(), pos.getZ()); + mob.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); +- level.addFreshEntityWithPassengers(mob); ++ level.addFreshEntityWithPassengers(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit + return true; + } else { + return false; diff --git a/paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch similarity index 71% rename from paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch index 0730cbca92bc..dd5c1d4130ef 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/redstone/NeighborUpdater.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java -index 65624f84591c51b3344d0a9e041f2b3fd163f6fa..353085151026b0d695be3c35d0638ecd39a962ce 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java -@@ -66,8 +66,26 @@ public interface NeighborUpdater { +@@ -66,8 +_,26 @@ final @Nullable Orientation orientation, final boolean movedByPiston ) { @@ -32,6 +24,6 @@ index 65624f84591c51b3344d0a9e041f2b3fd163f6fa..353085151026b0d695be3c35d0638ecd + } catch (StackOverflowError ex) { + level.lastPhysicsProblem = pos.immutable(); + // Spigot end - } catch (Throwable var9) { - CrashReport report = CrashReport.forThrowable(var9, "Exception while updating neighbours"); + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Exception while updating neighbours"); CrashReportCategory category = report.addCategory("Block being updated"); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index bae069df3e09..5e0a1748d64b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/storage/PlayerDataStorage.java b/net/minecraft/world/level/storage/PlayerDataStorage.java -index 4671807c1abad46678beb8870e0645b575d18236..41cbb27861f33ad8d7523f3b2fef9a30a69693a9 100644 --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -31,6 +31,7 @@ public class PlayerDataStorage { +@@ -31,6 +_,7 @@ } public void save(final Player player) { @@ -16,16 +8,16 @@ index 4671807c1abad46678beb8870e0645b575d18236..41cbb27861f33ad8d7523f3b2fef9a30 try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(player.problemPath(), LOGGER)) { TagValueOutput output = TagValueOutput.createWithContext(reporter, player.registryAccess()); player.saveWithoutId(output); -@@ -42,7 +43,7 @@ public class PlayerDataStorage { +@@ -42,7 +_,7 @@ Path oldFile = playerDirPath.resolve(player.getStringUUID() + ".dat_old"); Util.safeReplaceFile(realFile, tmpFile, oldFile); - } catch (Exception var11) { + } catch (Exception ignored) { - LOGGER.warn("Failed to save player data for {}", player.getPlainTextName()); -+ LOGGER.warn("Failed to save player data for {}", player.getPlainTextName(), var11); // Paper - Print exception ++ LOGGER.warn("Failed to save player data for {}", player.getPlainTextName(), ignored); // Paper - Print exception } } -@@ -62,9 +63,25 @@ public class PlayerDataStorage { +@@ -62,9 +_,25 @@ private Optional load(final NameAndId nameAndId, final String suffix) { File realFile = new File(this.playerDir, nameAndId.id() + suffix); @@ -49,10 +41,10 @@ index 4671807c1abad46678beb8870e0645b575d18236..41cbb27861f33ad8d7523f3b2fef9a30 + } + return optional; + // Spigot end - } catch (Exception var5) { + } catch (Exception ignored) { LOGGER.warn("Failed to load player data for {}", nameAndId.name()); } -@@ -84,4 +101,10 @@ public class PlayerDataStorage { +@@ -84,4 +_,10 @@ return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, tag, version); }); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch new file mode 100644 index 000000000000..181dbcff0089 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/SavedDataStorage.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/storage/SavedDataStorage.java ++++ b/net/minecraft/world/level/storage/SavedDataStorage.java +@@ -155,7 +_,7 @@ + + int threads = Util.maxAllowedExecutorThreads(); + int taskCount = tagsToSave.size(); +- if (taskCount > threads) { ++ if (false && taskCount > threads) { // Paper - Separate dimension data IO pool; just throw them into the fixed pool queue + this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(ignored -> { + List> tasks = new ArrayList<>(threads); + int bucketSize = Mth.positiveCeilDiv(taskCount, threads); +@@ -176,7 +_,7 @@ + ignored -> CompletableFuture.allOf( + tagsToSave.entrySet() + .stream() +- .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.ioPool())) ++ .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.DIMENSION_DATA_IO_POOL)) // Paper - Separate dimension data IO pool + .toArray(CompletableFuture[]::new) + ) + ); From facf9ee2fd062238dc930773bb64de328e6fdf95 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 13 May 2026 13:14:28 +0100 Subject: [PATCH 12/16] 150 --- .../net/minecraft/server/Bootstrap.java.patch | 105 ------ .../skeleton/WitherSkeleton.java.patch | 27 -- .../world/entity/raid/Raids.java.patch | 47 --- .../block/piston/PistonBaseBlock.java.patch | 172 ---------- .../StructureTemplate.java.patch | 158 --------- .../net/minecraft/server/Bootstrap.java.patch | 96 ++++++ .../net/minecraft/server/Main.java.patch | 30 +- .../server/MinecraftServer.java.patch | 308 +++++++++--------- .../ServerConnectionListener.java.patch | 22 +- .../ServerGamePacketListenerImpl.java.patch | 248 +++++++------- .../ServerLoginPacketListenerImpl.java.patch | 60 ++-- .../CachedUserNameToIdResolver.java.patch | 59 ++-- .../players/OldUsersConverter.java.patch | 36 +- .../world/entity/ai/goal/Goal.java.patch | 14 +- .../entity/ai/goal/RemoveBlockGoal.java.patch | 31 +- .../skeleton/WitherSkeleton.java.patch | 19 ++ .../world/entity/raid/Raid.java.patch | 46 ++- .../world/entity/raid/Raids.java.patch | 39 +++ .../block/piston/PistonBaseBlock.java.patch | 164 ++++++++++ .../level/chunk/ChunkGenerator.java.patch | 79 ++--- .../ChunkGeneratorStructureState.java.patch | 45 ++- .../world/level/chunk/LevelChunk.java.patch | 60 ++-- .../world/level/chunk/ProtoChunk.java.patch | 19 +- .../StructureTemplate.java.patch | 150 +++++++++ .../storage/LevelStorageSource.java.patch | 33 +- 25 files changed, 962 insertions(+), 1105 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/Main.java.patch (95%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/MinecraftServer.java.patch (87%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/network/ServerConnectionListener.java.patch (90%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch (95%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch (91%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch (77%) rename paper-server/patches/{rejected => sources}/net/minecraft/server/players/OldUsersConverter.java.patch (80%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/goal/Goal.java.patch (69%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch (57%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/raid/Raid.java.patch (86%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/chunk/ChunkGenerator.java.patch (69%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch (85%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/chunk/LevelChunk.java.patch (83%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/chunk/ProtoChunk.java.patch (53%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/storage/LevelStorageSource.java.patch (67%) diff --git a/paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch deleted file mode 100644 index c9abcb446638..000000000000 --- a/paper-server/patches/rejected/net/minecraft/server/Bootstrap.java.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/Bootstrap.java b/net/minecraft/server/Bootstrap.java -index c667484cbbd54863537e428c0f792c55de82ee3f..749cca9ae9a1af6a15fdfb2e3f23fd9e40412efc 100644 ---- a/net/minecraft/server/Bootstrap.java -+++ b/net/minecraft/server/Bootstrap.java -@@ -43,6 +43,7 @@ public class Bootstrap { - if (!isBootstrapped) { - isBootstrapped = true; - Instant start = Instant.now(); -+ io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping - if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { - throw new IllegalStateException("Unable to load registries"); - } else { -@@ -54,11 +55,85 @@ public class Bootstrap { - EntitySelectorOptions.bootStrap(); - DispenseItemBehavior.bootStrap(); - CauldronInteractions.bootStrap(); -- BuiltInRegistries.bootStrap(); -+ // Paper start -+ BuiltInRegistries.bootStrap(() -> { -+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings -+ }); -+ // Paper end - CreativeModeTabs.validate(); - wrapStreams(); - bootstrapDuration.set(Duration.between(start, Instant.now()).toMillis()); - } -+ // CraftBukkit start -+ // TODO Check what of this is needed, maybe report it to Mojira. if deemed relevant, move to the respective classes -+ // Used in CraftLegacy -+ for (int i = 0; i <= 15; i++) { -+ net.minecraft.util.datafix.fixes.BlockStateData.register( -+ 1008 + i, -+ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( -+ "Name", "minecraft:oak_sign", -+ "Properties", java.util.Map.of("rotation", String.valueOf(i)) -+ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), -+ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( -+ "Name", "minecraft:standing_sign", -+ "Properties", java.util.Map.of("rotation", String.valueOf(i)) -+ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) -+ ); -+ } -+ -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, -+ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( -+ "Name", "minecraft:portal", -+ "Properties", java.util.Map.of("axis", "x") -+ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), -+ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( -+ "Name", "minecraft:portal", -+ "Properties", java.util.Map.of("axis", "x") -+ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) -+ ); -+ -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(411, "minecraft:rabbit"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(412, "minecraft:cooked_rabbit"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(413, "minecraft:rabbit_stew"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(414, "minecraft:rabbit_foot"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(415, "minecraft:rabbit_hide"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(416, "minecraft:armor_stand"); -+ -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(423, "minecraft:mutton"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(424, "minecraft:cooked_mutton"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(425, "minecraft:banner"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(426, "minecraft:end_crystal"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(427, "minecraft:spruce_door"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(428, "minecraft:birch_door"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(429, "minecraft:jungle_door"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(430, "minecraft:acacia_door"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(431, "minecraft:dark_oak_door"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(432, "minecraft:chorus_fruit"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(433, "minecraft:chorus_fruit_popped"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(434, "minecraft:beetroot"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(435, "minecraft:beetroot_seeds"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(436, "minecraft:beetroot_soup"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(437, "minecraft:dragon_breath"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(438, "minecraft:splash_potion"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(439, "minecraft:spectral_arrow"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(440, "minecraft:tipped_arrow"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(441, "minecraft:lingering_potion"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(442, "minecraft:shield"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(443, "minecraft:elytra"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(444, "minecraft:spruce_boat"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(445, "minecraft:birch_boat"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(446, "minecraft:jungle_boat"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(447, "minecraft:acacia_boat"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(448, "minecraft:dark_oak_boat"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(449, "minecraft:totem_of_undying"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(450, "minecraft:shulker_shell"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(452, "minecraft:iron_nugget"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(453, "minecraft:knowledge_book"); -+ -+ net.minecraft.util.datafix.fixes.ItemSpawnEggFix.ID_TO_ENTITY[23] = "Arrow"; -+ // CraftBukkit end - } - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch deleted file mode 100644 index 321ca3a40e95..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java -index 3106820022b6435bf9c02bcdf0ec0cb5fdfd2253..27f0e22f015aad556bff6dac404b6ed2df04e486 100644 ---- a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java -+++ b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java -@@ -95,7 +95,7 @@ public class WitherSkeleton extends AbstractSkeleton { - return false; - } else { - if (target instanceof LivingEntity) { -- ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this); -+ ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - } - - return true; -@@ -111,6 +111,6 @@ public class WitherSkeleton extends AbstractSkeleton { - - @Override - public boolean canBeAffected(final MobEffectInstance newEffect) { -- return !newEffect.is(MobEffects.WITHER) && super.canBeAffected(newEffect); -+ return (!newEffect.is(MobEffects.WITHER) || !this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton) && super.canBeAffected(newEffect); // Paper - Add config for mobs immune to default effects - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch deleted file mode 100644 index a4957216ce8d..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raids.java.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/raid/Raids.java b/net/minecraft/world/entity/raid/Raids.java -index e5f7c6ada9102345b2e86bc24797686dd325b3fd..d5d3c86327d8feefb9fa2a3330bcb4dbdc629342 100644 ---- a/net/minecraft/world/entity/raid/Raids.java -+++ b/net/minecraft/world/entity/raid/Raids.java -@@ -52,6 +52,7 @@ public class Raids extends SavedData { - private Raids(final List raids, final int nextId, final int tick) { - for (Raids.RaidWithId raid : raids) { - this.raidMap.put(raid.id, raid.raid); -+ raid.raid.idOrNegativeOne = raid.id; // Paper - expose id of raids while method is kept around as deprecated for removal - } - - this.nextId = nextId; -@@ -130,11 +131,23 @@ public class Raids extends SavedData { - } - - Raid raid = this.getOrCreateRaid(level, raidCenterPos); -- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -- this.raidMap.put(this.getUniqueId(), raid); -- } -- -- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { -+ // CraftBukkit - moved down -+ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ // this.raidMap.put(this.getUniqueId(), raid); -+ // } -+ -+ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(level, raid, player)) { -+ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); -+ return null; -+ } -+ -+ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ this.raidMap.put(this.getUniqueId(), raid); -+ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal -+ } -+ // CraftBukkit end - raid.absorbRaidOmen(player); - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch deleted file mode 100644 index 21aa40fc69e9..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index 0080f8dc04994fa149ae9ce50bade886f43c9cfb..a2bc07a8348c5d7f30aafa0344d66715c89994b0 100644 ---- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java -+++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -150,6 +150,12 @@ public class PistonBaseBlock extends DirectionalBlock { - @Override - protected boolean triggerEvent(final BlockState state, final Level level, final BlockPos pos, final int b0, final int b1) { - Direction direction = state.getValue(FACING); -+ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; prevent retracting when we're facing the wrong way (we were replaced before retraction could occur) -+ Direction directionQueuedAs = Direction.from3DDataValue(b1 & 7); // Paper - copied from below -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits && direction != directionQueuedAs) { -+ return false; -+ } -+ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - BlockState extendedState = state.setValue(EXTENDED, true); - if (!level.isClientSide()) { - boolean extend = this.getNeighborSignal(level, pos, direction); -@@ -182,10 +188,17 @@ public class PistonBaseBlock extends DirectionalBlock { - .defaultBlockState() - .setValue(MovingPistonBlock.FACING, direction) - .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); -+ // Paper start - Fix sticky pistons and BlockPistonRetractEvent; Move empty piston retract call to fix multiple event fires -+ if (!this.isSticky) { -+ if (!new org.bukkit.event.block.BlockPistonRetractEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), java.util.Collections.emptyList(), org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)).callEvent()) { -+ return false; -+ } -+ } -+ // Paper end - Fix sticky pistons and BlockPistonRetractEvent - level.setBlock(pos, movingPistonState, Block.UPDATE_NONE | Block.UPDATE_KNOWN_SHAPE); - level.setBlockEntity( - MovingPistonBlock.newMovingBlockEntity( -- pos, movingPistonState, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(b1 & 7)), direction, false, true -+ pos, movingPistonState, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(b1 & 7)), direction, false, true // Paper - Protect Bedrock and End Portal/Frames from being destroyed; diff on change - ) - ); - level.updateNeighborsAt(pos, movingPistonState.getBlock()); -@@ -209,13 +222,27 @@ public class PistonBaseBlock extends DirectionalBlock { - || movingState.getPistonPushReaction() != PushReaction.NORMAL - && !movingState.is(Blocks.PISTON) - && !movingState.is(Blocks.STICKY_PISTON)) { -+ // Paper start - Fix sticky pistons and BlockPistonRetractEvent; fire BlockPistonRetractEvent for sticky pistons retracting nothing (air) -+ if (b0 == TRIGGER_CONTRACT && movingState.isAir()) { -+ if (!new org.bukkit.event.block.BlockPistonRetractEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), java.util.Collections.emptyList(), org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)).callEvent()) { -+ return false; -+ } -+ } -+ // Paper end - Fix sticky pistons and BlockPistonRetractEvent - level.removeBlock(pos.relative(direction), false); - } else { - this.moveBlocks(level, pos, direction, false); - } - } - } else { -- level.removeBlock(pos.relative(direction), false); -+ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; fix headless pistons breaking blocks -+ BlockPos headPos = pos.relative(direction); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits || level.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, direction)) { // double check to make sure we're not a headless piston -+ level.removeBlock(headPos, false); -+ } else { -+ ((ServerLevel) level).getChunkSource().blockChanged(headPos); // ... fix client desync -+ } -+ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - } - - level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.15F + 0.6F); -@@ -233,7 +260,7 @@ public class PistonBaseBlock extends DirectionalBlock { - final boolean allowDestroyable, - final Direction connectionDirection - ) { -- if (pos.getY() < level.getMinY() || pos.getY() > level.getMaxY() || !level.getWorldBorder().isWithinBounds(pos)) { -+ if (pos.getY() < level.getMinY() || pos.getY() > level.getMaxY() || !level.getWorldBorder().isWithinBounds(pos) || !level.getWorldBorder().isWithinBounds(pos.relative(direction))) { // Paper - Fix piston world border check - return false; - } else if (state.isAir()) { - return true; -@@ -289,12 +316,58 @@ public class PistonBaseBlock extends DirectionalBlock { - BlockState[] toUpdate = new BlockState[toPush.size() + toDestroy.size()]; - Direction pushDirection = extending ? direction : direction.getOpposite(); - int updateIndex = 0; -+ // CraftBukkit start -+ final org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pistonPos); -+ -+ final List moved = resolver.getToPush(); -+ final List broken = resolver.getToDestroy(); -+ -+ List blocks = new java.util.AbstractList<>() { -+ -+ @Override -+ public int size() { -+ return moved.size() + broken.size(); -+ } -+ -+ @Override -+ public org.bukkit.block.Block get(int index) { -+ if (index >= this.size() || index < 0) { -+ throw new ArrayIndexOutOfBoundsException(index); -+ } -+ -+ BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size()); -+ return org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ } -+ }; -+ -+ final org.bukkit.event.block.BlockPistonEvent event; -+ if (extending) { -+ event = new org.bukkit.event.block.BlockPistonExtendEvent( -+ bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(pushDirection) -+ ); -+ } else { -+ event = new org.bukkit.event.block.BlockPistonRetractEvent( -+ bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(pushDirection) -+ ); -+ } -+ if (!event.callEvent()) { -+ for (BlockPos brokenPos : broken) { -+ level.sendBlockUpdated(brokenPos, Blocks.AIR.defaultBlockState(), level.getBlockState(brokenPos), Block.UPDATE_ALL); -+ } -+ for (BlockPos movedPos : moved) { -+ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); -+ movedPos = movedPos.relative(pushDirection); -+ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); -+ } -+ return false; -+ } -+ // CraftBukkit end - - for (int i = toDestroy.size() - 1; i >= 0; i--) { - BlockPos pos = toDestroy.get(i); - BlockState state = level.getBlockState(pos); - BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; -- dropResources(state, level, pos, blockEntity); -+ dropResources(state, level, pos, blockEntity, pistonPos); // Paper - Add BlockBreakBlockEvent - if (!state.is(BlockTags.FIRE) && level.isClientSide()) { - level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, getId(state)); - } -@@ -305,13 +378,28 @@ public class PistonBaseBlock extends DirectionalBlock { - } - - for (int i = toPush.size() - 1; i >= 0; i--) { -- BlockPos pos = toPush.get(i); -- BlockState blockState = level.getBlockState(pos); -+ // Paper start - fix a variety of piston desync dupes -+ boolean allowDesync = io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication; -+ BlockPos oldPos = toPush.get(i); -+ BlockPos pos = oldPos; -+ BlockState blockState = allowDesync ? level.getBlockState(oldPos) : null; -+ // Paper end - fix a variety of piston desync dupes - pos = pos.relative(pushDirection); - deleteAfterMove.remove(pos); - BlockState actualState = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, direction); - level.setBlock(pos, actualState, Block.UPDATE_NONE | Block.UPDATE_MOVE_BY_PISTON); -- level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, actualState, toPushShapes.get(i), direction, extending, false)); -+ // Paper start - fix a variety of piston desync dupes -+ if (!allowDesync) { -+ blockState = level.getBlockState(oldPos); -+ deleteAfterMove.replace(oldPos, blockState); -+ } -+ level.setBlockEntity( -+ MovingPistonBlock.newMovingBlockEntity(pos, actualState, allowDesync ? toPushShapes.get(i) : blockState, direction, extending, false) -+ ); -+ if (!allowDesync) { -+ level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_SKIP_ON_PLACE); // set air to prevent later physics updates from seeing this block -+ } -+ // Paper end - fix a variety of piston desync dupes - toUpdate[updateIndex++] = blockState; - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch deleted file mode 100644 index 827b401af2bf..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ /dev/null @@ -1,158 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -index 61019270d4816912e2097aabe3791c6ce4b9b833..b8e6c84f633778d4023fe4b31475b10e61b67ce4 100644 ---- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -80,6 +80,10 @@ public class StructureTemplate { - public final List entityInfoList = Lists.newArrayList(); - private Vec3i size = Vec3i.ZERO; - private String author = "?"; -+ // CraftBukkit start - data containers -+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); -+ public org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); -+ // CraftBukkit end - - public Vec3i getSize() { - return this.size; -@@ -251,7 +255,7 @@ public class StructureTemplate { - } - - public boolean placeInWorld( -- final ServerLevelAccessor level, -+ ServerLevelAccessor level, // Paper - make non-final - final BlockPos position, - final BlockPos referencePos, - final StructurePlaceSettings settings, -@@ -261,6 +265,19 @@ public class StructureTemplate { - if (this.palettes.isEmpty()) { - return false; - } else { -+ // CraftBukkit start -+ // We only want the TransformerLevelAccessor at certain locations because in here are many "block update" calls that shouldn't be transformed -+ ServerLevelAccessor wrappedAccessor = level; -+ org.bukkit.craftbukkit.util.CraftStructureTransformer structureTransformer = null; -+ if (wrappedAccessor instanceof org.bukkit.craftbukkit.util.TransformerLevelAccessor transformerAccessor) { -+ level = transformerAccessor.getDelegate(); -+ structureTransformer = transformerAccessor.getStructureTransformer(); -+ // The structureTransformer is not needed if we can not transform blocks therefore we can save a little bit of performance doing this -+ if (structureTransformer != null && !structureTransformer.canTransformBlocks()) { -+ structureTransformer = null; -+ } -+ } -+ // CraftBukkit end - List blockInfoList = settings.getRandomPalette(this.palettes, position).blocks(); - if ((!blockInfoList.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) - && this.size.getX() >= 1 -@@ -288,6 +305,20 @@ public class StructureTemplate { - level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); - } - -+ // CraftBukkit start -+ if (structureTransformer != null) { -+ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(level, blockPos, state, null); -+ if (blockInfo.nbt != null && craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState entityState) { -+ entityState.loadData(blockInfo.nbt); -+ if (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftLootable craftLootable) { -+ craftLootable.setSeed(random.nextLong()); -+ } -+ } -+ craftBlockState = structureTransformer.transformCraftState(craftBlockState); -+ state = craftBlockState.getHandle(); -+ blockInfo = new StructureTemplate.StructureBlockInfo(blockPos, state, (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState craftBlockEntityState ? craftBlockEntityState.getSnapshotNBT() : null)); -+ } -+ // CraftBukkit end - if (level.setBlock(blockPos, state, updateMode)) { - minX = Math.min(minX, blockPos.getX()); - minY = Math.min(minY, blockPos.getY()); -@@ -299,7 +330,7 @@ public class StructureTemplate { - if (blockInfo.nbt != null) { - BlockEntity blockEntity = level.getBlockEntity(blockPos); - if (blockEntity != null) { -- if (!SharedConstants.DEBUG_STRUCTURE_EDIT_MODE && blockEntity instanceof RandomizableContainer) { -+ if (structureTransformer == null && !SharedConstants.DEBUG_STRUCTURE_EDIT_MODE && blockEntity instanceof RandomizableContainer) { // CraftBukkit - only process if don't have a transformer access (Was already set above) - SPIGOT-7520: Use structureTransformer as check, so that it is the same as above - blockInfo.nbt.putLong("LootTableSeed", random.nextLong()); - } - -@@ -384,7 +415,11 @@ public class StructureTemplate { - if (blockInfox.getSecond() != null) { - BlockEntity blockEntity = level.getBlockEntity(blockPos); - if (blockEntity != null) { -- blockEntity.setChanged(); -+ // Paper start - Fix NBT pieces overriding a block entity during worldgen deadlock -+ if (!(level instanceof net.minecraft.world.level.WorldGenLevel)) { -+ blockEntity.setChanged(); -+ } -+ // Paper end - Fix NBT pieces overriding a block entity during worldgen deadlock - } - } - } -@@ -392,7 +427,7 @@ public class StructureTemplate { - - if (!settings.isIgnoreEntities()) { - this.placeEntities( -- level, -+ wrappedAccessor, // CraftBukkit - position, - settings.getMirror(), - settings.getRotation(), -@@ -512,14 +547,17 @@ public class StructureTemplate { - }); - } - } -+ - } - - private static Optional createEntityIgnoreException(final ProblemReporter reporter, final ServerLevelAccessor level, final CompoundTag tag) { -- try { -- return EntityType.create(TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), EntitySpawnReason.STRUCTURE); -- } catch (Exception var4) { -- return Optional.empty(); -- } -+ // CraftBukkit start -+ // try { -+ return EntityType.create(TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), EntitySpawnReason.STRUCTURE, true); // Paper - Don't fire sync event during generation -+ // } catch (Exception var4) { -+ // return Optional.empty(); -+ // } -+ // CraftBukkit end - } - - public Vec3i getSize(final Rotation rotation) { -@@ -710,6 +748,11 @@ public class StructureTemplate { - - tag.put("entities", entityList); - tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); -+ // CraftBukkit start - PDC -+ if (!this.persistentDataContainer.isEmpty()) { -+ tag.put("BukkitValues", this.persistentDataContainer.toTagCompound()); -+ } -+ // CraftBukkit end - return NbtUtils.addCurrentDataVersion(tag); - } - -@@ -735,6 +778,11 @@ public class StructureTemplate { - BlockPos blockPos = new BlockPos(blockPosTag.getIntOr(0, 0), blockPosTag.getIntOr(1, 0), blockPosTag.getIntOr(2, 0)); - entityTag.getCompound("nbt").ifPresent(nbt -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(pos, blockPos, nbt))); - }); -+ // CraftBukkit start - PDC -+ if (tag.get("BukkitValues") instanceof CompoundTag compoundTag) { -+ this.persistentDataContainer.putAll(compoundTag); -+ } -+ // CraftBukkit end - } - - private void loadPalette(final HolderGetter blockLookup, final ListTag paletteList, final ListTag blockList) { -@@ -834,7 +882,7 @@ public class StructureTemplate { - - public static final class Palette { - private final List blocks; -- private final Map> cache = Maps.newHashMap(); -+ private final Map> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads - private @Nullable List cachedJigsaws; - - private Palette(final List blocks) { diff --git a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch new file mode 100644 index 000000000000..3ca47e862d0e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch @@ -0,0 +1,96 @@ +--- a/net/minecraft/server/Bootstrap.java ++++ b/net/minecraft/server/Bootstrap.java +@@ -43,6 +_,7 @@ + if (!isBootstrapped) { + isBootstrapped = true; + Instant start = Instant.now(); ++ io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping + if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { + throw new IllegalStateException("Unable to load registries"); + } +@@ -56,10 +_,84 @@ + EntitySelectorOptions.bootStrap(); + DispenseItemBehavior.bootStrap(); + CauldronInteractions.bootStrap(); +- BuiltInRegistries.bootStrap(); ++ // Paper start ++ BuiltInRegistries.bootStrap(() -> { ++ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings ++ }); ++ // Paper end + CreativeModeTabs.validate(); + wrapStreams(); + bootstrapDuration.set(Duration.between(start, Instant.now()).toMillis()); ++ // CraftBukkit start ++ // TODO Check what of this is needed, maybe report it to Mojira. if deemed relevant, move to the respective classes ++ // Used in CraftLegacy ++ for (int i = 0; i <= 15; i++) { ++ net.minecraft.util.datafix.fixes.BlockStateData.register( ++ 1008 + i, ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:oak_sign", ++ "Properties", java.util.Map.of("rotation", String.valueOf(i)) ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:standing_sign", ++ "Properties", java.util.Map.of("rotation", String.valueOf(i)) ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) ++ ); ++ } ++ ++ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:portal", ++ "Properties", java.util.Map.of("axis", "x") ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:portal", ++ "Properties", java.util.Map.of("axis", "x") ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) ++ ); ++ ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(411, "minecraft:rabbit"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(412, "minecraft:cooked_rabbit"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(413, "minecraft:rabbit_stew"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(414, "minecraft:rabbit_foot"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(415, "minecraft:rabbit_hide"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(416, "minecraft:armor_stand"); ++ ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(423, "minecraft:mutton"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(424, "minecraft:cooked_mutton"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(425, "minecraft:banner"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(426, "minecraft:end_crystal"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(427, "minecraft:spruce_door"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(428, "minecraft:birch_door"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(429, "minecraft:jungle_door"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(430, "minecraft:acacia_door"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(431, "minecraft:dark_oak_door"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(432, "minecraft:chorus_fruit"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(433, "minecraft:chorus_fruit_popped"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(434, "minecraft:beetroot"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(435, "minecraft:beetroot_seeds"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(436, "minecraft:beetroot_soup"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(437, "minecraft:dragon_breath"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(438, "minecraft:splash_potion"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(439, "minecraft:spectral_arrow"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(440, "minecraft:tipped_arrow"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(441, "minecraft:lingering_potion"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(442, "minecraft:shield"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(443, "minecraft:elytra"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(444, "minecraft:spruce_boat"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(445, "minecraft:birch_boat"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(446, "minecraft:jungle_boat"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(447, "minecraft:acacia_boat"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(448, "minecraft:dark_oak_boat"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(449, "minecraft:totem_of_undying"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(450, "minecraft:shulker_shell"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(452, "minecraft:iron_nugget"); ++ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(453, "minecraft:knowledge_book"); ++ ++ net.minecraft.util.datafix.fixes.ItemSpawnEggFix.ID_TO_ENTITY[23] = "Arrow"; ++ // CraftBukkit end + } + } + diff --git a/paper-server/patches/rejected/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch similarity index 95% rename from paper-server/patches/rejected/net/minecraft/server/Main.java.patch rename to paper-server/patches/sources/net/minecraft/server/Main.java.patch index e8b62200d775..31e6c418b7de 100644 --- a/paper-server/patches/rejected/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee7945062099197c25 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -63,8 +63,10 @@ public class Main { +@@ -63,8 +_,10 @@ private static final Logger LOGGER = LogUtils.getLogger(); @SuppressForbidden(reason = "System.out needed before bootstrap") @@ -20,7 +12,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 OptionParser parser = new OptionParser(); OptionSpec nogui = parser.accepts("nogui"); OptionSpec initSettings = parser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -89,39 +91,95 @@ public class Main { +@@ -89,39 +_,95 @@ parser.printHelpOn(System.err); return; } @@ -124,7 +116,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(universePath.toPath()); LevelStorageSource.LevelStorageAccess access = levelStorageSource.validateAndCreateAccess(levelName); Dynamic levelDataTag; -@@ -149,13 +207,38 @@ public class Main { +@@ -149,13 +_,38 @@ } else { levelDataTag = null; } @@ -164,7 +156,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 WorldStem worldStem; try { -@@ -164,17 +247,31 @@ public class Main { +@@ -164,17 +_,31 @@ executor -> WorldLoader.load( worldLoadConfig, context -> { @@ -198,7 +190,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 } }, WorldStem::new, -@@ -191,6 +288,7 @@ public class Main { +@@ -190,6 +_,7 @@ return; } @@ -206,7 +198,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 RegistryAccess.Frozen registryHolder = worldStem.registries().compositeAccess(); WorldData data = worldStem.worldDataAndGenSettings().data(); boolean recreateRegionFilesValue = options.has(recreateRegionFiles); -@@ -199,22 +297,51 @@ public class Main { +@@ -198,22 +_,51 @@ } access.saveDataTag(data); @@ -261,13 +253,13 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 Thread shutdownThread = new Thread("Server Shutdown Thread") { @Override public void run() { -@@ -223,12 +350,13 @@ public class Main { +@@ -222,12 +_,13 @@ }; shutdownThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(shutdownThread); + */ // CraftBukkit end - } catch (Throwable var40) { - LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", var40); + } catch (Throwable t) { + LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", t); } } @@ -276,7 +268,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 final DedicatedServerSettings settings, final WorldLoader.DataLoadContext context, final Registry datapackDimensions, -@@ -299,7 +427,11 @@ public class Main { +@@ -298,7 +_,11 @@ final RegistryAccess registryAccess, final boolean recreateRegionFiles ) { @@ -289,7 +281,7 @@ index 395021fb2ed2b3f7da79b3f8e49f63d4f4dc075d..aa15c5c83f04e518c30a9dee79450620 try (WorldUpgrader upgrader = new WorldUpgrader(storageSource, fixerUpper, registryAccess, eraseCache, recreateRegionFiles)) { Component lastStatus = null; -@@ -327,5 +459,6 @@ public class Main { +@@ -326,5 +_,6 @@ } } } diff --git a/paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch similarity index 87% rename from paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch rename to paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index b7cf69f15fed..4da1ad2e1e0e 100644 --- a/paper-server/patches/rejected/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f155e986406 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -192,11 +192,13 @@ import org.jspecify.annotations.Nullable; +@@ -192,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements CommandSource, ServerInfo, ChunkIOErrorReporter { @@ -23,7 +15,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -219,7 +221,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); @@ -32,7 +24,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; private Consumer onMetricsRecordingStopped = results -> this.stopRecordingMetrics(); private Consumer onMetricsRecordingFinished = ignored -> {}; -@@ -227,7 +229,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -57,7 +49,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -272,7 +275,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 4) { thread.setPriority(8); } -@@ -309,7 +313,124 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop this.gameRules.setAll(g, null)); -+ // Paper - per-level WeatherData -+ // Paper - per-level GameRules - this.fixerUpper = fixerUpper; - this.functionManager = new ServerFunctionManager(this, this.resources.managers.getFunctionLibrary()); - HolderGetter blockLookup = this.registries -@@ -362,8 +483,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop this.gameRules.setAll(g, null)); ++ // Paper - per-level WeatherData ++ // Paper - per-level GameRules + this.fixerUpper = fixerUpper; + this.functionManager = new ServerFunctionManager(this, this.resources.managers.getFunctionLibrary()); +- HolderGetter blockLookup = this.registries.compositeAccess().lookupOrThrow(Registries.BLOCK).filterFeatures(this.worldData.enabledFeatures()); ++ HolderGetter blockLookup = this.registries ++ .compositeAccess() ++ .lookupOrThrow(Registries.BLOCK) ++ .filterFeatures(this.worldData.enabledFeatures()); + this.structureTemplateManager = new StructureTemplateManager(worldStem.resourceManager(), storageSource, fixerUpper, blockLookup); + this.serverThread = serverThread; + this.executor = Util.backgroundExecutor(); +@@ -360,7 +_,39 @@ + this.clockManager = this.getDataStorage().computeIfAbsent(ServerClockManager.TYPE); + this.clockManager.init(this); + this.customBossEvents = this.savedDataStorage.computeIfAbsent(CustomBossEvents.TYPE); +- this.scheduledEvents = this.savedDataStorage.computeIfAbsent(TimerQueue.TYPE); ++ // Paper - per-level scheduledEvents + // CraftBukkit start + this.options = options; + this.worldLoaderContext = worldLoaderContext; @@ -276,7 +275,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 + } catch (IOException ex) { + MinecraftServer.LOGGER.warn((String) null, ex); + } - } ++ } + */ + // Paper end + io.papermc.paper.log.LogManagerShutdownThread.unhook(); // Paper - Improved watchdog support @@ -286,7 +285,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 } protected abstract boolean initServer() throws IOException; -@@ -400,15 +553,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop overworldCustomSpawners = ImmutableList.of( - new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(this.savedDataStorage) -+ new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(savedDataStorage) // Paper - save to world data - ); +- ); - LevelStem overworldData = dimensions.getValue(LevelStem.OVERWORLD); - ServerLevel overworld = new ServerLevel( - this, this.executor, this.storageSource, levelData, Level.OVERWORLD, overworldData, isDebug, biomeZoomSeed, overworldCustomSpawners, true +- ); +- this.levels.put(Level.OVERWORLD, overworld); ++ new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(savedDataStorage) // Paper - save to world data ++ ); + final org.bukkit.generator.ChunkGenerator chunkGenerator = this.server.getGenerator(loading.data().bukkitName()); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(loading.data().bukkitName()); + final org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo( @@ -377,8 +379,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 + levelStem.generator(), + this.registryAccess(), + loading.data().uuid() - ); -- this.levels.put(Level.OVERWORLD, overworld); ++ ); + if (biomeProvider == null && chunkGenerator != null) { + biomeProvider = chunkGenerator.getDefaultBiomeProvider(worldInfo); + } @@ -468,9 +469,9 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 - this.setupDebugLevel(this.worldData); + this.setupDebugLevel(this.worldData, overworld); // Paper - per-level GameRules } - } catch (Throwable var20) { - CrashReport report = CrashReport.forThrowable(var20, "Exception initializing level"); -@@ -465,25 +735,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { TicketStorage savedTickets = level.getDataStorage().get(TicketStorage.TYPE); if (savedTickets != null) { -@@ -565,17 +842,19 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop sample = new ObjectArrayList<>(sampleSize); - int offset = Mth.nextInt(this.random, 0, players.size() - sampleSize); + } -@@ -1104,12 +1647,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop sample = new ObjectArrayList<>(sampleSize); + int offset = Mth.nextInt(this.random, 0, players.size() - sampleSize); + +@@ -1094,12 +_,46 @@ protected void tickChildren(final BooleanSupplier haveTime) { ProfilerFiller profiler = Profiler.get(); this.getPlayerList().getPlayers().forEach(playerx -> playerx.connection.suspendFlushing()); @@ -1149,7 +1150,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 profiler.pop(); } -@@ -1119,10 +1696,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop level + " " + level.dimension().identifier()); profiler.push("tick"); -@@ -1136,7 +1723,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> levelKeys() { return this.levels.keySet(); } -@@ -1230,7 +1842,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop result = CompletableFuture.supplyAsync( () -> packsToEnable.stream() .map(this.packRepository::getPack) -@@ -1534,7 +2179,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { CloseableResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, packsToLoad); @@ -1366,7 +1366,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 return ReloadableServerResources.loadResources( resources, this.registries, -@@ -1554,18 +2199,37 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { @@ -1406,7 +1406,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 }, this); if (this.isSameThread()) { this.managedBlock(result::isDone); -@@ -1580,7 +2244,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop selected, final FeatureFlagSet forcedFeatures, final boolean disableInactive ) { @@ -1424,7 +1424,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 enableForcedFeaturePacks(packRepository, forcedFeatures); DataPackConfig packConfig = getSelectedPacks(packRepository, disableInactive); FeatureFlagSet packRequestedFeatures = packRepository.getRequestedFeatureFlags().join(forcedFeatures); -@@ -1667,7 +2331,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entries = Lists.newArrayList(); - final GameRules gameRules = this.getGameRules(); + final GameRules gameRules = this.overworld().getGameRules(); // Paper - per-level GameRules gameRules.visitGameRuleTypes(new GameRuleTypeVisitor() { - { - Objects.requireNonNull(MinecraftServer.this); -@@ -1951,6 +2618,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop void visit(final GameRule gameRule) { +@@ -1937,6 +_,17 @@ } } @@ -1512,7 +1512,7 @@ index b5838c9ce1f128f3ba78de77d7557427863a95b3..d22f55c63eb950e1b979280612eb9f15 private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2071,16 +2749,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index dc817359a74b1c98e4fcc57aa7285e999520b175..4b3490181278e0b652077d8a523138ce26423873 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -50,9 +50,31 @@ public class ServerConnectionListener { +@@ -49,9 +_,31 @@ this.running = true; } @@ -41,10 +33,10 @@ index dc817359a74b1c98e4fcc57aa7285e999520b175..4b3490181278e0b652077d8a523138ce this.channels .add( new ServerBootstrap() -@@ -80,22 +102,64 @@ public class ServerConnectionListener { - Connection connection = (Connection)(rateLimitPacketsPerSecond > 0 +@@ -75,22 +_,64 @@ + Connection connection = rateLimitPacketsPerSecond > 0 ? new RateKickingConnection(rateLimitPacketsPerSecond) - : new Connection(PacketFlow.SERVERBOUND)); + : new Connection(PacketFlow.SERVERBOUND); - ServerConnectionListener.this.connections.add(connection); + // Paper start - Add support for Proxy Protocol + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.proxyProtocol) { @@ -108,7 +100,7 @@ index dc817359a74b1c98e4fcc57aa7285e999520b175..4b3490181278e0b652077d8a523138ce public SocketAddress startMemoryChannel() { ChannelFuture newChannel; synchronized (this.channels) { -@@ -151,12 +215,26 @@ public class ServerConnectionListener { +@@ -142,12 +_,26 @@ public void tick() { synchronized (this.connections) { @@ -134,8 +126,8 @@ index dc817359a74b1c98e4fcc57aa7285e999520b175..4b3490181278e0b652077d8a523138ce + // Paper end - Force kill connection ticking try { connection.tick(); - } catch (Exception var7) { -@@ -170,6 +248,7 @@ public class ServerConnectionListener { + } catch (Exception e) { +@@ -161,6 +_,7 @@ connection.setReadOnly(); } } else { diff --git a/paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch similarity index 95% rename from paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch rename to paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index a33e12f4c435..8a9fec619627 100644 --- a/paper-server/patches/rejected/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173b466817c 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -222,6 +222,38 @@ import net.minecraft.world.phys.shapes.VoxelShape; +@@ -222,6 +_,38 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -47,7 +39,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, -@@ -242,7 +274,9 @@ public class ServerGamePacketListenerImpl +@@ -242,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -57,7 +49,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -266,7 +300,23 @@ public class ServerGamePacketListenerImpl +@@ -266,7 +_,23 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -81,7 +73,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private int nextChatIndex; -@@ -275,6 +325,9 @@ public class ServerGamePacketListenerImpl +@@ -275,6 +_,9 @@ private boolean waitingForSwitchToConfig; private boolean waitingForRespawn; private int clientLoadedTimeoutTimer; @@ -91,11 +83,12 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 public ServerGamePacketListenerImpl(final MinecraftServer server, final Connection connection, final ServerPlayer player, final CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -284,8 +337,22 @@ public class ServerGamePacketListenerImpl +@@ -284,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); - this.chatMessageChain = new FutureChain(server); +- } + this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat + this.tickEndEvent = new io.papermc.paper.event.packet.ClientTickEndEvent(player.getBukkitEntity()); // Paper - add client tick end event + this.playerGameConnection = new io.papermc.paper.connection.PaperPlayerGameConnection(this); // Paper @@ -110,12 +103,12 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 + @Override + public net.kyori.adventure.audience.Audience getAudience() { + return this.getCraftPlayer(); - } ++ } + // Paper end - configuration phase API @Override public void tick() { -@@ -298,11 +365,13 @@ public class ServerGamePacketListenerImpl +@@ -298,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -130,7 +123,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } } -@@ -318,8 +387,8 @@ public class ServerGamePacketListenerImpl +@@ -318,8 +_,8 @@ this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -141,7 +134,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return true; } } else { -@@ -337,8 +406,8 @@ public class ServerGamePacketListenerImpl +@@ -337,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -152,7 +145,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return true; } } else { -@@ -351,6 +420,12 @@ public class ServerGamePacketListenerImpl +@@ -351,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -165,7 +158,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return false; } -@@ -416,11 +491,37 @@ public class ServerGamePacketListenerImpl +@@ -416,11 +_,37 @@ @Override public void handlePlayerInput(final ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -193,8 +186,9 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.hasClientLoaded()) { this.player.resetLastActionTime(); - this.player.setShiftKeyDown(packet.input().shift()); +- } + // this.player.setShiftKeyDown(packet.input().shift()); // Paper - move up and only set if event is not cancelled. - } ++ } + // Paper start - Add option to make parrots stay + if (packet.input().shift() && this.player.level().paperConfig().entities.behavior.parrotsAreUnaffectedByPlayerMovement) { + this.player.removeEntitiesOnShoulder(); @@ -204,7 +198,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } private static boolean containsInvalidValues(final double x, final double y, final double z, final float yRot, final float xRot) { -@@ -439,11 +540,23 @@ public class ServerGamePacketListenerImpl +@@ -439,11 +_,23 @@ public void handleMoveVehicle(final ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -229,7 +223,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 double oldX = vehicle.getX(); double oldY = vehicle.getY(); double oldZ = vehicle.getZ(); -@@ -457,7 +570,52 @@ public class ServerGamePacketListenerImpl +@@ -457,7 +_,52 @@ double zDist = targetZ - this.vehicleFirstGoodZ; double expectedDist = vehicle.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -283,7 +277,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 LOGGER.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", vehicle.getPlainTextName(), this.player.getPlainTextName(), xDist, yDist, zDist ); -@@ -466,9 +624,9 @@ public class ServerGamePacketListenerImpl +@@ -466,9 +_,9 @@ } AABB oldAABB = vehicle.getBoundingBox(); @@ -296,7 +290,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 boolean vehicleRestsOnSomething = vehicle.verticalCollisionBelow; if (vehicle instanceof LivingEntity livingVehicle && livingVehicle.onClimbable()) { livingVehicle.resetFallDistance(); -@@ -485,7 +643,7 @@ public class ServerGamePacketListenerImpl +@@ -485,7 +_,7 @@ zDist = targetZ - vehicle.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; boolean fail = false; @@ -305,7 +299,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 fail = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", vehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(movedDist)); } -@@ -498,6 +656,57 @@ public class ServerGamePacketListenerImpl +@@ -498,6 +_,57 @@ } vehicle.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); @@ -363,7 +357,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.level().getChunkSource().move(this.player); Vec3 clientDeltaMovement = new Vec3(vehicle.getX() - oldX, vehicle.getY() - oldY, vehicle.getZ() - oldZ); this.handlePlayerKnownMovement(clientDeltaMovement); -@@ -528,7 +737,7 @@ public class ServerGamePacketListenerImpl +@@ -528,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -372,7 +366,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return; } -@@ -545,13 +754,14 @@ public class ServerGamePacketListenerImpl +@@ -545,13 +_,14 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -388,7 +382,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } @Override -@@ -572,6 +782,7 @@ public class ServerGamePacketListenerImpl +@@ -572,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(final ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -396,7 +390,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -587,25 +798,112 @@ public class ServerGamePacketListenerImpl +@@ -587,25 +_,112 @@ } } @@ -513,7 +507,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = null; -@@ -666,7 +964,7 @@ public class ServerGamePacketListenerImpl +@@ -666,7 +_,7 @@ @Override public void handleSetCommandMinecart(final ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -522,7 +516,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -702,11 +1000,11 @@ public class ServerGamePacketListenerImpl +@@ -702,11 +_,11 @@ boolean includeData = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack itemStack = blockState.getCloneItemStack(level, pos, includeData); if (!itemStack.isEmpty()) { @@ -536,7 +530,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } } -@@ -733,7 +1031,7 @@ public class ServerGamePacketListenerImpl +@@ -733,7 +_,7 @@ if (entity != null && this.player.isWithinEntityInteractionRange(entity, 3.0)) { ItemStack itemStack = entity.getPickResult(); if (itemStack != null && !itemStack.isEmpty()) { @@ -545,7 +539,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } if (packet.includeData() && this.player.canUseGameMasterBlocks() && entity instanceof Avatar avatar) { -@@ -742,22 +1040,35 @@ public class ServerGamePacketListenerImpl +@@ -742,22 +_,35 @@ } } @@ -586,7 +580,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -790,7 +1101,7 @@ public class ServerGamePacketListenerImpl +@@ -790,7 +_,7 @@ @Override public void handleSetGameRule(final ServerboundSetGameRulePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -595,7 +589,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 LOGGER.warn("Player {} tried to set game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -808,7 +1119,7 @@ public class ServerGamePacketListenerImpl +@@ -808,7 +_,7 @@ private void setGameRuleValue(final GameRules gameRules, final GameRule rule, final String value) { rule.deserialize(value).result().ifPresent(parsedValue -> { @@ -604,7 +598,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.broadcastGameRuleChangeToOperators(rule, (T)parsedValue); }); } -@@ -967,6 +1278,13 @@ public class ServerGamePacketListenerImpl +@@ -967,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int selection = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu menu) { @@ -618,7 +612,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (!menu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, menu); return; -@@ -979,6 +1297,51 @@ public class ServerGamePacketListenerImpl +@@ -979,6 +_,51 @@ @Override public void handleEditBook(final ServerboundEditBookPacket packet) { @@ -670,7 +664,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List contents = Lists.newArrayList(); -@@ -993,10 +1356,14 @@ public class ServerGamePacketListenerImpl +@@ -993,10 +_,14 @@ } private void updateBookContents(final List contents, final int slot) { @@ -686,7 +680,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -1009,7 +1376,8 @@ public class ServerGamePacketListenerImpl +@@ -1009,7 +_,8 @@ writtenBook.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, pages, true) ); @@ -696,7 +690,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -1057,10 +1425,10 @@ public class ServerGamePacketListenerImpl +@@ -1057,10 +_,10 @@ public void handleMovePlayer(final ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -709,7 +703,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.tickCount == 0) { this.resetPosition(); } -@@ -1077,7 +1445,15 @@ public class ServerGamePacketListenerImpl +@@ -1077,7 +_,15 @@ if (this.player.isPassenger()) { this.player.absSnapTo(this.player.getX(), this.player.getY(), this.player.getZ(), targetYRot, targetXRot); this.player.level().getChunkSource().move(this.player); @@ -725,7 +719,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 double startX = this.player.getX(); double startY = this.player.getY(); double startZ = this.player.getZ(); -@@ -1086,6 +1462,16 @@ public class ServerGamePacketListenerImpl +@@ -1086,6 +_,16 @@ double zDist = targetZ - this.firstGoodZ; double expectedDist = this.player.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -742,7 +736,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.player.isSleeping()) { if (movedDist > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), targetYRot, targetXRot); -@@ -1095,7 +1481,13 @@ public class ServerGamePacketListenerImpl +@@ -1095,7 +_,13 @@ if (level.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int deltaPackets = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -757,7 +751,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 LOGGER.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.player.getPlainTextName(), -@@ -1103,30 +1495,96 @@ public class ServerGamePacketListenerImpl +@@ -1103,30 +_,96 @@ ); deltaPackets = 1; } @@ -863,7 +857,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 double oyDist = yDist; xDist = targetX - this.player.getX(); yDist = targetY - this.player.getY(); -@@ -1136,21 +1594,101 @@ public class ServerGamePacketListenerImpl +@@ -1136,21 +_,101 @@ zDist = targetZ - this.player.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -885,6 +879,12 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 + if (event.getLogWarning()) + // Paper end LOGGER.warn("{} moved wrongly!", this.player.getPlainTextName()); +- } +- +- if (this.player.noPhysics +- || this.player.isSleeping() +- || (!fail || !level.noCollision(this.player, oldAABB)) +- && !this.isEntityCollidingWithAnythingNew(level, this.player, oldAABB, targetX, targetY, targetZ)) { + } // Paper + } + @@ -896,7 +896,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 + if (event.isAllowed()) { + allowMovement = true; + } - } ++ } + if (allowMovement) { + // Paper end - Add fail move event + // CraftBukkit start - fire PlayerMoveEvent @@ -938,11 +938,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 + this.lastPosZ = to.getZ(); + this.lastYaw = to.getYaw(); + this.lastPitch = to.getPitch(); - -- if (this.player.noPhysics -- || this.player.isSleeping() -- || (!fail || !level.noCollision(this.player, oldAABB)) -- && !this.isEntityCollidingWithAnythingNew(level, this.player, oldAABB, targetX, targetY, targetZ)) { ++ + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); + this.cserver.getPluginManager().callEvent(event); @@ -972,7 +968,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = oyDist >= -0.03125 -@@ -1185,7 +1723,7 @@ public class ServerGamePacketListenerImpl +@@ -1185,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -981,7 +977,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player .doCheckFallDamage( this.player.getX() - startX, this.player.getY() - startY, this.player.getZ() - startZ, packet.isOnGround() -@@ -1223,6 +1761,7 @@ public class ServerGamePacketListenerImpl +@@ -1225,6 +_,7 @@ this.player.getXRot() ); } @@ -989,7 +985,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return true; } else { -@@ -1248,10 +1787,77 @@ public class ServerGamePacketListenerImpl +@@ -1250,10 +_,77 @@ } public void teleport(final double x, final double y, final double z, final float yRot, final float xRot) { @@ -1068,7 +1064,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1259,12 +1865,20 @@ public class ServerGamePacketListenerImpl +@@ -1261,12 +_,20 @@ this.player.teleportSetPosition(destination, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1089,7 +1085,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1289,32 +1903,95 @@ public class ServerGamePacketListenerImpl +@@ -1291,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack swap = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1187,8 +1183,8 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1332,9 +2009,36 @@ public class ServerGamePacketListenerImpl - } +@@ -1334,9 +_,36 @@ + && !player.getCooldowns().isOnCooldown(itemStack); } + // Paper start - limit place/interactions @@ -1224,7 +1220,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1343,6 +2047,11 @@ public class ServerGamePacketListenerImpl +@@ -1345,6 +_,11 @@ if (itemStack.isItemEnabled(level.enabledFeatures())) { BlockHitResult blockHit = packet.getHitResult(); Vec3 location = blockHit.getLocation(); @@ -1236,7 +1232,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 BlockPos pos = blockHit.getBlockPos(); if (this.player.isWithinBlockInteractionRange(pos, 1.0)) { Vec3 distance = location.subtract(Vec3.atCenterOf(pos)); -@@ -1357,9 +2066,13 @@ public class ServerGamePacketListenerImpl +@@ -1359,9 +_,13 @@ } else if (pos.getY() < minY) { this.player.sendBuildLimitMessage(false, minY); } else { @@ -1252,7 +1248,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, level, itemStack, hand, blockHit); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, blockHit.getBlockPos(), itemStack); -@@ -1371,7 +2084,7 @@ public class ServerGamePacketListenerImpl +@@ -1373,7 +_,7 @@ && wasBlockPlacementAttempt(this.player, itemStack)) { this.player.sendBuildLimitMessage(true, maxY); } else if (interactionResult instanceof InteractionResult.Success success @@ -1261,7 +1257,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.swing(hand, true); } -@@ -1385,6 +2098,15 @@ public class ServerGamePacketListenerImpl +@@ -1387,6 +_,15 @@ && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); } @@ -1277,7 +1273,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } else { this.player.sendBuildLimitMessage(true, maxY); } -@@ -1392,13 +2114,8 @@ public class ServerGamePacketListenerImpl +@@ -1394,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(level, pos)); this.send(new ClientboundBlockUpdatePacket(level, pos.relative(direction))); } @@ -1293,7 +1289,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } } -@@ -1408,6 +2125,8 @@ public class ServerGamePacketListenerImpl +@@ -1410,6 +_,8 @@ @Override public void handleUseItem(final ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1302,7 +1298,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1421,6 +2140,44 @@ public class ServerGamePacketListenerImpl +@@ -1423,6 +_,44 @@ this.player.absSnapRotationTo(targetYRot, targetXRot); } @@ -1347,7 +1343,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.player.gameMode.useItem(this.player, level, itemStack, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1436,7 +2193,7 @@ public class ServerGamePacketListenerImpl +@@ -1438,7 +_,7 @@ for (ServerLevel level : this.server.getAllLevels()) { Entity entity = packet.getEntity(level); if (entity != null) { @@ -1356,7 +1352,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 return; } } -@@ -1454,23 +2211,42 @@ public class ServerGamePacketListenerImpl +@@ -1456,23 +_,42 @@ @Override public void onDisconnect(final DisconnectionDetails details) { LOGGER.info("{} lost connection: {}", this.player.getPlainTextName(), details.reason().getString()); @@ -1399,9 +1395,9 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (packetSequenceNr < 0) { + this.disconnect(Component.literal("Expected packet sequence nr >= 0"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - Treat sequence violations like they should be throw new IllegalArgumentException("Expected packet sequence nr >= 0"); - } else { - this.ackBlockChangesUpTo = Math.max(packetSequenceNr, this.ackBlockChangesUpTo); -@@ -1480,20 +2256,38 @@ public class ServerGamePacketListenerImpl + } + +@@ -1482,20 +_,38 @@ @Override public void handleSetCarriedItem(final ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1440,7 +1436,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1505,25 +2299,45 @@ public class ServerGamePacketListenerImpl +@@ -1507,25 +_,45 @@ return; } @@ -1494,7 +1490,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 ParseResults parsed = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parsed)) { LOGGER.error( -@@ -1540,26 +2354,55 @@ public class ServerGamePacketListenerImpl +@@ -1542,26 +_,55 @@ Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1528,8 +1524,8 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 try { + // Paper - Always parse the original command to add to the chat chain signedArguments = this.collectSignedArguments(packet, SignableCommand.of(command), lastSeenMessages); - } catch (SignedMessageChain.DecodeException var6) { - this.handleMessageDecodeFailure(var6); + } catch (SignedMessageChain.DecodeException e) { + this.handleMessageDecodeFailure(e); return; } @@ -1553,7 +1549,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } private void handleMessageDecodeFailure(final SignedMessageChain.DecodeException e) { -@@ -1623,14 +2466,20 @@ public class ServerGamePacketListenerImpl +@@ -1625,14 +_,20 @@ return commands.parse(command, this.player.createCommandSourceStack()); } @@ -1578,16 +1574,16 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -1642,7 +2491,7 @@ public class ServerGamePacketListenerImpl +@@ -1644,7 +_,7 @@ var10000 = Optional.of(result); - } catch (LastSeenMessagesValidator.ValidationException var5) { - LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); + } catch (LastSeenMessagesValidator.ValidationException e) { + LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), e.getMessage()); - this.disconnect(CHAT_VALIDATION_FAILED); + this.disconnectAsync(CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes & add proper async disconnect return Optional.empty(); } -@@ -1660,22 +2509,81 @@ public class ServerGamePacketListenerImpl +@@ -1662,22 +_,81 @@ return false; } @@ -1675,16 +1671,16 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -1686,7 +2594,7 @@ public class ServerGamePacketListenerImpl +@@ -1688,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); - } catch (LastSeenMessagesValidator.ValidationException var5) { - LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); + } catch (LastSeenMessagesValidator.ValidationException e) { + LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), e.getMessage()); - this.disconnect(CHAT_VALIDATION_FAILED); + this.disconnectAsync(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes & add proper async disconnect } } } -@@ -1694,7 +2602,34 @@ public class ServerGamePacketListenerImpl +@@ -1696,7 +_,34 @@ @Override public void handleAnimate(final ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1719,7 +1715,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.swing(packet.getHand()); } -@@ -1702,6 +2637,21 @@ public class ServerGamePacketListenerImpl +@@ -1704,6 +_,21 @@ public void handlePlayerCommand(final ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.hasClientLoaded()) { @@ -1741,7 +1737,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1746,6 +2696,14 @@ public class ServerGamePacketListenerImpl +@@ -1748,6 +_,14 @@ } public void sendPlayerChatMessage(final PlayerChatMessage message, final ChatType.Bound chatType) { @@ -1756,7 +1752,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1768,9 +2726,11 @@ public class ServerGamePacketListenerImpl +@@ -1770,9 +_,11 @@ } if (trackedCount > 4096) { @@ -1769,7 +1765,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } public void sendDisguisedChatMessage(final Component content, final ChatType.Bound chatType) { -@@ -1781,6 +2741,17 @@ public class ServerGamePacketListenerImpl +@@ -1783,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1787,7 +1783,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1796,20 +2767,27 @@ public class ServerGamePacketListenerImpl +@@ -1798,20 +_,27 @@ @Override public void handleAttack(final ServerboundAttackPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1817,7 +1813,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 LOGGER.warn("Player {} tried to attack an invalid entity", this.player.getPlainTextName()); } else if (mainHandItem.isItemEnabled(level.enabledFeatures())) { if (!this.player.cannotAttackWithItem(mainHandItem, 5)) { -@@ -1819,25 +2797,88 @@ public class ServerGamePacketListenerImpl +@@ -1821,25 +_,88 @@ } } } @@ -1907,7 +1903,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.player.interactOn(target, hand, location) instanceof InteractionResult.Success success) { ItemStack awardedForStack = success.wasItemInteraction() ? usedItemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(this.player, awardedForStack, target); -@@ -1848,6 +2889,12 @@ public class ServerGamePacketListenerImpl +@@ -1850,6 +_,12 @@ } } } @@ -1920,7 +1916,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -1859,7 +2906,7 @@ public class ServerGamePacketListenerImpl +@@ -1861,7 +_,7 @@ ServerLevel level = this.player.level(); Entity target = level.getEntityOrPart(packet.entityId()); if (target != null && level.getWorldBorder().isWithinBounds(target.blockPosition())) { @@ -1929,7 +1925,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (target.isPickable()) { this.player.setCamera(target); } -@@ -1877,7 +2924,7 @@ public class ServerGamePacketListenerImpl +@@ -1879,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1938,7 +1934,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.resetPosition(); this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -1886,12 +2933,12 @@ public class ServerGamePacketListenerImpl +@@ -1888,12 +_,12 @@ return; } @@ -1954,7 +1950,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } break; -@@ -1904,7 +2951,7 @@ public class ServerGamePacketListenerImpl +@@ -1906,7 +_,7 @@ } private void sendGameRuleValues() { @@ -1963,7 +1959,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 LOGGER.warn("Player {} tried to request game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -1920,16 +2967,27 @@ public class ServerGamePacketListenerImpl +@@ -1922,16 +_,27 @@ @Override public void handleContainerClose(final ServerboundContainerClosePacket packet) { @@ -1993,7 +1989,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1945,7 +3003,298 @@ public class ServerGamePacketListenerImpl +@@ -1947,7 +_,298 @@ } else { boolean fullResyncNeeded = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2293,7 +2289,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 for (Entry e : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(e.getIntKey(), e.getValue()); -@@ -1958,6 +3307,8 @@ public class ServerGamePacketListenerImpl +@@ -1960,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2302,7 +2298,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } } -@@ -1965,6 +3316,14 @@ public class ServerGamePacketListenerImpl +@@ -1967,6 +_,14 @@ @Override public void handlePlaceRecipe(final ServerboundPlaceRecipePacket packet) { @@ -2317,7 +2313,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1981,9 +3340,44 @@ public class ServerGamePacketListenerImpl +@@ -1983,9 +_,44 @@ return; } @@ -2363,7 +2359,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, displayInfo.display().display())); } -@@ -1997,6 +3391,7 @@ public class ServerGamePacketListenerImpl +@@ -1999,6 +_,7 @@ @Override public void handleContainerButtonClick(final ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2371,7 +2367,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -2006,6 +3401,7 @@ public class ServerGamePacketListenerImpl +@@ -2008,6 +_,7 @@ if (clickAccepted) { this.player.containerMenu.broadcastChanges(); } @@ -2379,7 +2375,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } } -@@ -2022,10 +3418,48 @@ public class ServerGamePacketListenerImpl +@@ -2024,10 +_,48 @@ boolean validSlot = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean validData = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2428,7 +2424,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } else if (drop && validData) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -2039,15 +3473,38 @@ public class ServerGamePacketListenerImpl +@@ -2041,15 +_,38 @@ @Override public void handleSignUpdate(final ServerboundSignUpdatePacket packet) { @@ -2468,7 +2464,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (!(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) { return; } -@@ -2059,14 +3516,32 @@ public class ServerGamePacketListenerImpl +@@ -2061,14 +_,32 @@ @Override public void handlePlayerAbilities(final ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2502,7 +2498,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (this.player.isModelPartShown(PlayerModelPart.HAT) != wasHatShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2082,21 +3557,21 @@ public class ServerGamePacketListenerImpl +@@ -2084,21 +_,21 @@ packet.difficulty().getDisplayName() ); } else { @@ -2527,7 +2523,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } } -@@ -2116,7 +3591,7 @@ public class ServerGamePacketListenerImpl +@@ -2118,7 +_,7 @@ ProfilePublicKey.Data newProfileKey = newChatSession.profilePublicKey(); if (!Objects.equals(oldProfileKey, newProfileKey)) { if (oldProfileKey != null && newProfileKey.expiresAt().isBefore(oldProfileKey.expiresAt())) { @@ -2536,33 +2532,33 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 } else { try { SignatureValidator profileKeySignatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2127,8 +3602,8 @@ public class ServerGamePacketListenerImpl +@@ -2129,8 +_,8 @@ this.resetPlayerChatState(newChatSession.validate(this.player.getGameProfile(), profileKeySignatureValidator)); - } catch (ProfilePublicKey.ValidationException var6) { -- LOGGER.error("Failed to validate profile key: {}", var6.getMessage()); -- this.disconnect(var6.getComponent()); -+ // LOGGER.error("Failed to validate profile key: {}", var6.getMessage()); // Paper - Improve logging and errors -+ this.disconnect(var6.getComponent(), var6.kickCause); // Paper - kick event causes + } catch (ProfilePublicKey.ValidationException e) { +- LOGGER.error("Failed to validate profile key: {}", e.getMessage()); +- this.disconnect(e.getComponent()); ++ // LOGGER.error("Failed to validate profile key: {}", e.getMessage()); // Paper - Improve logging and errors ++ this.disconnect(e.getComponent(), e.kickCause); // Paper - kick event causes } } } -@@ -2139,11 +3614,13 @@ public class ServerGamePacketListenerImpl - if (!this.waitingForSwitchToConfig) { +@@ -2142,11 +_,13 @@ throw new IllegalStateException("Client acknowledged config, but none was requested"); - } else { -+ final ServerConfigurationPacketListenerImpl listener = new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())); // Paper - this.connection - .setupInboundProtocol( - ConfigurationProtocols.SERVERBOUND, -- new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())) -+ listener // Paper - ); -+ new io.papermc.paper.event.connection.configuration.PlayerConnectionReconfigureEvent(listener.paperConnection).callEvent(); // Paper } + ++ final ServerConfigurationPacketListenerImpl listener = new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())); // Paper + this.connection + .setupInboundProtocol( + ConfigurationProtocols.SERVERBOUND, +- new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())) ++ listener // Paper + ); ++ new io.papermc.paper.event.connection.configuration.PlayerConnectionReconfigureEvent(listener.paperConnection).callEvent(); // Paper } -@@ -2161,27 +3638,32 @@ public class ServerGamePacketListenerImpl + @Override +@@ -2163,27 +_,32 @@ private void resetPlayerChatState(final RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2596,7 +2592,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2213,12 +3695,23 @@ public class ServerGamePacketListenerImpl +@@ -2215,12 +_,23 @@ } public void tickClientLoadTimeout() { @@ -2622,7 +2618,7 @@ index 617af4bf845cd4e27e5e348b0e16edb6f6b9bd79..0ee19c162d495f152cbe4ad9f85c3173 this.clientLoadedTimeoutTimer = 0; } -@@ -2230,4 +3723,80 @@ public class ServerGamePacketListenerImpl +@@ -2232,4 +_,80 @@ this.waitingForRespawn = false; this.clientLoadedTimeoutTimer = 60; } diff --git a/paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch similarity index 91% rename from paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch rename to paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index cd1c9dc8702f..760d2c14f7ef 100644 --- a/paper-server/patches/rejected/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c058e79eb 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -46,9 +46,16 @@ import org.apache.commons.lang3.Validate; +@@ -46,9 +_,16 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -25,7 +17,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; private final MinecraftServer server; -@@ -56,10 +63,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -56,10 +_,14 @@ private final ServerActivityMonitor serverActivityMonitor; public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; @@ -42,7 +34,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c public ServerLoginPacketListenerImpl(final MinecraftServer minecraftserver, final Connection connection, final boolean transferred) { this.server = minecraftserver; -@@ -67,10 +78,19 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -67,10 +_,19 @@ this.serverActivityMonitor = this.server.getServerActivityMonitor(); this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); this.transferred = transferred; @@ -62,7 +54,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { this.verifyLoginAndFinishConnectionSetup(Objects.requireNonNull(this.authenticatedProfile)); } -@@ -80,16 +100,39 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -80,16 +_,39 @@ this.finishLoginAndWaitForClient(this.authenticatedProfile); } @@ -76,14 +68,14 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c + this.disconnectAsync(Component.translatable("multiplayer.disconnect.slow_login")); // Paper } } - ++ + // CraftBukkit start + @Deprecated + public void disconnect(String reason) { + this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(reason))); // Paper - Fix hex colors not working in some kick messages + } + // CraftBukkit end -+ + @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); @@ -103,7 +95,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c public void disconnect(final Component component) { try { LOGGER.info("Disconnecting {}: {}", this.getUserName(), component.getString()); -@@ -117,7 +160,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -117,7 +_,14 @@ @Override public void handleHello(final ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"); @@ -119,7 +111,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c this.requestedUsername = packet.name(); GameProfile singleplayerProfile = this.server.getSingleplayerProfile(); if (singleplayerProfile != null && this.requestedUsername.equalsIgnoreCase(singleplayerProfile.name())) { -@@ -127,7 +177,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -127,7 +_,30 @@ this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -151,7 +143,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c } } } -@@ -139,9 +212,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -139,9 +_,9 @@ private void verifyLoginAndFinishConnectionSetup(final GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -163,7 +155,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c } else { if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { this.connection -@@ -151,7 +224,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -151,7 +_,7 @@ ); } @@ -172,7 +164,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c if (waitForDisconnection) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -163,6 +236,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -163,6 +_,7 @@ private void finishLoginAndWaitForClient(final GameProfile gameProfile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; this.connection.send(new ClientboundLoginFinishedPacket(gameProfile)); @@ -180,17 +172,17 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c } @Override -@@ -186,7 +260,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - throw new IllegalStateException("Protocol error", var7); +@@ -186,7 +_,8 @@ + throw new IllegalStateException("Protocol error", e); } - Thread thread = new Thread("User Authenticator #" + UNIQUE_THREAD_ID.incrementAndGet()) { + // Paper start - Virtual authenticator threads + authenticatorPool.execute(new Runnable() { - { - Objects.requireNonNull(ServerLoginPacketListenerImpl.this); - } -@@ -202,12 +277,18 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + @Override + public void run() { + String name = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); +@@ -198,12 +_,18 @@ .hasJoinedServer(name, digest, this.getAddress()); if (result != null) { GameProfile profile = result.profile(); @@ -210,8 +202,8 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", name); -@@ -215,11 +296,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - } catch (AuthenticationUnavailableException var4) { +@@ -211,11 +_,16 @@ + } catch (AuthenticationUnavailableException ignored) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); - ServerLoginPacketListenerImpl.this.startClientVerification(UUIDUtil.createOfflineProfile(name)); @@ -229,13 +221,14 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c } } -@@ -229,18 +315,123 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -225,18 +_,123 @@ ? ((InetSocketAddress)remoteAddress).getAddress() : null; } - }; - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); - thread.start(); +- } + }); + // Paper end - Virtual authenticator threads + } @@ -288,7 +281,7 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c + } + } + return gameprofile; // Paper - Add more fields to AsyncPlayerPreLoginEvent - } ++ } + // CraftBukkit end @Override @@ -356,14 +349,14 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie cookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); -@@ -257,9 +448,32 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -253,8 +_,31 @@ @Override public void handleCookieResponse(final ServerboundCookieResponsePacket packet) { + if (this.paperLoginConnection.handleCookieResponse(packet)) return; // Paper this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } - ++ + // Spigot start + protected GameProfile createOfflineProfile(String s) { + java.util.UUID uuid; @@ -385,7 +378,6 @@ index b69f8830f0eeebc09ccc2470fedb75b613e0e12b..c1edad046cbdd1627edba58bc06aef5c + return new GameProfile(uuid, s, new com.mojang.authlib.properties.PropertyMap(props.build())); + } + // Spigot end -+ - public static enum State { + + public enum State { HELLO, - KEY, diff --git a/paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch similarity index 77% rename from paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch rename to paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch index 37e5b19413ea..58fa1ee0631f 100644 --- a/paper-server/patches/rejected/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/players/CachedUserNameToIdResolver.java b/net/minecraft/server/players/CachedUserNameToIdResolver.java -index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f2872e7a5dbb 100644 --- a/net/minecraft/server/players/CachedUserNameToIdResolver.java +++ b/net/minecraft/server/players/CachedUserNameToIdResolver.java -@@ -46,6 +46,10 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -46,6 +_,10 @@ private final Gson gson = new GsonBuilder().create(); private final File file; private final AtomicLong operationCount = new AtomicLong(); @@ -19,7 +11,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 public CachedUserNameToIdResolver(final GameProfileRepository profileRepository, final File file) { this.profileRepository = profileRepository; -@@ -54,23 +58,27 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -54,10 +_,12 @@ } private void safeAdd(final CachedUserNameToIdResolver.GameProfileInfo profileInfo) { @@ -32,15 +24,15 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 } private Optional lookupGameProfile(final GameProfileRepository profileRepository, final String name) { - if (!StringUtil.isValidPlayerName(name)) { +@@ -65,12 +_,14 @@ return this.createUnknownProfile(name); - } else { -- Optional profile = profileRepository.findProfileByName(name).map(NameAndId::new); -+ final boolean shouldLookup = !org.apache.commons.lang3.StringUtils.isBlank(name) // Paper - Don't lookup a profile with a blank name -+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode(); // Paper - Add setting for proxy online mode status -+ Optional profile = shouldLookup ? profileRepository.findProfileByName(name).map(NameAndId::new) : Optional.empty(); // Paper - Don't lookup a profile with a blank name - return profile.isEmpty() ? this.createUnknownProfile(name) : profile; } + +- Optional profile = profileRepository.findProfileByName(name).map(NameAndId::new); ++ final boolean shouldLookup = !org.apache.commons.lang3.StringUtils.isBlank(name) // Paper - Don't lookup a profile with a blank name ++ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode(); // Paper - Add setting for proxy online mode status ++ Optional profile = shouldLookup ? profileRepository.findProfileByName(name).map(NameAndId::new) : Optional.empty(); // Paper - Don't lookup a profile with a blank name + return profile.isEmpty() ? this.createUnknownProfile(name) : profile; } private Optional createUnknownProfile(final String name) { @@ -49,7 +41,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 } @Override -@@ -90,7 +98,7 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -90,7 +_,7 @@ Date expirationDate = c.getTime(); CachedUserNameToIdResolver.GameProfileInfo profileInfo = new CachedUserNameToIdResolver.GameProfileInfo(profile, expirationDate); this.safeAdd(profileInfo); @@ -58,7 +50,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 return profileInfo; } -@@ -98,9 +106,24 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -98,9 +_,24 @@ return this.operationCount.incrementAndGet(); } @@ -83,7 +75,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 CachedUserNameToIdResolver.GameProfileInfo profileInfo = this.profilesByName.get(userName); boolean needsSave = false; if (profileInfo != null && new Date().getTime() >= profileInfo.expirationDate.getTime()) { -@@ -114,8 +137,13 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -114,8 +_,13 @@ if (profileInfo != null) { profileInfo.setLastAccess(this.getNextOperation()); result = Optional.of(profileInfo.nameAndId()); @@ -98,7 +90,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 if (profile.isPresent()) { result = Optional.of(this.addInternal(profile.get()).nameAndId()); needsSave = false; -@@ -124,15 +152,17 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -124,15 +_,17 @@ } } @@ -118,27 +110,27 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 CachedUserNameToIdResolver.GameProfileInfo profileInfo = this.profilesByUUID.get(id); if (profileInfo == null) { return Optional.empty(); -@@ -140,6 +170,7 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { - profileInfo.setLastAccess(this.getNextOperation()); - return Optional.of(profileInfo.nameAndId()); - } +@@ -140,6 +_,7 @@ + + profileInfo.setLastAccess(this.getNextOperation()); + return Optional.of(profileInfo.nameAndId()); + } finally { this.stateLock.unlock(); } // Paper - Fix GameProfileCache concurrency } private static DateFormat createDateFormat() { -@@ -164,6 +195,11 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { - - return (List)var9; +@@ -158,6 +_,11 @@ + DateFormat dateFormat = createDateFormat(); + entryList.forEach(element -> readGameProfile(element, dateFormat).ifPresent(result::add)); } catch (FileNotFoundException var7) { + // Spigot start + } catch (com.google.gson.JsonSyntaxException | NullPointerException ex) { + LOGGER.warn("Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues."); + this.file.delete(); + // Spigot end - } catch (JsonParseException | IOException var8) { - LOGGER.warn("Failed to load profile cache {}", this.file, var8); + } catch (IOException | JsonParseException e) { + LOGGER.warn("Failed to load profile cache {}", this.file, e); } -@@ -173,23 +209,51 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -167,23 +_,51 @@ @Override public void save() { @@ -153,7 +145,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 DateFormat dateFormat = createDateFormat(); - this.getTopMRUProfiles(1000).forEach(entry -> entryList.add(writeGameProfile(entry, dateFormat))); + this.listTopMRUProfiles(org.spigotmc.SpigotConfig.userCacheCap).forEach(entry -> entryList.add(writeGameProfile(entry, dateFormat))); // Spigot // Paper - Fix GameProfileCache concurrency - String toSave = this.gson.toJson((JsonElement)entryList); + String toSave = this.gson.toJson(entryList); + Runnable save = () -> { // Paper - Perf: Async GameProfileCache saving try (Writer writer = Files.newWriter(this.file, StandardCharsets.UTF_8)) { @@ -175,6 +167,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 - .stream() - .sorted(Comparator.comparing(CachedUserNameToIdResolver.GameProfileInfo::lastAccess).reversed()) - .limit(limit); +- } + // Paper start - Fix GameProfileCache concurrency + return this.listTopMRUProfiles(limit).stream(); + } @@ -190,7 +183,7 @@ index 58d5a1f2da3bb7b63b876cda1dfb3545ad33268e..aecbdddf4cf3ab627477156cd314f287 + } finally { + this.stateLock.unlock(); + } - } ++ } + // Paper end - Fix GameProfileCache concurrency private static JsonElement writeGameProfile(final CachedUserNameToIdResolver.GameProfileInfo src, final DateFormat dateFormat) { diff --git a/paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch similarity index 80% rename from paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch rename to paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch index 510c98c704ba..f9eb3fd9e170 100644 --- a/paper-server/patches/rejected/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/players/OldUsersConverter.java b/net/minecraft/server/players/OldUsersConverter.java -index e6946327048187e4704feb91d24ab9d77590a501..82cef084ebdb4d42eb8ace1e6b0e595074928a87 100644 --- a/net/minecraft/server/players/OldUsersConverter.java +++ b/net/minecraft/server/players/OldUsersConverter.java -@@ -50,7 +50,8 @@ public class OldUsersConverter { +@@ -50,7 +_,8 @@ private static void lookupPlayers(final MinecraftServer server, final Collection names, final ProfileLookupCallback callback) { String[] filteredNames = names.stream().filter(s -> !StringUtil.isNullOrEmpty(s)).toArray(String[]::new); @@ -18,43 +10,43 @@ index e6946327048187e4704feb91d24ab9d77590a501..82cef084ebdb4d42eb8ace1e6b0e5950 server.services().profileRepository().findProfilesByNames(filteredNames, callback); } else { for (String name : filteredNames) { -@@ -66,7 +67,7 @@ public class OldUsersConverter { +@@ -66,7 +_,7 @@ try { bans.load(); - } catch (IOException var6) { -- LOGGER.warn("Could not load existing file {}", bans.getFile().getName(), var6); + } catch (IOException e) { +- LOGGER.warn("Could not load existing file {}", bans.getFile().getName(), e); + LOGGER.warn("Could not load existing file {}", bans.getFile().getName()); // CraftBukkit - don't print stacktrace } } -@@ -122,7 +123,7 @@ public class OldUsersConverter { +@@ -122,7 +_,7 @@ try { ipBans.load(); - } catch (IOException var11) { -- LOGGER.warn("Could not load existing file {}", ipBans.getFile().getName(), var11); + } catch (IOException e) { +- LOGGER.warn("Could not load existing file {}", ipBans.getFile().getName(), e); + LOGGER.warn("Could not load existing file {}", ipBans.getFile().getName()); // CraftBukkit - don't print stacktrace } } -@@ -158,7 +159,7 @@ public class OldUsersConverter { +@@ -158,7 +_,7 @@ try { opsList.load(); - } catch (IOException var6) { -- LOGGER.warn("Could not load existing file {}", opsList.getFile().getName(), var6); + } catch (IOException e) { +- LOGGER.warn("Could not load existing file {}", opsList.getFile().getName(), e); + LOGGER.warn("Could not load existing file {}", opsList.getFile().getName()); // CraftBukkit - don't print stacktrace } } -@@ -203,7 +204,7 @@ public class OldUsersConverter { +@@ -203,7 +_,7 @@ try { whitelist.load(); - } catch (IOException var6) { -- LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName(), var6); + } catch (IOException e) { +- LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName(), e); + LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName()); // CraftBukkit - don't print stacktrace } } -@@ -317,6 +318,35 @@ public class OldUsersConverter { +@@ -317,6 +_,35 @@ private void movePlayerFile(final File directory, final String oldName, final String newName) { File oldFileName = new File(worldPlayerDirectory, oldName + ".dat"); File newFileName = new File(directory, newName + ".dat"); diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch index 4a7750de5378..2f8f7ce9781c 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/Goal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/goal/Goal.java b/net/minecraft/world/entity/ai/goal/Goal.java -index aafe6895709831d64733586122de1e777862c005..5746eefd9e8fa851e74ccf6b5d889a9f8e6fc1e0 100644 --- a/net/minecraft/world/entity/ai/goal/Goal.java +++ b/net/minecraft/world/entity/ai/goal/Goal.java -@@ -46,6 +46,17 @@ public abstract class Goal { +@@ -46,6 +_,17 @@ return this.flags; } @@ -26,7 +18,7 @@ index aafe6895709831d64733586122de1e777862c005..5746eefd9e8fa851e74ccf6b5d889a9f protected int adjustedTickDelay(final int ticks) { return this.requiresUpdateEveryTick() ? ticks : reducedTickDelay(ticks); } -@@ -62,7 +73,19 @@ public abstract class Goal { +@@ -62,7 +_,19 @@ return (ServerLevel)level; } @@ -41,7 +33,7 @@ index aafe6895709831d64733586122de1e777862c005..5746eefd9e8fa851e74ccf6b5d889a9f + } + // Paper end - Mob goal api + - public static enum Flag { + public enum Flag { + UNKNOWN_BEHAVIOR, // Paper - add UNKNOWN_BEHAVIOR MOVE, LOOK, diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch similarity index 57% rename from paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 49d7c53ee089..a5f1d9673c95 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -index 8cc8b775bd8d111148cfc04f384ad65a1ffb4dac..ca91cadd8d52c09a735e6447664bed4753f3cdd3 100644 --- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -@@ -101,6 +101,11 @@ public class RemoveBlockGoal extends MoveToBlockGoal { +@@ -101,6 +_,11 @@ } if (this.ticksSinceReachedGoal > 60) { @@ -20,7 +12,7 @@ index 8cc8b775bd8d111148cfc04f384ad65a1ffb4dac..ca91cadd8d52c09a735e6447664bed47 level.removeBlock(eatPos, false); if (!level.isClientSide()) { for (int i = 0; i < 20; i++) { -@@ -119,13 +124,16 @@ public class RemoveBlockGoal extends MoveToBlockGoal { +@@ -119,14 +_,17 @@ } private @Nullable BlockPos getPosWithBlock(final BlockPos pos, final BlockGetter level) { @@ -29,17 +21,18 @@ index 8cc8b775bd8d111148cfc04f384ad65a1ffb4dac..ca91cadd8d52c09a735e6447664bed47 + if (state == null) return null; // Paper - Prevent AI rules from loading chunks + if (state.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks return pos; - } else { - BlockPos[] neighbours = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; + } - for (BlockPos neighborPos : neighbours) { -- if (level.getBlockState(neighborPos).is(this.blockToRemove)) { -+ net.minecraft.world.level.block.state.BlockState neighborState = level.getBlockStateIfLoaded(neighborPos); // Paper - Prevent AI rules from loading chunks -+ if (neighborState != null && neighborState.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks - return neighborPos; - } + BlockPos[] neighbours = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; + + for (BlockPos neighborPos : neighbours) { +- if (level.getBlockState(neighborPos).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState neighborState = level.getBlockStateIfLoaded(neighborPos); // Paper - Prevent AI rules from loading chunks ++ if (neighborState != null && neighborState.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return neighborPos; } -@@ -136,7 +144,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal { + } +@@ -136,7 +_,7 @@ @Override protected boolean isValidTarget(final LevelReader level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch new file mode 100644 index 000000000000..c1bb12ba5eae --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java +@@ -96,7 +_,7 @@ + } + + if (target instanceof LivingEntity) { +- ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this); ++ ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + } + + return true; +@@ -111,6 +_,6 @@ + + @Override + public boolean canBeAffected(final MobEffectInstance newEffect) { +- return !newEffect.is(MobEffects.WITHER) && super.canBeAffected(newEffect); ++ return (!newEffect.is(MobEffects.WITHER) || !this.level().paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton) && super.canBeAffected(newEffect); // Paper - Add config for mobs immune to default effects + } + } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch similarity index 86% rename from paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch index 6f85aeca7f8e..440b9cd9aef2 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java -index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9ef5e0dbb4 100644 --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -63,6 +63,12 @@ import net.minecraft.world.phys.Vec3; +@@ -63,6 +_,12 @@ import org.jspecify.annotations.Nullable; public class Raid { @@ -21,7 +13,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityType.RAVAGER); public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( i -> i.group( -@@ -78,6 +84,8 @@ public class Raid { +@@ -78,6 +_,8 @@ Raid.RaidStatus.CODEC.fieldOf("status").forGetter(r -> r.status), BlockPos.CODEC.fieldOf("center").forGetter(r -> r.center), UUIDUtil.CODEC_SET.fieldOf("heroes_of_the_village").forGetter(r -> r.heroesOfTheVillage) @@ -30,7 +22,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e ) .apply(i, Raid::new) ); -@@ -131,6 +139,7 @@ public class Raid { +@@ -131,6 +_,7 @@ this.center = center; this.numGroups = this.getNumGroups(difficulty); this.status = Raid.RaidStatus.ONGOING; @@ -38,7 +30,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e } private Raid( -@@ -146,6 +155,7 @@ public class Raid { +@@ -146,6 +_,7 @@ final Raid.RaidStatus status, final BlockPos center, final Set heroesOfTheVillage @@ -46,7 +38,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e ) { this.started = started; this.active = active; -@@ -159,6 +169,7 @@ public class Raid { +@@ -159,6 +_,7 @@ this.numGroups = numGroups; this.status = status; this.heroesOfTheVillage.addAll(heroesOfTheVillage); @@ -54,7 +46,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e } public boolean isOver() { -@@ -185,6 +196,12 @@ public class Raid { +@@ -185,6 +_,12 @@ return this.status == Raid.RaidStatus.LOSS; } @@ -67,7 +59,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e public float getTotalHealth() { return this.totalHealth; } -@@ -271,6 +288,7 @@ public class Raid { +@@ -271,6 +_,7 @@ boolean oldActive = this.active; this.active = level.hasChunkAt(this.center); if (level.getDifficulty() == Difficulty.PEACEFUL) { @@ -75,7 +67,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e this.stop(); return; } -@@ -290,13 +308,16 @@ public class Raid { +@@ -290,13 +_,16 @@ if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; @@ -92,7 +84,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e this.stop(); return; } -@@ -385,6 +406,7 @@ public class Raid { +@@ -385,6 +_,7 @@ } if (attempt > 5) { @@ -100,7 +92,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e this.stop(); break; } -@@ -396,6 +418,7 @@ public class Raid { +@@ -396,6 +_,7 @@ } else { this.status = Raid.RaidStatus.VICTORY; @@ -108,7 +100,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e for (UUID heroUUID : this.heroesOfTheVillage) { Entity entity = level.getEntity(heroUUID); if (entity instanceof LivingEntity hero && !entity.isSpectator()) { -@@ -403,9 +426,11 @@ public class Raid { +@@ -403,9 +_,11 @@ if (hero instanceof ServerPlayer playerHero) { playerHero.awardStat(Stats.RAID_WIN); CriteriaTriggers.RAID_WIN.trigger(playerHero); @@ -120,7 +112,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e } } -@@ -413,6 +438,7 @@ public class Raid { +@@ -413,6 +_,7 @@ } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { @@ -128,7 +120,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e this.stop(); return; } -@@ -568,6 +594,7 @@ public class Raid { +@@ -568,6 +_,7 @@ this.groupsSpawned++; this.updateBossbar(); this.setDirty(level); @@ -136,7 +128,7 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e } public void joinRaid(final ServerLevel level, final int groupNumber, final Raider raider, final @Nullable BlockPos pos, final boolean exists) { -@@ -582,7 +609,7 @@ public class Raid { +@@ -582,7 +_,7 @@ raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); raider.applyRaidBuffs(level, groupNumber, false); raider.setOnGround(true); @@ -145,16 +137,16 @@ index ba709ebb916b9e6b5144602b8bb28c99e25fb34c..130cc6769c8a21ea0a0eabacacf77d9e } } } -@@ -810,6 +837,12 @@ public class Raid { +@@ -809,6 +_,12 @@ + public void addHeroOfTheVillage(final Entity killer) { this.heroesOfTheVillage.add(killer.getUUID()); } - ++ + // CraftBukkit start - a method to get all raiders + public java.util.Collection getRaiders() { + return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); + } + // CraftBukkit end -+ - private static enum RaidStatus implements StringRepresentable { + + private enum RaidStatus implements StringRepresentable { ONGOING("ongoing"), - VICTORY("victory"), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch new file mode 100644 index 000000000000..74239c4658d8 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/world/entity/raid/Raids.java ++++ b/net/minecraft/world/entity/raid/Raids.java +@@ -52,6 +_,7 @@ + private Raids(final List raids, final int nextId, final int tick) { + for (Raids.RaidWithId raid : raids) { + this.raidMap.put(raid.id, raid.raid); ++ raid.raid.idOrNegativeOne = raid.id; // Paper - expose id of raids while method is kept around as deprecated for removal + } + + this.nextId = nextId; +@@ -132,11 +_,23 @@ + } + + Raid raid = this.getOrCreateRaid(level, raidCenterPos); +- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { +- this.raidMap.put(this.getUniqueId(), raid); +- } +- +- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { ++ // CraftBukkit - moved down ++ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ // this.raidMap.put(this.getUniqueId(), raid); ++ // } ++ ++ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(level, raid, player)) { ++ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); ++ return null; ++ } ++ ++ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ this.raidMap.put(this.getUniqueId(), raid); ++ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal ++ } ++ // CraftBukkit end + raid.absorbRaidOmen(player); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch new file mode 100644 index 000000000000..8ade0ce1da95 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -0,0 +1,164 @@ +--- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java ++++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java +@@ -150,6 +_,12 @@ + @Override + protected boolean triggerEvent(final BlockState state, final Level level, final BlockPos pos, final int b0, final int b1) { + Direction direction = state.getValue(FACING); ++ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; prevent retracting when we're facing the wrong way (we were replaced before retraction could occur) ++ Direction directionQueuedAs = Direction.from3DDataValue(b1 & 7); // Paper - copied from below ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits && direction != directionQueuedAs) { ++ return false; ++ } ++ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed + BlockState extendedState = state.setValue(EXTENDED, true); + if (!level.isClientSide()) { + boolean extend = this.getNeighborSignal(level, pos, direction); +@@ -182,10 +_,17 @@ + .defaultBlockState() + .setValue(MovingPistonBlock.FACING, direction) + .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); ++ // Paper start - Fix sticky pistons and BlockPistonRetractEvent; Move empty piston retract call to fix multiple event fires ++ if (!this.isSticky) { ++ if (!new org.bukkit.event.block.BlockPistonRetractEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), java.util.Collections.emptyList(), org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)).callEvent()) { ++ return false; ++ } ++ } ++ // Paper end - Fix sticky pistons and BlockPistonRetractEvent + level.setBlock(pos, movingPistonState, Block.UPDATE_NONE | Block.UPDATE_KNOWN_SHAPE); + level.setBlockEntity( + MovingPistonBlock.newMovingBlockEntity( +- pos, movingPistonState, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(b1 & 7)), direction, false, true ++ pos, movingPistonState, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(b1 & 7)), direction, false, true // Paper - Protect Bedrock and End Portal/Frames from being destroyed; diff on change + ) + ); + level.updateNeighborsAt(pos, movingPistonState.getBlock()); +@@ -209,13 +_,27 @@ + || movingState.getPistonPushReaction() != PushReaction.NORMAL + && !movingState.is(Blocks.PISTON) + && !movingState.is(Blocks.STICKY_PISTON)) { ++ // Paper start - Fix sticky pistons and BlockPistonRetractEvent; fire BlockPistonRetractEvent for sticky pistons retracting nothing (air) ++ if (b0 == TRIGGER_CONTRACT && movingState.isAir()) { ++ if (!new org.bukkit.event.block.BlockPistonRetractEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), java.util.Collections.emptyList(), org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)).callEvent()) { ++ return false; ++ } ++ } ++ // Paper end - Fix sticky pistons and BlockPistonRetractEvent + level.removeBlock(pos.relative(direction), false); + } else { + this.moveBlocks(level, pos, direction, false); + } + } + } else { +- level.removeBlock(pos.relative(direction), false); ++ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; fix headless pistons breaking blocks ++ BlockPos headPos = pos.relative(direction); ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits || level.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, direction)) { // double check to make sure we're not a headless piston ++ level.removeBlock(headPos, false); ++ } else { ++ ((ServerLevel) level).getChunkSource().blockChanged(headPos); // ... fix client desync ++ } ++ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed + } + + level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.15F + 0.6F); +@@ -233,7 +_,7 @@ + final boolean allowDestroyable, + final Direction connectionDirection + ) { +- if (pos.getY() < level.getMinY() || pos.getY() > level.getMaxY() || !level.getWorldBorder().isWithinBounds(pos)) { ++ if (pos.getY() < level.getMinY() || pos.getY() > level.getMaxY() || !level.getWorldBorder().isWithinBounds(pos) || !level.getWorldBorder().isWithinBounds(pos.relative(direction))) { // Paper - Fix piston world border check + return false; + } + +@@ -298,12 +_,58 @@ + BlockState[] toUpdate = new BlockState[toPush.size() + toDestroy.size()]; + Direction pushDirection = extending ? direction : direction.getOpposite(); + int updateIndex = 0; ++ // CraftBukkit start ++ final org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pistonPos); ++ ++ final List moved = resolver.getToPush(); ++ final List broken = resolver.getToDestroy(); ++ ++ List blocks = new java.util.AbstractList<>() { ++ ++ @Override ++ public int size() { ++ return moved.size() + broken.size(); ++ } ++ ++ @Override ++ public org.bukkit.block.Block get(int index) { ++ if (index >= this.size() || index < 0) { ++ throw new ArrayIndexOutOfBoundsException(index); ++ } ++ ++ BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size()); ++ return org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ } ++ }; ++ ++ final org.bukkit.event.block.BlockPistonEvent event; ++ if (extending) { ++ event = new org.bukkit.event.block.BlockPistonExtendEvent( ++ bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(pushDirection) ++ ); ++ } else { ++ event = new org.bukkit.event.block.BlockPistonRetractEvent( ++ bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(pushDirection) ++ ); ++ } ++ if (!event.callEvent()) { ++ for (BlockPos brokenPos : broken) { ++ level.sendBlockUpdated(brokenPos, Blocks.AIR.defaultBlockState(), level.getBlockState(brokenPos), Block.UPDATE_ALL); ++ } ++ for (BlockPos movedPos : moved) { ++ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); ++ movedPos = movedPos.relative(pushDirection); ++ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); ++ } ++ return false; ++ } ++ // CraftBukkit end + + for (int i = toDestroy.size() - 1; i >= 0; i--) { + BlockPos pos = toDestroy.get(i); + BlockState state = level.getBlockState(pos); + BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; +- dropResources(state, level, pos, blockEntity); ++ dropResources(state, level, pos, blockEntity, pistonPos); // Paper - Add BlockBreakBlockEvent + if (!state.is(BlockTags.FIRE) && level.isClientSide()) { + level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, getId(state)); + } +@@ -314,13 +_,28 @@ + } + + for (int i = toPush.size() - 1; i >= 0; i--) { +- BlockPos pos = toPush.get(i); +- BlockState blockState = level.getBlockState(pos); ++ // Paper start - fix a variety of piston desync dupes ++ boolean allowDesync = io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication; ++ BlockPos oldPos = toPush.get(i); ++ BlockPos pos = oldPos; ++ BlockState blockState = allowDesync ? level.getBlockState(oldPos) : null; ++ // Paper end - fix a variety of piston desync dupes + pos = pos.relative(pushDirection); + deleteAfterMove.remove(pos); + BlockState actualState = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, direction); + level.setBlock(pos, actualState, Block.UPDATE_NONE | Block.UPDATE_MOVE_BY_PISTON); +- level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, actualState, toPushShapes.get(i), direction, extending, false)); ++ // Paper start - fix a variety of piston desync dupes ++ if (!allowDesync) { ++ blockState = level.getBlockState(oldPos); ++ deleteAfterMove.replace(oldPos, blockState); ++ } ++ level.setBlockEntity( ++ MovingPistonBlock.newMovingBlockEntity(pos, actualState, allowDesync ? toPushShapes.get(i) : blockState, direction, extending, false) ++ ); ++ if (!allowDesync) { ++ level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_SKIP_ON_PLACE); // set air to prevent later physics updates from seeing this block ++ } ++ // Paper end - fix a variety of piston desync dupes + toUpdate[updateIndex++] = blockState; + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index 452a15e6f68c..53d9cfcd3596 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420e396540d 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -105,8 +105,8 @@ public abstract class ChunkGenerator { +@@ -105,8 +_,8 @@ protected abstract MapCodec codec(); @@ -19,7 +11,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 } public Optional getTypeNameForDataFixer() { -@@ -127,11 +127,29 @@ public abstract class ChunkGenerator { +@@ -127,12 +_,30 @@ ); public @Nullable Pair> findNearestMapStructure( @@ -28,37 +20,38 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 ) { if (SharedConstants.DEBUG_DISABLE_FEATURES) { return null; - } else { -+ // Paper start - StructuresLocateEvent -+ final org.bukkit.World bukkitWorld = level.getWorld(); -+ final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); -+ final List apiStructures = wantedStructures.stream().map(org.bukkit.craftbukkit.generator.structure.CraftStructure::minecraftHolderToBukkit).toList(); -+ if (!apiStructures.isEmpty()) { -+ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, maxSearchRadius, createReference); -+ if (!event.callEvent()) { -+ return null; -+ } -+ if (event.getResult() != null) { -+ return Pair.of(io.papermc.paper.util.MCUtil.toBlockPos(event.getResult().pos()), org.bukkit.craftbukkit.generator.structure.CraftStructure.bukkitToMinecraftHolder(event.getResult().structure())); -+ } -+ pos = org.bukkit.craftbukkit.util.CraftLocation.toBlockPos(event.getOrigin()); -+ maxSearchRadius = event.getRadius(); -+ createReference = event.shouldFindUnexplored(); -+ wantedStructures = HolderSet.direct(org.bukkit.craftbukkit.generator.structure.CraftStructure::bukkitToMinecraftHolder, event.getStructures()); + } + ++ // Paper start - StructuresLocateEvent ++ final org.bukkit.World bukkitWorld = level.getWorld(); ++ final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); ++ final List apiStructures = wantedStructures.stream().map(org.bukkit.craftbukkit.generator.structure.CraftStructure::minecraftHolderToBukkit).toList(); ++ if (!apiStructures.isEmpty()) { ++ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, maxSearchRadius, createReference); ++ if (!event.callEvent()) { ++ return null; + } -+ // Paper end - ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); - Map>> placementScans = new Object2ObjectArrayMap<>(); ++ if (event.getResult() != null) { ++ return Pair.of(io.papermc.paper.util.MCUtil.toBlockPos(event.getResult().pos()), org.bukkit.craftbukkit.generator.structure.CraftStructure.bukkitToMinecraftHolder(event.getResult().structure())); ++ } ++ pos = org.bukkit.craftbukkit.util.CraftLocation.toBlockPos(event.getOrigin()); ++ maxSearchRadius = event.getRadius(); ++ createReference = event.shouldFindUnexplored(); ++ wantedStructures = HolderSet.direct(org.bukkit.craftbukkit.generator.structure.CraftStructure::bukkitToMinecraftHolder, event.getStructures()); ++ } ++ // Paper end + ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); + Map>> placementScans = new Object2ObjectArrayMap<>(); -@@ -226,6 +244,7 @@ public abstract class ChunkGenerator { - BlockPos.MutableBlockPos structurePos = new BlockPos.MutableBlockPos(); +@@ -227,6 +_,7 @@ + BlockPos.MutableBlockPos structurePos = new BlockPos.MutableBlockPos(); - for (ChunkPos chunkPos : positions) { -+ if (!level.paperConfig().environment.locateStructuresOutsideWorldBorder && !level.getWorldBorder().isChunkInBounds(chunkPos.x(), chunkPos.z())) { continue; } // Paper - Bound treasure maps to world border - structurePos.set(SectionPos.sectionToBlockCoord(chunkPos.x(), 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z(), 8)); - double distSqr = structurePos.distSqr(pos); - boolean isClosest = closestPos == null || distSqr < closest; -@@ -260,9 +279,12 @@ public abstract class ChunkGenerator { + for (ChunkPos chunkPos : positions) { ++ if (!level.paperConfig().environment.locateStructuresOutsideWorldBorder && !level.getWorldBorder().isChunkInBounds(chunkPos.x(), chunkPos.z())) { continue; } // Paper - Bound treasure maps to world border + structurePos.set(SectionPos.sectionToBlockCoord(chunkPos.x(), 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z(), 8)); + double distSqr = structurePos.distSqr(pos); + boolean isClosest = closestPos == null || distSqr < closest; +@@ -258,9 +_,12 @@ for (int x = -radius; x <= radius; x++) { boolean xEdge = x == -radius || x == radius; @@ -74,7 +67,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 int sectorX = chunkOriginX + spacing * x; int sectorZ = chunkOriginZ + spacing * z; ChunkPos chunkTarget = config.getPotentialStructureChunk(seed, sectorX, sectorZ); -@@ -314,7 +336,7 @@ public abstract class ChunkGenerator { +@@ -312,7 +_,7 @@ } } @@ -83,7 +76,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 ChunkPos centerPos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(centerPos)) { SectionPos sectionPos = SectionPos.of(centerPos, level.getMinSectionY()); -@@ -388,7 +410,14 @@ public abstract class ChunkGenerator { +@@ -386,7 +_,14 @@ Supplier currentlyGenerating = () -> featureRegistry.getResourceKey(feature) .map(Object::toString) .orElseGet(feature::toString); @@ -99,7 +92,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 try { level.setCurrentlyGenerating(currentlyGenerating); -@@ -416,6 +445,34 @@ public abstract class ChunkGenerator { +@@ -414,6 +_,34 @@ } } } @@ -134,7 +127,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 private static BoundingBox getWritableArea(final ChunkAccess chunk) { ChunkPos chunkPos = chunk.getPos(); -@@ -495,7 +552,7 @@ public abstract class ChunkGenerator { +@@ -493,7 +_,7 @@ } } @@ -143,7 +136,7 @@ index dcec19060cc3ad05572cc861abf654de803cdc6d..1b0eb74970c4d89ce8de4ca7bb86d420 if (structures.size() == 1) { this.tryGenerateStructure( structures.get(0), -@@ -590,6 +647,14 @@ public abstract class ChunkGenerator { +@@ -588,6 +_,14 @@ biomePredicate ); if (start.isValid()) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch similarity index 85% rename from paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index 17f2c0f04453..99a18f95d099 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java -index 21995b893634bf315d9181991ce60a19d8967387..d43105cf0c29cb86a5e3c7c59dc5e02d2ab8e53f 100644 --- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java -@@ -41,22 +41,109 @@ public class ChunkGeneratorStructureState { +@@ -41,22 +_,109 @@ private final Map>> ringPositions = new Object2ObjectArrayMap<>(); private boolean hasGeneratedPositions; private final List> possibleStructureSets; @@ -31,8 +23,9 @@ index 21995b893634bf315d9181991ce60a19d8967387..d43105cf0c29cb86a5e3c7c59dc5e02d .filter(structureSet -> hasBiomesForStructureSet(structureSet.value(), biomeSource)) .collect(Collectors.toUnmodifiableList()); - return new ChunkGeneratorStructureState(randomState, biomeSource, levelSeed, levelSeed, structures); +- } + return new ChunkGeneratorStructureState(randomState, biomeSource, levelSeed, levelSeed, ChunkGeneratorStructureState.injectSpigot(structures, conf), conf); // Spigot - } ++ } + // Paper start - Add missing structure set seed configs; horrible hack because spigot creates a ton of direct Holders which lose track of the identifying key + public static final class KeyedRandomSpreadStructurePlacement extends net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement { + public final net.minecraft.resources.ResourceKey key; @@ -122,7 +115,7 @@ index 21995b893634bf315d9181991ce60a19d8967387..d43105cf0c29cb86a5e3c7c59dc5e02d private static boolean hasBiomesForStructureSet(final StructureSet structureSet, final BiomeSource biomeSource) { Stream> structureBiomes = structureSet.structures().stream().flatMap(entry -> { -@@ -71,13 +158,14 @@ public class ChunkGeneratorStructureState { +@@ -71,13 +_,14 @@ final BiomeSource biomeSource, final long levelSeed, final long concentricRingsSeed, @@ -138,21 +131,21 @@ index 21995b893634bf315d9181991ce60a19d8967387..d43105cf0c29cb86a5e3c7c59dc5e02d } public List> possibleStructureSets() { -@@ -115,7 +203,13 @@ public class ChunkGeneratorStructureState { - int spread = placement.spread(); - HolderSet preferredBiomes = placement.preferredBiomes(); - RandomSource random = RandomSource.create(); -+ // Paper start - Add missing structure set seed configs -+ if (this.conf.strongholdSeed != null && structureSet.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) { -+ random.setSeed(this.conf.strongholdSeed); -+ } else { -+ // Paper end - Add missing structure set seed configs - random.setSeed(this.concentricRingsSeed); -+ } // Paper - Add missing structure set seed configs - double angle = random.nextDouble() * Math.PI * 2.0; - int positionInCircle = 0; - int circle = 0; -@@ -193,7 +287,7 @@ public class ChunkGeneratorStructureState { +@@ -116,7 +_,13 @@ + int spread = placement.spread(); + HolderSet preferredBiomes = placement.preferredBiomes(); + RandomSource random = RandomSource.create(); ++ // Paper start - Add missing structure set seed configs ++ if (this.conf.strongholdSeed != null && structureSet.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) { ++ random.setSeed(this.conf.strongholdSeed); ++ } else { ++ // Paper end - Add missing structure set seed configs + random.setSeed(this.concentricRingsSeed); ++ } // Paper - Add missing structure set seed configs + double angle = random.nextDouble() * Math.PI * 2.0; + int positionInCircle = 0; + int circle = 0; +@@ -193,7 +_,7 @@ for (int testX = sourceX - range; testX <= sourceX + range; testX++) { for (int testZ = sourceZ - range; testZ <= sourceZ + range; testZ++) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch similarity index 83% rename from paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index 924c608ce378..894bf76d305c 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed484cd42b 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -88,13 +88,21 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -87,13 +_,21 @@ }; private final Map tickersInLevel = Maps.newHashMap(); public boolean loaded; @@ -31,7 +23,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed public LevelChunk(final Level level, final ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -112,7 +120,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -111,7 +_,7 @@ final @Nullable BlendingData blendingData ) { super(pos, upgradeData, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -40,7 +32,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); for (Heightmap.Types type : Heightmap.Types.values()) { -@@ -164,6 +172,10 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -163,6 +_,10 @@ this.skyLightSources = protoChunk.skyLightSources; this.setLightCorrect(protoChunk.isLightCorrect()); this.markUnsaved(); @@ -51,7 +43,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed } public void setUnsavedListener(final LevelChunk.UnsavedListener unsavedListener) { -@@ -172,6 +184,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -171,6 +_,12 @@ unsavedListener.setUnsaved(this.chunkPos); } } @@ -64,7 +56,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed @Override public void markUnsaved() { -@@ -205,8 +223,28 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -204,8 +_,28 @@ : super.getListenerRegistry(section); } @@ -93,7 +85,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -241,28 +279,42 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -240,28 +_,42 @@ } } @@ -128,8 +120,8 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed return Fluids.EMPTY.defaultFluidState(); + /* // Paper - Perf: Optimise Chunk#getFluid - } catch (Throwable var7) { - CrashReport report = CrashReport.forThrowable(var7, "Getting fluid state"); + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Getting fluid state"); CrashReportCategory category = report.addCategory("Block being got"); category.setDetail("Location", () -> CrashReportCategory.formatLocation(this, x, y, z)); throw new ReportedException(report); @@ -138,16 +130,16 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed } @Override -@@ -323,7 +375,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { - if (!section.getBlockState(localX, localY, localZ).is(newBlock)) { - return null; - } else { -- if (!this.level.isClientSide() && (flags & Block.UPDATE_SKIP_ON_PLACE) == 0) { -+ if (!this.level.isClientSide() && (flags & Block.UPDATE_SKIP_ON_PLACE) == 0 && (!this.level.captureBlockStates || newBlock instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. - state.onPlace(this.level, pos, oldState, movedByPiston); - } +@@ -325,7 +_,7 @@ + return null; + } + +- if (!this.level.isClientSide() && (flags & Block.UPDATE_SKIP_ON_PLACE) == 0) { ++ if (!this.level.isClientSide() && (flags & Block.UPDATE_SKIP_ON_PLACE) == 0 && (!this.level.captureBlockStates || newBlock instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. + state.onPlace(this.level, pos, oldState, movedByPiston); + } -@@ -369,7 +421,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -368,7 +_,12 @@ } public @Nullable BlockEntity getBlockEntity(final BlockPos pos, final LevelChunk.EntityCreationType creationType) { @@ -161,7 +153,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed if (blockEntity == null) { CompoundTag tag = this.pendingBlockEntities.remove(pos); if (tag != null) { -@@ -424,7 +481,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -423,7 +_,13 @@ BlockPos pos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(pos); if (!blockState.hasBlockEntity()) { @@ -176,7 +168,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed } else { BlockState cachedBlockState = blockEntity.getBlockState(); if (blockState != cachedBlockState) { -@@ -471,6 +534,11 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -470,6 +_,11 @@ public void removeBlockEntity(final BlockPos pos) { if (this.isInLevel()) { BlockEntity removeThis = this.blockEntities.remove(pos); @@ -188,7 +180,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed if (removeThis != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(removeThis, serverLevel); -@@ -514,6 +582,65 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -513,6 +_,65 @@ } } @@ -254,7 +246,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed public boolean isEmpty() { return false; } -@@ -703,6 +830,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -702,6 +_,7 @@ } private void updateBlockEntityTicker(final T blockEntity) { @@ -262,7 +254,7 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed BlockState state = blockEntity.getBlockState(); BlockEntityTicker ticker = state.getTicker(this.level, (BlockEntityType)blockEntity.getType()); if (ticker == null) { -@@ -752,23 +880,24 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -749,23 +_,24 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; @@ -286,15 +278,15 @@ index ecdc3f92084ed8d06bafa63197991c92a9b09235..d747e7058f78ac1fd02f3dc8e06670ed } profiler.pop(); - } catch (Throwable var5) { -- CrashReport report = CrashReport.forThrowable(var5, "Ticking block entity"); + } catch (Throwable t) { +- CrashReport report = CrashReport.forThrowable(t, "Ticking block entity"); - CrashReportCategory category = report.addCategory("Block entity being ticked"); - this.blockEntity.fillCrashReportCategory(category); - throw new ReportedException(report); + // Paper start - Prevent block entity and entity crashes + final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(LevelChunk.this.getLevel()), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); -+ net.minecraft.server.MinecraftServer.LOGGER.error(msg, var5); -+ net.minecraft.world.level.chunk.LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var5))); // Paper - ServerExceptionEvent ++ net.minecraft.server.MinecraftServer.LOGGER.error(msg, t); ++ net.minecraft.world.level.chunk.LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, t))); // Paper - ServerExceptionEvent + LevelChunk.this.removeBlockEntity(this.getPos()); + // Paper end - Prevent block entity and entity crashes } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch similarity index 53% rename from paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch index 4f7fdc9a8258..54d6c2d0331f 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index 8be87ecbdad9988c67caf07751688c62e848013e..e2208bc7b58b0241192b1b79e3ac1aa0bb35f354 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -90,14 +90,31 @@ public class ProtoChunk extends ChunkAccess { +@@ -90,15 +_,32 @@ return new ChunkAccess.PackedTicks(this.blockTicks.pack(currentTick), this.fluidTicks.pack(currentTick)); } @@ -35,10 +27,11 @@ index 8be87ecbdad9988c67caf07751688c62e848013e..e2208bc7b58b0241192b1b79e3ac1aa0 + // Paper end if (this.isOutsideBuildHeight(y)) { return Blocks.VOID_AIR.defaultBlockState(); - } else { - LevelChunkSection section = this.getSection(this.getSectionIndex(y)); -- return section.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : section.getBlockState(pos.getX() & 15, y & 15, pos.getZ() & 15); -+ return section.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : section.getBlockState(x & 15, y & 15, z & 15); // Paper } + + LevelChunkSection section = this.getSection(this.getSectionIndex(y)); +- return section.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : section.getBlockState(pos.getX() & 15, y & 15, pos.getZ() & 15); ++ return section.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : section.getBlockState(x & 15, y & 15, z & 15); // Paper } + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch new file mode 100644 index 000000000000..eb4391e4cdfc --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -0,0 +1,150 @@ +--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java ++++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +@@ -80,6 +_,10 @@ + public final List entityInfoList = Lists.newArrayList(); + private Vec3i size = Vec3i.ZERO; + private String author = "?"; ++ // CraftBukkit start - data containers ++ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); ++ public org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); ++ // CraftBukkit end + + public Vec3i getSize() { + return this.size; +@@ -249,7 +_,7 @@ + } + + public boolean placeInWorld( +- final ServerLevelAccessor level, ++ ServerLevelAccessor level, // Paper - make non-final + final BlockPos position, + final BlockPos referencePos, + final StructurePlaceSettings settings, +@@ -260,6 +_,19 @@ + return false; + } + ++ // CraftBukkit start ++ // We only want the TransformerLevelAccessor at certain locations because in here are many "block update" calls that shouldn't be transformed ++ ServerLevelAccessor wrappedAccessor = level; ++ org.bukkit.craftbukkit.util.CraftStructureTransformer structureTransformer = null; ++ if (wrappedAccessor instanceof org.bukkit.craftbukkit.util.TransformerLevelAccessor transformerAccessor) { ++ level = transformerAccessor.getDelegate(); ++ structureTransformer = transformerAccessor.getStructureTransformer(); ++ // The structureTransformer is not needed if we can not transform blocks therefore we can save a little bit of performance doing this ++ if (structureTransformer != null && !structureTransformer.canTransformBlocks()) { ++ structureTransformer = null; ++ } ++ } ++ // CraftBukkit end + List blockInfoList = settings.getRandomPalette(this.palettes, position).blocks(); + if ((!blockInfoList.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) + && this.size.getX() >= 1 +@@ -287,6 +_,20 @@ + level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); + } + ++ // CraftBukkit start ++ if (structureTransformer != null) { ++ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(level, blockPos, state, null); ++ if (blockInfo.nbt != null && craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState entityState) { ++ entityState.loadData(blockInfo.nbt); ++ if (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftLootable craftLootable) { ++ craftLootable.setSeed(random.nextLong()); ++ } ++ } ++ craftBlockState = structureTransformer.transformCraftState(craftBlockState); ++ state = craftBlockState.getHandle(); ++ blockInfo = new StructureTemplate.StructureBlockInfo(blockPos, state, (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState craftBlockEntityState ? craftBlockEntityState.getSnapshotNBT() : null)); ++ } ++ // CraftBukkit end + if (level.setBlock(blockPos, state, updateMode)) { + minX = Math.min(minX, blockPos.getX()); + minY = Math.min(minY, blockPos.getY()); +@@ -298,7 +_,7 @@ + if (blockInfo.nbt != null) { + BlockEntity blockEntity = level.getBlockEntity(blockPos); + if (blockEntity != null) { +- if (!SharedConstants.DEBUG_STRUCTURE_EDIT_MODE && blockEntity instanceof RandomizableContainer) { ++ if (structureTransformer == null && !SharedConstants.DEBUG_STRUCTURE_EDIT_MODE && blockEntity instanceof RandomizableContainer) { // CraftBukkit - only process if don't have a transformer access (Was already set above) - SPIGOT-7520: Use structureTransformer as check, so that it is the same as above + blockInfo.nbt.putLong("LootTableSeed", random.nextLong()); + } + +@@ -383,7 +_,11 @@ + if (blockInfo.getSecond() != null) { + BlockEntity blockEntity = level.getBlockEntity(blockPos); + if (blockEntity != null) { +- blockEntity.setChanged(); ++ // Paper start - Fix NBT pieces overriding a block entity during worldgen deadlock ++ if (!(level instanceof net.minecraft.world.level.WorldGenLevel)) { ++ blockEntity.setChanged(); ++ } ++ // Paper end - Fix NBT pieces overriding a block entity during worldgen deadlock + } + } + } +@@ -391,7 +_,7 @@ + + if (!settings.isIgnoreEntities()) { + this.placeEntities( +- level, ++ wrappedAccessor, // CraftBukkit + position, + settings.getMirror(), + settings.getRotation(), +@@ -510,14 +_,17 @@ + }); + } + } ++ + } + + private static Optional createEntityIgnoreException(final ProblemReporter reporter, final ServerLevelAccessor level, final CompoundTag tag) { +- try { +- return EntityType.create(TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), EntitySpawnReason.STRUCTURE); +- } catch (Exception ignored) { +- return Optional.empty(); +- } ++ // CraftBukkit start ++ // try { ++ return EntityType.create(TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), EntitySpawnReason.STRUCTURE, true); // Paper - Don't fire sync event during generation ++ // } catch (Exception ignored) { ++ // return Optional.empty(); ++ // } ++ // CraftBukkit end + } + + public Vec3i getSize(final Rotation rotation) { +@@ -708,6 +_,11 @@ + + tag.put("entities", entityList); + tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); ++ // CraftBukkit start - PDC ++ if (!this.persistentDataContainer.isEmpty()) { ++ tag.put("BukkitValues", this.persistentDataContainer.toTagCompound()); ++ } ++ // CraftBukkit end + return NbtUtils.addCurrentDataVersion(tag); + } + +@@ -733,6 +_,11 @@ + BlockPos blockPos = new BlockPos(blockPosTag.getIntOr(0, 0), blockPosTag.getIntOr(1, 0), blockPosTag.getIntOr(2, 0)); + entityTag.getCompound("nbt").ifPresent(nbt -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(pos, blockPos, nbt))); + }); ++ // CraftBukkit start - PDC ++ if (tag.get("BukkitValues") instanceof CompoundTag compoundTag) { ++ this.persistentDataContainer.putAll(compoundTag); ++ } ++ // CraftBukkit end + } + + private void loadPalette(final HolderGetter blockLookup, final ListTag paletteList, final ListTag blockList) { +@@ -832,7 +_,7 @@ + + public static final class Palette { + private final List blocks; +- private final Map> cache = Maps.newHashMap(); ++ private final Map> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads + private @Nullable List cachedJigsaws; + + private Palette(final List blocks) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch similarity index 67% rename from paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 9bd430363d06..6df0f5e804b9 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/storage/LevelStorageSource.java b/net/minecraft/world/level/storage/LevelStorageSource.java -index e3de51f7171931bb0d00fd31a2e0fd173af4d390..ea43d9b47cc9f2e201fd43e56d8dc896e4b1cabd 100644 --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -149,12 +149,13 @@ public class LevelStorageSource { +@@ -144,13 +_,14 @@ final WorldDataConfiguration dataConfiguration, final Registry datapackDimensions, final HolderLookup.Provider registryAccess @@ -16,14 +8,15 @@ index e3de51f7171931bb0d00fd31a2e0fd173af4d390..ea43d9b47cc9f2e201fd43e56d8dc896 ) { if (DataFixers.getFileFixer().requiresFileFixing(NbtUtils.getDataVersion(levelDataTag))) { throw new IllegalStateException("Cannot get level data without file fixing first"); - } else { - Dynamic dataTag = RegistryOps.injectRegistryContext(levelDataTag, registryAccess); -- WorldGenSettings worldGenSettings = readExistingSavedData(worldAccess, registryAccess, WorldGenSettings.TYPE) -+ WorldGenSettings worldGenSettings = readExistingSavedData(worldAccess, dimension, registryAccess, WorldGenSettings.TYPE) // Paper - pass dimension - .mapOrElse( - Function.identity(), - error -> { -@@ -174,13 +175,13 @@ public class LevelStorageSource { + } + + Dynamic dataTag = RegistryOps.injectRegistryContext(levelDataTag, registryAccess); +- WorldGenSettings worldGenSettings = readExistingSavedData(worldAccess, registryAccess, WorldGenSettings.TYPE) ++ WorldGenSettings worldGenSettings = readExistingSavedData(worldAccess, dimension, registryAccess, WorldGenSettings.TYPE) // Paper - pass dimension + .mapOrElse( + Function.identity(), + error -> { +@@ -169,13 +_,13 @@ } public static DataResult readExistingSavedData( @@ -37,10 +30,10 @@ index e3de51f7171931bb0d00fd31a2e0fd173af4d390..ea43d9b47cc9f2e201fd43e56d8dc896 try { - fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.defaultQuota()); + fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.create(net.minecraft.nbt.NbtAccounter.DEFAULT_NBT_QUOTA * 50L)); // Paper - raise quota to account for custom data - } catch (IOException var6) { - return DataResult.error(var6::getMessage); + } catch (IOException e) { + return DataResult.error(e::getMessage); } -@@ -396,7 +397,7 @@ public class LevelStorageSource { +@@ -386,7 +_,7 @@ public LevelStorageSource.LevelStorageAccess validateAndCreateAccess(final String levelId) throws IOException, ContentValidationException { Path levelPath = this.getLevelPath(levelId); From 97f0f11f88a9367c937afb70a6483fd4cf06be1b Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 13 May 2026 14:09:10 +0100 Subject: [PATCH 13/16] 170 --- .../EquipmentDispenseItemBehavior.java.patch | 71 ------ .../dispenser/SpawnEggItemBehavior.java.patch | 50 ---- .../level/chunk/storage/RegionFile.java.patch | 59 ----- .../storage/SerializableChunkData.java.patch | 144 ----------- .../storage/SimpleRegionStorage.java.patch | 57 ----- .../vibrations/VibrationSystem.java.patch | 35 --- .../cauldron/CauldronInteractions.java.patch | 213 ++++++++-------- .../dispenser/DispenseItemBehavior.java.patch | 131 +++++----- .../EquipmentDispenseItemBehavior.java.patch | 63 +++++ .../ShulkerBoxDispenseBehavior.java.patch | 14 +- .../dispenser/SpawnEggItemBehavior.java.patch | 42 ++++ .../server/players/PlayerList.java.patch | 125 +++++----- .../WanderingTraderSpawner.java.patch | 40 ++- .../entity/projectile/Projectile.java.patch | 59 ++--- .../minecart/NewMinecartBehavior.java.patch | 26 +- .../minecart/OldMinecartBehavior.java.patch | 22 +- .../world/level/BaseCommandBlock.java.patch | 54 ++-- .../minecraft/world/level/Level.java.patch | 236 +++++++++--------- .../world/level/NaturalSpawner.java.patch | 44 ++-- .../world/level/border/WorldBorder.java.patch | 32 +-- .../level/chunk/storage/RegionFile.java.patch | 51 ++++ .../storage/RegionFileStorage.java.patch | 42 ++-- .../storage/SerializableChunkData.java.patch | 137 ++++++++++ .../storage/SimpleRegionStorage.java.patch | 49 ++++ .../PersistentEntitySectionManager.java.patch | 76 +++--- .../vibrations/VibrationSystem.java.patch | 27 ++ 26 files changed, 874 insertions(+), 1025 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/core/cauldron/CauldronInteractions.java.patch (64%) rename paper-server/patches/{rejected => sources}/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch (83%) create mode 100644 paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch (80%) create mode 100644 paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/server/players/PlayerList.java.patch (93%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch (68%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/projectile/Projectile.java.patch (80%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch (73%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch (73%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/BaseCommandBlock.java.patch (63%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/Level.java.patch (73%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/NaturalSpawner.java.patch (90%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/border/WorldBorder.java.patch (85%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch (54%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch (72%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch diff --git a/paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch deleted file mode 100644 index 2f20671b23f2..000000000000 --- a/paper-server/patches/rejected/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java -index 19f2b508e0fb688e41bd9852c8058216473fc177..369b1efd45c2a945715d0be47084961a897e635b 100644 ---- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java -+++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java -@@ -14,10 +14,17 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior { - - @Override - protected ItemStack execute(final BlockSource source, final ItemStack dispensed) { -- return dispenseEquipment(source, dispensed) ? dispensed : super.execute(source, dispensed); -+ return dispenseEquipment(source, dispensed, this) ? dispensed : super.execute(source, dispensed); // Paper - fix possible StackOverflowError - } - -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - public static boolean dispenseEquipment(final BlockSource source, final ItemStack dispensed) { -+ // Paper start -+ return dispenseEquipment(source, dispensed, null); -+ } -+ -+ public static boolean dispenseEquipment(final BlockSource source, final ItemStack dispensed, final @org.jspecify.annotations.Nullable DispenseItemBehavior currentBehavior) { -+ // Paper end - BlockPos pos = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); - List entities = source.level().getEntitiesOfClass(LivingEntity.class, new AABB(pos), entity -> entity.canEquipWithDispenser(dispensed)); - if (entities.isEmpty()) { -@@ -25,13 +32,39 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior { - } else { - LivingEntity target = entities.getFirst(); - EquipmentSlot slot = target.getEquipmentSlotForItem(dispensed); -- ItemStack equip = dispensed.split(1); -- target.setItemSlot(slot, equip); -+ ItemStack equip = dispensed.copyWithCount(1); // Paper - shrink below and single item in event -+ // CraftBukkit start -+ net.minecraft.world.level.Level world = source.level(); -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, source.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(equip); -+ -+ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) target.getBukkitEntity()); -+ world.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return false; -+ } -+ -+ boolean shrink = true; -+ if (!event.getItem().equals(craftItem)) { -+ shrink = false; -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); -+ if (dispenseItemBehavior != DispenseItemBehavior.NOOP && (currentBehavior == null || dispenseItemBehavior != currentBehavior)) { -+ dispenseItemBehavior.dispense(source, eventStack); -+ return true; -+ } -+ } -+ -+ target.setItemSlot(slot, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); -+ // CraftBukkit end - if (target instanceof Mob targetMob) { - targetMob.setGuaranteedDrop(slot); - targetMob.setPersistenceRequired(); - } - -+ if (shrink) dispensed.shrink(1); // Paper - shrink here - return true; - } - } diff --git a/paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch b/paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch deleted file mode 100644 index 47398136c946..000000000000 --- a/paper-server/patches/rejected/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java -index 9950d8d5baa7318ab5383c16d2450039e44458e1..2c633b052bae5437e4f9748df2b588681fd9e049 100644 ---- a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java -+++ b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java -@@ -18,14 +18,37 @@ public class SpawnEggItemBehavior extends DefaultDispenseItemBehavior { - if (type == null) { - return dispensed; - } else { -+ // Paper start - block dispense event -+ ItemStack singleDispensed = dispensed.copyWithCount(1); -+ final org.bukkit.craftbukkit.inventory.CraftItemStack eventItemCopy = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleDispensed); -+ final org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent( -+ org.bukkit.craftbukkit.block.CraftBlock.at(source.level(), source.pos()), -+ eventItemCopy, -+ new org.bukkit.util.Vector(0, 0, 0) -+ ); -+ if (!event.callEvent()) return dispensed; -+ -+ final boolean shrink = event.getItem().equals(eventItemCopy); -+ if (!shrink) { -+ final ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()); -+ final DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(source, eventStack); -+ return dispensed; -+ } -+ -+ type = SpawnEggItem.getType(eventStack); -+ singleDispensed = eventStack; -+ } -+ // Paper end - block dispense event - try { -- type.spawn(source.level(), dispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false); -+ type.spawn(source.level(), singleDispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false); // Paper - block dispense event - update used item stack - } catch (Exception var6) { - LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), var6); - return ItemStack.EMPTY; - } - -- dispensed.shrink(1); -+ if (shrink) dispensed.shrink(1); // Paper - block dispense event - only shrink if above logic requires it. - source.level().gameEvent(null, GameEvent.ENTITY_PLACE, source.pos()); - return dispensed; - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch deleted file mode 100644 index ef01c23ca40d..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFile.java.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 985d64ce5aa8513f8fdc9877d2296e90bbb25c43..9409cc5c8dbd12ce6bdf34843da70170ebce41bd 100644 ---- a/net/minecraft/world/level/chunk/storage/RegionFile.java -+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -83,6 +83,14 @@ public class RegionFile implements AutoCloseable { - if (offset != 0) { - int sectorNumber = getSectorNumber(offset); - int numSectors = getNumSectors(offset); -+ // Spigot start -+ if (numSectors == 255) { -+ // We're maxed out, so we need to read the proper length from the section -+ ByteBuffer realLen = ByteBuffer.allocate(4); -+ this.file.read(realLen, sectorNumber * 4096); -+ numSectors = (realLen.getInt(0) + 4) / 4096 + 1; -+ } -+ // Spigot end - if (sectorNumber < 2) { - LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i, sectorNumber); - this.offsets.put(i, 0); -@@ -117,6 +125,13 @@ public class RegionFile implements AutoCloseable { - } else { - int sectorNumber = getSectorNumber(offset); - int numSectors = getNumSectors(offset); -+ // Spigot start -+ if (numSectors == 255) { -+ ByteBuffer realLen = ByteBuffer.allocate(4); -+ this.file.read(realLen, sectorNumber * 4096); -+ numSectors = (realLen.getInt(0) + 4) / 4096 + 1; -+ } -+ // Spigot end - int sectorsLength = numSectors * 4096; - ByteBuffer buffer = ByteBuffer.allocate(sectorsLength); - this.file.read(buffer, sectorNumber * 4096); -@@ -258,6 +273,7 @@ public class RegionFile implements AutoCloseable { - return true; - } - } catch (IOException var9) { -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var9); // Paper - ServerExceptionEvent - return false; - } - } -@@ -329,6 +345,11 @@ public class RegionFile implements AutoCloseable { - try (FileChannel extFile = FileChannel.open(tmpPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { - data.position(5); - extFile.write(data); -+ // Paper start - ServerExceptionEvent -+ } catch (Throwable throwable) { -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); -+ throw throwable; -+ // Paper end - ServerExceptionEvent - } - - return () -> Files.move(tmpPath, path, StandardCopyOption.REPLACE_EXISTING); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch deleted file mode 100644 index 4d2a641697b0..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ /dev/null @@ -1,144 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index b4809d1035bb7b8dc9557e146a2820ee94edfaa2..480623c30777fd230bf8428b16364db09806562b 100644 ---- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -+++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -92,6 +92,7 @@ public record SerializableChunkData( - List entities, - List blockEntities, - CompoundTag structureData -+ , net.minecraft.nbt.@Nullable Tag persistentDataContainer // CraftBukkit - persistentDataContainer - ) { - private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); - private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); -@@ -107,13 +108,39 @@ public record SerializableChunkData( - public static final String BLOCK_LIGHT_TAG = "BlockLight"; - public static final String SKY_LIGHT_TAG = "SkyLight"; - -+ // Paper start - guard against serializing mismatching coordinates -+ // TODO Note: This needs to be re-checked each update -+ public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) { -+ final int dataVersion = NbtUtils.getDataVersion(chunkData); -+ if (dataVersion < 2842) { // Level tag is removed after this version -+ final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); -+ return new ChunkPos(levelData.getIntOr("xPos", 0), levelData.getIntOr("zPos", 0)); -+ } else { -+ return new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); -+ } -+ } -+ // Paper end - guard against serializing mismatching coordinates -+ -+ // Paper start - Do not let the server load chunks from newer versions -+ private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().dataVersion().version(); -+ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); -+ // Paper end - Do not let the server load chunks from newer versions -+ - public static SerializableChunkData parse( - final LevelHeightAccessor levelHeight, final PalettedContainerFactory containerFactory, final CompoundTag chunkData - ) { - if (chunkData.getString("Status").isEmpty()) { - return null; - } else { -- ChunkPos chunkPos = new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); -+ // Paper start - Do not let the server load chunks from newer versions -+ chunkData.getInt("DataVersion").ifPresent(dataVersion -> { -+ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) { -+ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace(); -+ System.exit(1); -+ } -+ }); -+ // Paper end - Do not let the server load chunks from newer versions -+ ChunkPos chunkPos = new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate - long lastUpdateTime = chunkData.getLongOr("LastUpdate", 0L); - long inhabitedTime = chunkData.getLongOr("InhabitedTime", 0L); - ChunkStatus status = chunkData.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); -@@ -152,7 +179,7 @@ public record SerializableChunkData( - CompoundTag structureData = chunkData.getCompoundOrEmpty("structures"); - ListTag sectionTags = chunkData.getListOrEmpty("sections"); - List sectionData = new ArrayList<>(sectionTags.size()); -- Codec>> biomesCodec = containerFactory.biomeContainerCodec(); -+ Codec>> biomesCodec = containerFactory.biomeContainerRWCodec(); // CraftBukkit - read/write - Codec> blockStatesCodec = containerFactory.blockStatesContainerCodec(); - - for (int i = 0; i < sectionTags.size(); i++) { -@@ -169,7 +196,7 @@ public record SerializableChunkData( - .getOrThrow(SerializableChunkData.ChunkReadException::new) - ) - .orElseGet(containerFactory::createForBlockStates); -- PalettedContainerRO> biomes = sectionTag.getCompound("biomes") -+ PalettedContainer> biomes = sectionTag.getCompound("biomes") // CraftBukkit - read/write - .map( - container -> biomesCodec.parse(NbtOps.INSTANCE, container) - .promotePartial(msg -> logErrors(chunkPos, y, msg)) -@@ -206,6 +233,7 @@ public record SerializableChunkData( - entities, - blockEntities, - structureData -+ , chunkData.get("ChunkBukkitValues") // CraftBukkit - ChunkBukkitValues - ); - } - } -@@ -283,6 +311,12 @@ public record SerializableChunkData( - } - } - -+ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. -+ if (this.persistentDataContainer instanceof CompoundTag compoundTag) { -+ chunk.persistentDataContainer.putAll(compoundTag); -+ } -+ // CraftBukkit end -+ - chunk.setLightCorrect(this.lightCorrect); - EnumSet toPrime = EnumSet.noneOf(Heightmap.Types.class); - -@@ -389,6 +423,12 @@ public record SerializableChunkData( - CompoundTag structureData = packStructureData( - StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() - ); -+ // CraftBukkit start - store chunk persistent data in nbt -+ CompoundTag persistentDataContainer = null; -+ if (!chunk.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. -+ persistentDataContainer = chunk.persistentDataContainer.toTagCompound(); -+ } -+ // CraftBukkit end - return new SerializableChunkData( - level.palettedContainerFactory(), - pos, -@@ -408,6 +448,7 @@ public record SerializableChunkData( - entities, - blockEntities, - structureData -+ , persistentDataContainer // CraftBukkit - persistentDataContainer - ); - } - } -@@ -475,6 +516,11 @@ public record SerializableChunkData( - this.heightmaps.forEach((type, data) -> heightmapsTag.put(type.getSerializationKey(), new LongArrayTag(data))); - tag.put("Heightmaps", heightmapsTag); - tag.put("structures", this.structureData); -+ // CraftBukkit start - store chunk persistent data in nbt -+ if (this.persistentDataContainer != null) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. -+ tag.put("ChunkBukkitValues", this.persistentDataContainer); -+ } -+ // CraftBukkit end - return tag; - } - -@@ -558,6 +604,12 @@ public record SerializableChunkData( - } else { - StructureStart start = StructureStart.loadStaticStart(context, startsTag.getCompoundOrEmpty(key), seed); - if (start != null) { -+ // CraftBukkit start - load persistent data for structure start -+ net.minecraft.nbt.Tag persistentBase = startsTag.getCompoundOrEmpty(key).get("StructureBukkitValues"); -+ if (persistentBase instanceof CompoundTag compoundTag) { -+ start.persistentDataContainer.putAll(compoundTag); -+ } -+ // CraftBukkit end - outmap.put(startFeature, start); - } - } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch deleted file mode 100644 index e35935cbeae6..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index 55b5e09e0809d4c25868fc0cb9b62f5a1632a0dc..c5ac299e4a23d51a7777a678a0e1735bfb194f09 100644 ---- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -+++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -@@ -44,7 +44,19 @@ public class SimpleRegionStorage implements AutoCloseable { - } - - public CompletableFuture write(final ChunkPos pos, final Supplier supplier) { -- return this.worker.store(pos, supplier); -+ // Paper start - guard against possible chunk pos desync -+ final Supplier guardedPosCheck = () -> { -+ final CompoundTag nbt = supplier.get(); -+ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; -+ if (chunkStorage && nbt != null && !pos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { -+ final String world = (this instanceof net.minecraft.server.level.ChunkMap chunkMap) ? io.papermc.paper.util.MCUtil.getLevelName(chunkMap.level) : null; -+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos -+ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); -+ } -+ return nbt; -+ }; -+ return this.worker.store(pos, guardedPosCheck); -+ // Paper end - guard against possible chunk pos desync - } - - public CompoundTag upgradeChunkTag(CompoundTag chunkTag, final int defaultVersion, final @Nullable CompoundTag dataFixContextTag, final int targetVersion) { -@@ -53,8 +65,25 @@ public class SimpleRegionStorage implements AutoCloseable { - return chunkTag; - } else { - try { -+ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty -+ boolean stopBelowZero = false; -+ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; -+ if (chunkStorage) { -+ final boolean belowZeroGenerationInExistingChunks = (this instanceof net.minecraft.server.level.ChunkMap chunkMap) -+ ? chunkMap.level.spigotConfig.belowZeroGenerationInExistingChunks -+ : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; -+ if (version <= 2730 && !belowZeroGenerationInExistingChunks) { -+ stopBelowZero = "full".equals(chunkTag.getCompound("Level").flatMap(level -> level.getString("Status")).orElse(null)); -+ } -+ } -+ // Spigot end - injectDatafixingContext(chunkTag, dataFixContextTag); - chunkTag = this.dataFixType.update(this.fixerUpper, chunkTag, version, targetVersion); -+ // Spigot start -+ if (stopBelowZero) { -+ chunkTag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); -+ } -+ // Spigot end - removeDatafixingContext(chunkTag); - NbtUtils.addDataVersion(chunkTag, targetVersion); - return chunkTag; diff --git a/paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch deleted file mode 100644 index 1f54d0fd123b..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java -index 5b4bcf60db341d19380019d8a25d3ad4222c860b..d37ded5474cdb1065bb573e89075d88b6d16243f 100644 ---- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java -+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java -@@ -123,7 +123,7 @@ public interface VibrationSystem { - public static final Codec CODEC = RecordCodecBuilder.create( - i -> i.group( - VibrationInfo.CODEC.lenientOptionalFieldOf("event").forGetter(o -> Optional.ofNullable(o.currentVibration)), -- VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.Data::getSelectionStrategy), -+ VibrationSelector.CODEC.optionalFieldOf("selector").xmap(o -> o.orElseGet(VibrationSelector::new), Optional::of).forGetter(VibrationSystem.Data::getSelectionStrategy), // Paper - fix MapLike spam for missing "selector" in 1.19.2 - ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.Data::getTravelTimeInTicks) - ) - .apply( -@@ -219,7 +219,14 @@ public interface VibrationSystem { - return false; - } else { - Vec3 destination = listenerSourcePos.get(); -- if (!user.canReceiveVibration(level, BlockPos.containing(sourcePosition), event, context)) { -+ // CraftBukkit start -+ boolean defaultCancel = !user.canReceiveVibration(level, BlockPos.containing(sourcePosition), event, context); -+ Entity entity = context.sourceEntity(); -+ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(event), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(sourcePosition)), (entity == null) ? null : entity.getBukkitEntity()); -+ event1.setCancelled(defaultCancel); -+ level.getCraftServer().getPluginManager().callEvent(event1); -+ if (event1.isCancelled()) { -+ // CraftBukkit end - return false; - } else if (isOccluded(level, sourcePosition, destination)) { - return false; diff --git a/paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch similarity index 64% rename from paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch rename to paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch index a4455d3e567e..0a1d9fb63129 100644 --- a/paper-server/patches/rejected/net/minecraft/core/cauldron/CauldronInteractions.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/cauldron/CauldronInteractions.java b/net/minecraft/core/cauldron/CauldronInteractions.java -index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef5310da5f 100644 --- a/net/minecraft/core/cauldron/CauldronInteractions.java +++ b/net/minecraft/core/cauldron/CauldronInteractions.java -@@ -46,15 +46,20 @@ public class CauldronInteractions { +@@ -46,15 +_,20 @@ public static void bootStrap() { addDefaultInteractions(EMPTY); @@ -31,7 +23,7 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -67,7 +72,7 @@ public class CauldronInteractions { +@@ -67,7 +_,7 @@ addDefaultInteractions(WATER); WATER.put( Items.BUCKET, @@ -40,7 +32,7 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef state, level, pos, -@@ -76,33 +81,43 @@ public class CauldronInteractions { +@@ -76,23 +_,28 @@ itemInHand, new ItemStack(Items.WATER_BUCKET), s -> s.getValue(LayeredCauldronBlock.LEVEL) == 3, @@ -72,24 +64,25 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef + WATER.put(Items.POTION, (state, level, pos, player, hand, itemInHand, hitDirection) -> { // Paper - add hitDirection if (state.getValue(LayeredCauldronBlock.LEVEL) == 3) { return InteractionResult.TRY_WITH_EMPTY_HAND; - } else { - PotionContents potion = itemInHand.get(DataComponents.POTION_CONTENTS); - if (potion != null && potion.is(Potions.WATER)) { - if (!level.isClientSide()) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleCauldronLevelChangeEvent(level, pos, state.cycle(LayeredCauldronBlock.LEVEL), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { // Paper - Call CauldronLevelChangeEvent -+ return InteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, new ItemStack(Items.GLASS_BOTTLE))); - player.awardStat(Stats.USE_CAULDRON); - player.awardStat(Stats.ITEM_USED.get(itemInHand.getItem())); -- level.setBlockAndUpdate(pos, state.cycle(LayeredCauldronBlock.LEVEL)); -+ // level.setBlockAndUpdate(pos, state.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit - level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); - level.gameEvent(null, GameEvent.FLUID_PLACE, pos); - } -@@ -148,14 +163,14 @@ public class CauldronInteractions { + } +@@ -100,10 +_,15 @@ + PotionContents potion = itemInHand.get(DataComponents.POTION_CONTENTS); + if (potion != null && potion.is(Potions.WATER)) { + if (!level.isClientSide()) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleCauldronLevelChangeEvent(level, pos, state.cycle(LayeredCauldronBlock.LEVEL), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { // Paper - Call CauldronLevelChangeEvent ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, new ItemStack(Items.GLASS_BOTTLE))); + player.awardStat(Stats.USE_CAULDRON); + player.awardStat(Stats.ITEM_USED.get(itemInHand.getItem())); +- level.setBlockAndUpdate(pos, state.cycle(LayeredCauldronBlock.LEVEL)); ++ // level.setBlockAndUpdate(pos, state.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit + level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); + level.gameEvent(null, GameEvent.FLUID_PLACE, pos); + } +@@ -148,14 +_,14 @@ WATER.put(Items.YELLOW_SHULKER_BOX, CauldronInteractions::shulkerBoxInteraction); LAVA.put( Items.BUCKET, @@ -107,7 +100,7 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef state, level, pos, -@@ -164,7 +179,7 @@ public class CauldronInteractions { +@@ -164,7 +_,7 @@ itemInHand, new ItemStack(Items.POWDER_SNOW_BUCKET), s -> s.getValue(LayeredCauldronBlock.LEVEL) == 3, @@ -116,7 +109,7 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef ) ); addDefaultInteractions(POWDER_SNOW); -@@ -187,15 +202,46 @@ public class CauldronInteractions { +@@ -187,16 +_,47 @@ final Predicate canFill, final SoundEvent soundEvent ) { @@ -139,32 +132,33 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef + // Paper end - add hitDirection if (!canFill.test(state)) { return InteractionResult.TRY_WITH_EMPTY_HAND; - } else { - if (!level.isClientSide()) { -+ // Paper start - fire PlayerBucketFillEvent -+ if (hitDirection != null) { -+ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, pos, pos, hitDirection, itemInHand, newItem.getItem(), hand); -+ if (event.isCancelled()) { -+ return InteractionResult.PASS; -+ } -+ newItem = event.getItemStack() != null ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; -+ } -+ // Paper end - fire PlayerBucketFillEvent -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleCauldronLevelChangeEvent(level, pos, Blocks.CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { // Paper - Call CauldronLevelChangeEvent -+ return InteractionResult.SUCCESS; + } + + if (!level.isClientSide()) { ++ // Paper start - fire PlayerBucketFillEvent ++ if (hitDirection != null) { ++ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, pos, pos, hitDirection, itemInHand, newItem.getItem(), hand); ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; + } -+ // CraftBukkit end - Item itemUsed = itemInHand.getItem(); - player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, newItem)); - player.awardStat(Stats.USE_CAULDRON); - player.awardStat(Stats.ITEM_USED.get(itemUsed)); -- level.setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState()); -+ // level.setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit - level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); - level.gameEvent(null, GameEvent.FLUID_PICKUP, pos); - } -@@ -213,12 +259,42 @@ public class CauldronInteractions { ++ newItem = event.getItemStack() != null ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; ++ } ++ // Paper end - fire PlayerBucketFillEvent ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleCauldronLevelChangeEvent(level, pos, Blocks.CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { // Paper - Call CauldronLevelChangeEvent ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + Item itemUsed = itemInHand.getItem(); + player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, newItem)); + player.awardStat(Stats.USE_CAULDRON); + player.awardStat(Stats.ITEM_USED.get(itemUsed)); +- level.setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState()); ++ // level.setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit + level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); + level.gameEvent(null, GameEvent.FLUID_PICKUP, pos); + } +@@ -213,12 +_,42 @@ final BlockState newState, final SoundEvent soundEvent ) { @@ -209,7 +203,7 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -227,23 +303,23 @@ public class CauldronInteractions { +@@ -227,23 +_,23 @@ } private static InteractionResult fillWaterInteraction( @@ -226,25 +220,25 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef - final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final ItemStack itemInHand + final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final ItemStack itemInHand, final net.minecraft.core.Direction hitDirection // Paper - add hitDirection ) { - return (InteractionResult)(isUnderWater(level, pos) + return isUnderWater(level, pos) ? InteractionResult.CONSUME -- : emptyBucket(level, pos, player, hand, itemInHand, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEvents.BUCKET_EMPTY_LAVA)); -+ : emptyBucket(level, pos, player, hand, itemInHand, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEvents.BUCKET_EMPTY_LAVA, hitDirection)); // Paper - add hitDirection +- : emptyBucket(level, pos, player, hand, itemInHand, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEvents.BUCKET_EMPTY_LAVA); ++ : emptyBucket(level, pos, player, hand, itemInHand, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEvents.BUCKET_EMPTY_LAVA, hitDirection); // Paper - add hitDirection } private static InteractionResult fillPowderSnowInteraction( - final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final ItemStack itemInHand + final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final ItemStack itemInHand, final net.minecraft.core.Direction hitDirection // Paper - add hitDirection ) { - return (InteractionResult)(isUnderWater(level, pos) + return isUnderWater(level, pos) ? InteractionResult.CONSUME -@@ -254,22 +330,27 @@ public class CauldronInteractions { +@@ -254,12 +_,12 @@ hand, itemInHand, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), - SoundEvents.BUCKET_EMPTY_POWDER_SNOW + SoundEvents.BUCKET_EMPTY_POWDER_SNOW, hitDirection // Paper - add hitDirection - )); + ); } private static InteractionResult shulkerBoxInteraction( @@ -253,23 +247,23 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef ) { Block block = Block.byItem(itemInHand.getItem()); if (!(block instanceof ShulkerBoxBlock)) { - return InteractionResult.TRY_WITH_EMPTY_HAND; - } else { - if (!level.isClientSide()) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { -+ return InteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - ItemStack cleanedShulkerBox = itemInHand.transmuteCopy(Blocks.SHULKER_BOX, 1); - player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, cleanedShulkerBox, false)); - player.awardStat(Stats.CLEAN_SHULKER_BOX); -- LayeredCauldronBlock.lowerFillLevel(state, level, pos); -+ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit - } +@@ -267,17 +_,22 @@ + } - return InteractionResult.SUCCESS; -@@ -277,18 +358,23 @@ public class CauldronInteractions { + if (!level.isClientSide()) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + ItemStack cleanedShulkerBox = itemInHand.transmuteCopy(Blocks.SHULKER_BOX, 1); + player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, cleanedShulkerBox, false)); + player.awardStat(Stats.CLEAN_SHULKER_BOX); +- LayeredCauldronBlock.lowerFillLevel(state, level, pos); ++ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit + } + + return InteractionResult.SUCCESS; } private static InteractionResult bannerInteraction( @@ -278,24 +272,24 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef ) { BannerPatternLayers patterns = itemInHand.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); if (patterns.layers().isEmpty()) { - return InteractionResult.TRY_WITH_EMPTY_HAND; - } else { - if (!level.isClientSide()) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { -+ return InteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - ItemStack cleanedBanner = itemInHand.copyWithCount(1); - cleanedBanner.set(DataComponents.BANNER_PATTERNS, patterns.removeLast()); - player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, cleanedBanner, false)); - player.awardStat(Stats.CLEAN_BANNER); -- LayeredCauldronBlock.lowerFillLevel(state, level, pos); -+ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit - } +@@ -285,27 +_,37 @@ + } - return InteractionResult.SUCCESS; -@@ -296,15 +382,20 @@ public class CauldronInteractions { + if (!level.isClientSide()) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + ItemStack cleanedBanner = itemInHand.copyWithCount(1); + cleanedBanner.set(DataComponents.BANNER_PATTERNS, patterns.removeLast()); + player.setItemInHand(hand, ItemUtils.createFilledResult(itemInHand, player, cleanedBanner, false)); + player.awardStat(Stats.CLEAN_BANNER); +- LayeredCauldronBlock.lowerFillLevel(state, level, pos); ++ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit + } + + return InteractionResult.SUCCESS; } private static InteractionResult dyedItemIteration( @@ -304,17 +298,18 @@ index e0397dfeb3ce8bffcb1ef11be71e84eb84724dcc..63e93e299a13cf04d26a588485481fef ) { if (!itemInHand.has(DataComponents.DYED_COLOR)) { return InteractionResult.TRY_WITH_EMPTY_HAND; - } else { - if (!level.isClientSide()) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { -+ return InteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - itemInHand.remove(DataComponents.DYED_COLOR); - player.awardStat(Stats.CLEAN_ARMOR); -- LayeredCauldronBlock.lowerFillLevel(state, level, pos); -+ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit - } + } - return InteractionResult.SUCCESS; + if (!level.isClientSide()) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(state, level, pos, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + itemInHand.remove(DataComponents.DYED_COLOR); + player.awardStat(Stats.CLEAN_ARMOR); +- LayeredCauldronBlock.lowerFillLevel(state, level, pos); ++ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit + } + + return InteractionResult.SUCCESS; diff --git a/paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch similarity index 83% rename from paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 56e44c58eb0d..0d7e83b21326 100644 --- a/paper-server/patches/rejected/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e7d61139b 100644 --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -87,12 +87,38 @@ public interface DispenseItemBehavior { +@@ -87,12 +_,38 @@ Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos pos = source.pos().relative(direction); ServerLevel serverLevel = source.level(); @@ -49,7 +41,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e } return dispensed; -@@ -110,8 +136,33 @@ public interface DispenseItemBehavior { +@@ -110,8 +_,33 @@ .getEntitiesOfClass(AbstractChestedHorse.class, new AABB(pos), entity -> entity.isAlive() && !entity.hasChest())) { if (abstractChestedHorse.isTamed()) { SlotAccess slot = abstractChestedHorse.getSlot(AbstractHorse.CHEST_SLOT_OFFSET); @@ -85,7 +77,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e this.setSuccess(true); return dispensed; } -@@ -150,8 +201,45 @@ public interface DispenseItemBehavior { +@@ -150,8 +_,45 @@ DispensibleContainerItem bucket = (DispensibleContainerItem)dispensed.getItem(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); Level level = source.level(); @@ -132,7 +124,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e return this.consumeWithRemainder(source, dispensed, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(source, dispensed); -@@ -174,12 +262,19 @@ public interface DispenseItemBehavior { +@@ -174,13 +_,20 @@ BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState blockState = level.getBlockState(target); if (blockState.getBlock() instanceof BucketPickup bucket) { @@ -140,20 +132,21 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e + ItemStack pickup = bucket.pickupBlock(null, org.bukkit.craftbukkit.util.DummyLevelAccessor.INSTANCE, target, blockState); // CraftBukkit if (pickup.isEmpty()) { return super.execute(source, dispensed); - } else { - level.gameEvent(null, GameEvent.FLUID_PICKUP, target); - Item targetType = pickup.getItem(); -+ // Paper start - Call BlockDispenseEvent -+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, target, dispensed, this); -+ if (result != null) { -+ return result; -+ } -+ // Paper end - Call BlockDispenseEvent -+ pickup = bucket.pickupBlock(null, level, target, blockState); // CraftBukkit - from above - return this.consumeWithRemainder(source, dispensed, new ItemStack(targetType)); } + + level.gameEvent(null, GameEvent.FLUID_PICKUP, target); + Item targetType = pickup.getItem(); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, target, dispensed, this); ++ if (result != null) { ++ return result; ++ } ++ // Paper end - Call BlockDispenseEvent ++ pickup = bucket.pickupBlock(null, level, target, blockState); // CraftBukkit - from above + return this.consumeWithRemainder(source, dispensed, new ItemStack(targetType)); } else { -@@ -194,15 +289,26 @@ public interface DispenseItemBehavior { + return super.execute(source, dispensed); +@@ -194,15 +_,26 @@ this.setSuccess(true); Direction facing = source.state().getValue(DispenserBlock.FACING); BlockPos targetPos = source.pos().relative(facing); @@ -181,7 +174,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e level.removeBlock(targetPos, false); } else { this.setSuccess(false); -@@ -224,11 +330,46 @@ public interface DispenseItemBehavior { +@@ -224,11 +_,46 @@ this.setSuccess(true); Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); @@ -228,7 +221,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e return dispensed; } -@@ -242,11 +383,36 @@ public interface DispenseItemBehavior { +@@ -242,11 +_,36 @@ return dispensed; } else { BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); @@ -268,7 +261,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e this.setSuccess(true); return dispensed; } -@@ -260,6 +426,13 @@ public interface DispenseItemBehavior { +@@ -260,6 +_,13 @@ Level level = source.level(); Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos target = source.pos().relative(direction); @@ -282,7 +275,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e if (level.isEmptyBlock(target) && WitherSkullBlock.canSpawnMob(level, target, dispensed)) { level.setBlock( target, -@@ -275,7 +448,7 @@ public interface DispenseItemBehavior { +@@ -275,7 +_,7 @@ dispensed.shrink(1); this.setSuccess(true); } else { @@ -291,7 +284,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e } return dispensed; -@@ -288,6 +461,13 @@ public interface DispenseItemBehavior { +@@ -288,6 +_,13 @@ Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock pumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -305,7 +298,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e if (level.isEmptyBlock(target) && pumpkinBlock.canSpawnGolem(level, target)) { if (!level.isClientSide()) { level.setBlock(target, pumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); -@@ -297,7 +477,7 @@ public interface DispenseItemBehavior { +@@ -297,7 +_,7 @@ dispensed.shrink(1); this.setSuccess(true); } else { @@ -314,7 +307,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e } return dispensed; -@@ -335,6 +515,12 @@ public interface DispenseItemBehavior { +@@ -335,6 +_,12 @@ ServerLevel level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState state = level.getBlockState(target); @@ -327,7 +320,7 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e if (state.is(BlockTags.BEEHIVES, s -> s.hasProperty(BeehiveBlock.HONEY_LEVEL) && s.getBlock() instanceof BeehiveBlock) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { ((BeehiveBlock)state.getBlock()) -@@ -360,6 +546,13 @@ public interface DispenseItemBehavior { +@@ -360,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -341,36 +334,36 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e RespawnAnchorBlock.charge(null, level, pos, blockState); dispensed.shrink(1); } else { -@@ -383,6 +576,28 @@ public interface DispenseItemBehavior { - this.setSuccess(false); +@@ -384,6 +_,28 @@ return dispensed; - } else { -+ // CraftBukkit start -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, source.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(dispensed); // Paper - ignore stack size on damageable items + } + ++ // CraftBukkit start ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, source.pos()); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(dispensed); // Paper - ignore stack size on damageable items + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), armadillos.get(0).getBukkitLivingEntity()); -+ level.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), armadillos.get(0).getBukkitLivingEntity()); ++ level.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ this.setSuccess(false); -+ return dispensed; -+ } ++ if (event.isCancelled()) { ++ this.setSuccess(false); ++ return dispensed; ++ } + -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(source, eventStack); -+ return dispensed; -+ } ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(source, eventStack); ++ return dispensed; + } -+ // CraftBukkit end - for (Armadillo armadillo : armadillos) { - if (armadillo.brushOffScute(null, dispensed)) { - dispensed.hurtAndBreak(16, level, null, item -> {}); -@@ -403,6 +618,13 @@ public interface DispenseItemBehavior { ++ } ++ // CraftBukkit end + for (Armadillo armadillo : armadillos) { + if (armadillo.brushOffScute(null, dispensed)) { + dispensed.hurtAndBreak(16, level, null, item -> {}); +@@ -403,6 +_,13 @@ BlockState blockState = level.getBlockState(pos); Optional maybeWaxed = HoneycombItem.getWaxed(blockState); if (maybeWaxed.isPresent()) { @@ -384,16 +377,16 @@ index 95a29660c64ecf36926f8c44e6401c6358bd4aa9..751232d09f5570a23223356a6572090e level.setBlockAndUpdate(pos, maybeWaxed.get()); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, pos, 0); dispensed.shrink(1); -@@ -430,6 +652,12 @@ public interface DispenseItemBehavior { - if (!level.getBlockState(target).is(BlockTags.CONVERTABLE_TO_MUD)) { - return this.defaultDispenseItemBehavior.dispense(source, dispensed); - } else { -+ // Paper start - Call BlockDispenseEvent -+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, target, dispensed, this); -+ if (result != null) { -+ return result; -+ } -+ // Paper end - Call BlockDispenseEvent - if (!level.isClientSide()) { - RandomSource random = level.getRandom(); +@@ -432,6 +_,12 @@ + return this.defaultDispenseItemBehavior.dispense(source, dispensed); + } + ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, target, dispensed, this); ++ if (result != null) { ++ return result; ++ } ++ // Paper end - Call BlockDispenseEvent + if (!level.isClientSide()) { + RandomSource random = level.getRandom(); diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch new file mode 100644 index 000000000000..98198f8de5fc --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +@@ -14,10 +_,17 @@ + + @Override + protected ItemStack execute(final BlockSource source, final ItemStack dispensed) { +- return dispenseEquipment(source, dispensed) ? dispensed : super.execute(source, dispensed); ++ return dispenseEquipment(source, dispensed, this) ? dispensed : super.execute(source, dispensed); // Paper - fix possible StackOverflowError + } + ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper + public static boolean dispenseEquipment(final BlockSource source, final ItemStack dispensed) { ++ // Paper start ++ return dispenseEquipment(source, dispensed, null); ++ } ++ ++ public static boolean dispenseEquipment(final BlockSource source, final ItemStack dispensed, final @org.jspecify.annotations.Nullable DispenseItemBehavior currentBehavior) { ++ // Paper end + BlockPos pos = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); + List entities = source.level().getEntitiesOfClass(LivingEntity.class, new AABB(pos), entity -> entity.canEquipWithDispenser(dispensed)); + if (entities.isEmpty()) { +@@ -26,13 +_,39 @@ + + LivingEntity target = entities.getFirst(); + EquipmentSlot slot = target.getEquipmentSlotForItem(dispensed); +- ItemStack equip = dispensed.split(1); +- target.setItemSlot(slot, equip); ++ ItemStack equip = dispensed.copyWithCount(1); // Paper - shrink below and single item in event ++ // CraftBukkit start ++ net.minecraft.world.level.Level world = source.level(); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, source.pos()); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(equip); ++ ++ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) target.getBukkitEntity()); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ ++ boolean shrink = true; ++ if (!event.getItem().equals(craftItem)) { ++ shrink = false; ++ // Chain to handler for new item ++ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); ++ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); ++ if (dispenseItemBehavior != DispenseItemBehavior.NOOP && (currentBehavior == null || dispenseItemBehavior != currentBehavior)) { ++ dispenseItemBehavior.dispense(source, eventStack); ++ return true; ++ } ++ } ++ ++ target.setItemSlot(slot, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ // CraftBukkit end + if (target instanceof Mob targetMob) { + targetMob.setGuaranteedDrop(slot); + targetMob.setPersistenceRequired(); + } + ++ if (shrink) dispensed.shrink(1); // Paper - shrink here + return true; + } + } diff --git a/paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch similarity index 80% rename from paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch index 446fcf38c57b..633393b05579 100644 --- a/paper-server/patches/rejected/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -index 9f0e541626a73190de31b1576577626808ce2dcd..1f5363c71d897400b39edb34bd6e2ad1f9d6a6b1 100644 --- a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -@@ -22,10 +22,36 @@ public class ShulkerBoxDispenseBehavior extends OptionalDispenseItemBehavior { +@@ -22,10 +_,36 @@ BlockPos relativePos = source.pos().relative(facing); Direction clickedFace = source.level().isEmptyBlock(relativePos.below()) ? facing : Direction.UP; @@ -43,6 +35,6 @@ index 9f0e541626a73190de31b1576577626808ce2dcd..1f5363c71d897400b39edb34bd6e2ad1 + dispensed.shrink(1); // vanilla shrink is in the place function above, manually handle it here + } + // Paper end - track changed items in the dispense event - } catch (Exception var8) { - LOGGER.error("Error trying to place shulker box at {}", relativePos, var8); + } catch (Exception e) { + LOGGER.error("Error trying to place shulker box at {}", relativePos, e); } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch new file mode 100644 index 000000000000..99e409f5b601 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java ++++ b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java +@@ -19,14 +_,37 @@ + return dispensed; + } + ++ // Paper start - block dispense event ++ ItemStack singleDispensed = dispensed.copyWithCount(1); ++ final org.bukkit.craftbukkit.inventory.CraftItemStack eventItemCopy = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleDispensed); ++ final org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent( ++ org.bukkit.craftbukkit.block.CraftBlock.at(source.level(), source.pos()), ++ eventItemCopy, ++ new org.bukkit.util.Vector(0, 0, 0) ++ ); ++ if (!event.callEvent()) return dispensed; ++ ++ final boolean shrink = event.getItem().equals(eventItemCopy); ++ if (!shrink) { ++ final ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()); ++ final DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(source, eventStack); ++ return dispensed; ++ } ++ ++ type = SpawnEggItem.getType(eventStack); ++ singleDispensed = eventStack; ++ } ++ // Paper end - block dispense event + try { +- type.spawn(source.level(), dispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false); ++ type.spawn(source.level(), singleDispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false); // Paper - block dispense event - update used item stack + } catch (Exception e) { + LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), e); + return ItemStack.EMPTY; + } + +- dispensed.shrink(1); ++ if (shrink) dispensed.shrink(1); // Paper - block dispense event - only shrink if above logic requires it. + source.level().gameEvent(null, GameEvent.ENTITY_PLACE, source.pos()); + return dispensed; + } diff --git a/paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch similarity index 93% rename from paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch rename to paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 1333afea7162..ce6d72589425 100644 --- a/paper-server/patches/rejected/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04dc35b268 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -114,14 +114,16 @@ public abstract class PlayerList { +@@ -113,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z", Locale.ROOT); private final MinecraftServer server; @@ -28,7 +20,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -129,12 +131,20 @@ public abstract class PlayerList { +@@ -128,12 +_,20 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -49,7 +41,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -144,23 +154,19 @@ public abstract class PlayerList { +@@ -143,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -78,7 +70,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 LevelData levelData = level.getLevelData(); ServerGamePacketListenerImpl playerConnection = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -177,8 +183,8 @@ public abstract class PlayerList { +@@ -176,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -89,7 +81,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 reducedDebugInfo, !immediateRespawn, doLimitedCrafting, -@@ -186,6 +192,7 @@ public abstract class PlayerList { +@@ -185,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -97,7 +89,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 playerConnection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); playerConnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); playerConnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -205,24 +212,129 @@ public abstract class PlayerList { +@@ -204,24 +_,129 @@ component = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), oldName); } @@ -231,7 +223,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } public void updateEntireScoreboard(final ServerScoreboard scoreboard, final ServerPlayer player) { -@@ -244,6 +356,15 @@ public abstract class PlayerList { +@@ -243,31 +_,40 @@ } } @@ -246,9 +238,6 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 + // Paper end - virtual world border API public void addWorldborderListener(final ServerLevel level) { level.getWorldBorder().addListener(new BorderChangeListener() { - { -@@ -252,27 +373,27 @@ public abstract class PlayerList { - @Override public void onSetSize(final WorldBorder border, final double newSize) { - PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(border), level.dimension()); @@ -280,7 +269,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } @Override -@@ -296,64 +417,147 @@ public abstract class PlayerList { +@@ -291,66 +_,149 @@ } protected void save(final ServerPlayer player) { @@ -389,6 +378,11 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } - this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); +- } +- +- public @Nullable Component canPlayerLogin(final SocketAddress address, final NameAndId nameAndId) { +- if (this.bans.isBanned(nameAndId)) { +- UserBanListEntry ban = this.bans.get(nameAndId); + // CraftBukkit start + // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); + ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID())); @@ -405,11 +399,8 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 + this.cserver.getScoreboardManager().removePlayer(player.getBukkitEntity()); + // CraftBukkit end + return playerQuitEvent.quitMessage(); // Paper - Adventure - } - -- public @Nullable Component canPlayerLogin(final SocketAddress address, final NameAndId nameAndId) { -- if (this.bans.isBanned(nameAndId)) { -- UserBanListEntry ban = this.bans.get(nameAndId); ++ } ++ + // Paper start - PlayerLoginEvent + public record LoginResult(@Nullable Component message, org.bukkit.event.player.PlayerLoginEvent.Result result) { + public static LoginResult ALLOW = new net.minecraft.server.players.PlayerList.LoginResult(null, org.bukkit.event.player.PlayerLoginEvent.Result.ALLOWED); @@ -432,27 +423,30 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } - return reason; -- } else if (!this.isWhiteListed(nameAndId)) { -- return Component.translatable("multiplayer.disconnect.not_whitelisted"); + return new LoginResult(reason, org.bukkit.event.player.PlayerLoginEvent.Result.KICK_BANNED); // Paper - PlayerLoginEvent + } else { +- if (!this.isWhiteListed(nameAndId)) { +- return Component.translatable("multiplayer.disconnect.not_whitelisted"); + // Paper start - whitelist event -+ } else if ((whitelistEventResult = this.isWhiteListedLogin(nameAndId)).result == org.bukkit.event.player.PlayerLoginEvent.Result.KICK_WHITELIST) { -+ return whitelistEventResult; -+ // Paper end - } else if (this.ipBans.isBanned(address)) { - IpBanListEntry ban = this.ipBans.get(address); - MutableComponent reason = Component.translatable("multiplayer.disconnect.banned_ip.reason", ban.getReasonMessage()); -@@ -361,19 +565,18 @@ public abstract class PlayerList { - reason.append(Component.translatable("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ban.getExpires()))); ++ if ((whitelistEventResult = this.isWhiteListedLogin(nameAndId)).result == org.bukkit.event.player.PlayerLoginEvent.Result.KICK_WHITELIST) { ++ return whitelistEventResult; } ++ // Paper end -- return reason; -+ return new LoginResult(reason, org.bukkit.event.player.PlayerLoginEvent.Result.KICK_BANNED); // Paper - PlayerLoginEvent - } else { -- return this.players.size() >= this.getMaxPlayers() && !this.canBypassPlayerLimit(nameAndId) -- ? Component.translatable("multiplayer.disconnect.server_full") -- : null; -+ return this.canBypassFullServerLogin(nameAndId, new LoginResult(Component.translatable("multiplayer.disconnect.server_full"), org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL)); // Paper - PlayerServerFullCheckEvent + if (this.ipBans.isBanned(address)) { + IpBanListEntry ban = this.ipBans.get(address); +@@ -359,20 +_,19 @@ + reason.append(Component.translatable("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ban.getExpires()))); + } + +- return reason; ++ return new LoginResult(reason, org.bukkit.event.player.PlayerLoginEvent.Result.KICK_BANNED); // Paper - PlayerLoginEvent + } else { +- return this.players.size() >= this.getMaxPlayers() && !this.canBypassPlayerLimit(nameAndId) +- ? Component.translatable("multiplayer.disconnect.server_full") +- : null; ++ return this.canBypassFullServerLogin(nameAndId, new LoginResult(Component.translatable("multiplayer.disconnect.server_full"), org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL)); // Paper - PlayerServerFullCheckEvent + } } } @@ -467,12 +461,12 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 dupes.add(player); } } -@@ -384,23 +587,31 @@ public abstract class PlayerList { +@@ -383,23 +_,31 @@ } - for (ServerPlayer playerx : dupes) { -- playerx.connection.disconnect(DUPLICATE_LOGIN_DISCONNECT_MESSAGE); -+ playerx.connection.disconnect(DUPLICATE_LOGIN_DISCONNECT_MESSAGE, io.papermc.paper.connection.DisconnectionReason.DUPLICATE_LOGIN_MESSAGE); // Paper - disconnect API + for (ServerPlayer player : dupes) { +- player.connection.disconnect(DUPLICATE_LOGIN_DISCONNECT_MESSAGE); ++ player.connection.disconnect(DUPLICATE_LOGIN_DISCONNECT_MESSAGE, io.papermc.paper.connection.DisconnectionReason.DUPLICATE_LOGIN_MESSAGE); // Paper - disconnect API } return !dupes.isEmpty(); @@ -504,7 +498,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 player.copyRespawnPosition(serverPlayer); } -@@ -408,17 +619,26 @@ public abstract class PlayerList { +@@ -407,17 +_,26 @@ player.addTag(tag); } @@ -532,7 +526,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); player.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); player.connection.send(new ClientboundSetExperiencePacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); -@@ -427,9 +647,15 @@ public abstract class PlayerList { +@@ -426,9 +_,15 @@ this.sendPlayerPermissionLevel(player); level.addRespawnedPlayer(player); this.players.add(player); @@ -548,7 +542,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 ServerPlayer.RespawnConfig respawnConfig = player.getRespawnConfig(); if (!keepAllPlayerData && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -455,6 +681,29 @@ public abstract class PlayerList { +@@ -454,6 +_,29 @@ } } @@ -578,7 +572,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 return player; } -@@ -463,23 +712,58 @@ public abstract class PlayerList { +@@ -462,23 +_,58 @@ } public void sendActiveEffects(final LivingEntity livingEntity, final ServerGamePacketListenerImpl connection) { @@ -640,7 +634,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 public void broadcastAll(final Packet packet) { for (ServerPlayer player : this.players) { player.connection.send(packet); -@@ -565,6 +849,12 @@ public abstract class PlayerList { +@@ -564,6 +_,12 @@ } private void sendPlayerPermissionLevel(final ServerPlayer player, final LevelBasedPermissionSet permissions) { @@ -653,16 +647,18 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 if (player.connection != null) { byte eventId = switch (permissions.level()) { case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; -@@ -576,9 +866,48 @@ public abstract class PlayerList { +@@ -575,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, eventId)); } + if (recalculatePermissions) { // Paper - Add sendOpLevel API + player.getBukkitEntity().recalculatePermissions(); // CraftBukkit this.server.getCommands().sendCommands(player); +- } +- + } // Paper - Add sendOpLevel API - } - ++ } ++ + // Paper start - whitelist verify event / login event + public LoginResult canBypassFullServerLogin(final NameAndId nameAndId, final LoginResult currentResult) { + final boolean shouldKick = this.players.size() >= this.getMaxPlayers() && !this.canBypassPlayerLimit(nameAndId); @@ -702,7 +698,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 public boolean isWhiteListed(final NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -590,16 +919,7 @@ public abstract class PlayerList { +@@ -589,16 +_,7 @@ } public @Nullable ServerPlayer getPlayerByName(final String name) { @@ -720,7 +716,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } public void broadcast( -@@ -613,6 +933,11 @@ public abstract class PlayerList { +@@ -612,6 +_,11 @@ ) { for (int i = 0; i < this.players.size(); i++) { ServerPlayer player = this.players.get(i); @@ -732,7 +728,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 if (player != except && player.level().dimension() == dimension) { double xd = x - player.getX(); double yd = y - player.getY(); -@@ -625,9 +950,11 @@ public abstract class PlayerList { +@@ -624,9 +_,11 @@ } public void saveAll() { @@ -744,7 +740,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } public UserWhiteList getWhiteList() { -@@ -652,12 +979,20 @@ public abstract class PlayerList { +@@ -651,12 +_,20 @@ public void sendLevelInfo(final ServerPlayer player, final ServerLevel level) { WorldBorder worldBorder = level.getWorldBorder(); player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); @@ -769,7 +765,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -666,8 +1001,21 @@ public abstract class PlayerList { +@@ -665,8 +_,21 @@ public void sendAllPlayerInfo(final ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -792,12 +788,13 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } public int getPlayerCount() { -@@ -711,9 +1059,26 @@ public abstract class PlayerList { +@@ -710,9 +_,26 @@ } public void removeAll() { - for (int i = 0; i < this.players.size(); i++) { - this.players.get(i).connection.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); +- } + // Paper start - Extract method to allow for restarting flag + this.removeAll(false); + } @@ -816,12 +813,12 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 + final net.minecraft.world.scores.Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); + final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName); + if (team != null) scoreboard.removePlayerTeam(team); - } ++ } + // Paper end - Configurable player collision } public void broadcastSystemMessage(final Component message, final boolean overlay) { -@@ -736,20 +1101,39 @@ public abstract class PlayerList { +@@ -735,20 +_,39 @@ } public void broadcastChatMessage(final PlayerChatMessage message, final ServerPlayer sender, final ChatType.Bound chatType) { @@ -864,7 +861,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 wasFullyFiltered |= filtered && message.isFullyFiltered(); } -@@ -762,13 +1146,21 @@ public abstract class PlayerList { +@@ -761,13 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -889,7 +886,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 private Path locateStatsFile(final GameProfile gameProfile) { Path statFolder = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR); -@@ -795,11 +1187,11 @@ public abstract class PlayerList { +@@ -794,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(final ServerPlayer player) { UUID uuid = player.getUUID(); @@ -903,7 +900,7 @@ index 24e16b03ded3eed7bbf091eaaeb43081f4181ae3..eff42b94fd182abace988d9649952e04 } result.setPlayer(player); -@@ -847,11 +1239,34 @@ public abstract class PlayerList { +@@ -846,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch similarity index 68% rename from paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch index cd7584096ac4..96b800ecd908 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java -index 949f1bd6c1712fa80d94c28ba1a16a0ed5793d93..b107f47d289aa32a37365163667270a98df19162 100644 --- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java +++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java -@@ -37,30 +37,38 @@ public class WanderingTraderSpawner implements CustomSpawner { +@@ -37,30 +_,38 @@ public WanderingTraderSpawner(final SavedDataStorage savedDataStorage) { this.savedDataStorage = savedDataStorage; @@ -55,23 +47,23 @@ index 949f1bd6c1712fa80d94c28ba1a16a0ed5793d93..b107f47d289aa32a37365163667270a9 } } -@@ -90,13 +98,13 @@ public class WanderingTraderSpawner implements CustomSpawner { - return false; - } +@@ -93,13 +_,13 @@ + return false; + } -- WanderingTrader trader = EntityType.WANDERING_TRADER.spawn(level, spawnPosition, EntitySpawnReason.EVENT); -+ WanderingTrader trader = EntityType.WANDERING_TRADER.spawn(level, wanderingTrader -> wanderingTrader.setDespawnDelay(48000), spawnPosition, EntitySpawnReason.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit // Paper - set despawnTimer before spawn events called - if (trader != null) { - for (int i = 0; i < 2; i++) { - this.tryToSpawnLlamaFor(level, trader, 4); - } +- WanderingTrader trader = EntityType.WANDERING_TRADER.spawn(level, spawnPosition, EntitySpawnReason.EVENT); ++ WanderingTrader trader = EntityType.WANDERING_TRADER.spawn(level, wanderingTrader -> wanderingTrader.setDespawnDelay(48000), spawnPosition, EntitySpawnReason.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit // Paper - set despawnTimer before spawn events called + if (trader != null) { + for (int i = 0; i < 2; i++) { + this.tryToSpawnLlamaFor(level, trader, 4); + } -- trader.setDespawnDelay(48000); -+ // trader.setDespawnDelay(48000); // Paper - moved above, modifiable by plugins on CreatureSpawnEvent - trader.setWanderTarget(referencePos); - trader.setHomeTo(referencePos, 16); - return true; -@@ -110,7 +118,7 @@ public class WanderingTraderSpawner implements CustomSpawner { +- trader.setDespawnDelay(48000); ++ // trader.setDespawnDelay(48000); // Paper - moved above, modifiable by plugins on CreatureSpawnEvent + trader.setWanderTarget(referencePos); + trader.setHomeTo(referencePos, 16); + return true; +@@ -112,7 +_,7 @@ private void tryToSpawnLlamaFor(final ServerLevel level, final WanderingTrader trader, final int radius) { BlockPos spawnPosition = this.findSpawnPositionNear(level, trader.blockPosition(), radius); if (spawnPosition != null) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch similarity index 80% rename from paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index ce6f6b2df7b1..7aab1ebaa180 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java -index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f219d82e191 100644 --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -44,6 +44,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -44,6 +_,7 @@ private boolean leftOwnerChecked; public boolean hasBeenShot = false; private @Nullable Entity lastDeflectedBy; @@ -16,7 +8,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 protected Projectile(final EntityType type, final Level level) { super(type, level); -@@ -83,6 +84,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -83,6 +_,7 @@ @Override protected void readAdditionalSaveData(final ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); @@ -24,7 +16,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } -@@ -155,7 +157,14 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -155,7 +_,14 @@ float zd = Mth.cos(yRot * Mth.DEG_TO_RAD) * Mth.cos(xRot * Mth.DEG_TO_RAD); this.shoot(xd, yd, zd, pow, uncertainty); Vec3 sourceMovement = source.getKnownMovement(); @@ -39,7 +31,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 } @Override -@@ -181,7 +190,20 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -181,7 +_,20 @@ final float pow, final float uncertainty ) { @@ -61,7 +53,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 creator.create(serverLevel, source, itemStack), serverLevel, itemStack, -@@ -215,7 +237,22 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -215,7 +_,22 @@ final float pow, final float uncertainty ) { @@ -85,7 +77,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 } public static T spawnProjectile(final T projectile, final ServerLevel serverLevel, final ItemStack itemStack) { -@@ -225,12 +262,47 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -225,11 +_,46 @@ public static T spawnProjectile( final T projectile, final ServerLevel serverLevel, final ItemStack itemStack, final Consumer shootFunction ) { @@ -93,6 +85,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 - serverLevel.addFreshEntity(projectile); - projectile.applyOnProjectileSpawned(serverLevel, itemStack); - return projectile; +- } + // Paper start - delayed projectile spawning + return spawnProjectileDelayed(projectile, serverLevel, itemStack, shootFunction).spawn(); + } @@ -101,8 +94,8 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 + // Paper end - delayed projectile spawning + adapter.accept(projectile); + return new Delayed<>(projectile, serverLevel, itemStack); // Paper - delayed projectile spawning - } - ++ } ++ + // Paper start - delayed projectile spawning + public record Delayed( + T projectile, @@ -133,11 +126,10 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 + } + } + // Paper end - delayed projectile spawning -+ + public void applyOnProjectileSpawned(final ServerLevel serverLevel, final ItemStack pickupItemStack) { EnchantmentHelper.onProjectileSpawned(serverLevel, pickupItemStack, this, item -> {}); - if (this instanceof AbstractArrow arrow) { -@@ -241,6 +313,17 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -241,6 +_,17 @@ } } @@ -155,7 +147,7 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 protected ProjectileDeflection hitTargetOrDeflectSelf(final HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -313,15 +396,35 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -313,16 +_,36 @@ } protected void onHitBlock(final BlockHitResult hitResult) { @@ -177,21 +169,22 @@ index 5657ed613e31dd858142ca592763385c4a389bb5..2ee2103e78f2b73d1e6df59b92037f21 protected boolean canHitEntity(final Entity entity) { if (!entity.canBeHitByProjectile()) { return false; - } else { - Entity owner = this.getOwner(); -+ // Paper start - Cancel hit for vanished entities -+ if (owner instanceof net.minecraft.server.level.ServerPlayer) { -+ org.bukkit.entity.Entity collided = entity.getBukkitEntity(); -+ org.bukkit.entity.Player shooter = (org.bukkit.entity.Player) owner.getBukkitEntity(); -+ if (!shooter.canSee(collided)) { -+ return false; -+ } -+ } -+ // Paper end - Cancel hit for vanished entities - return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(entity); } + + Entity owner = this.getOwner(); ++ // Paper start - Cancel hit for vanished entities ++ if (owner instanceof net.minecraft.server.level.ServerPlayer) { ++ org.bukkit.entity.Entity collided = entity.getBukkitEntity(); ++ org.bukkit.entity.Player shooter = (org.bukkit.entity.Player) owner.getBukkitEntity(); ++ if (!shooter.canSee(collided)) { ++ return false; ++ } ++ } ++ // Paper end - Cancel hit for vanished entities + return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(entity); } -@@ -334,13 +437,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { + +@@ -334,13 +_,7 @@ } protected static float lerpRotation(float rotO, final float rot) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch similarity index 73% rename from paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index b3458d661b41..05af618c7eeb 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java -index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b6504b1b9 100644 --- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java -@@ -482,6 +482,12 @@ public class NewMinecartBehavior extends MinecartBehavior { +@@ -482,6 +_,12 @@ @Override public double getMaxSpeed(final ServerLevel level) { @@ -21,7 +13,7 @@ index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b return level.getGameRules().get(GameRules.MAX_MINECART_SPEED).intValue() * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } -@@ -497,7 +503,8 @@ public class NewMinecartBehavior extends MinecartBehavior { +@@ -497,7 +_,8 @@ @Override public double getSlowdownFactor() { @@ -31,7 +23,7 @@ index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b } @Override -@@ -521,6 +528,13 @@ public class NewMinecartBehavior extends MinecartBehavior { +@@ -521,6 +_,13 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -45,7 +37,7 @@ index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b boolean pickedUp = entity.startRiding(this.minecart); if (pickedUp) { return true; -@@ -544,6 +558,17 @@ public class NewMinecartBehavior extends MinecartBehavior { +@@ -544,6 +_,17 @@ || entity instanceof AbstractMinecart || this.minecart.isVehicle() || entity.isPassenger()) { @@ -63,19 +55,19 @@ index f131e4d63ea59bac6953849f85fcc289fc25f91f..caaac6757512cc187b03562b601ab90b entity.push(this.minecart); pushed = true; } -@@ -552,6 +577,15 @@ public class NewMinecartBehavior extends MinecartBehavior { +@@ -552,6 +_,15 @@ } else { - for (Entity entityx : this.level().getEntities(this.minecart, hitbox)) { - if (!this.minecart.hasPassenger(entityx) && entityx.isPushable() && entityx instanceof AbstractMinecart) { + for (Entity entity : this.level().getEntities(this.minecart, hitbox)) { + if (!this.minecart.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent( + (org.bukkit.entity.Vehicle) this.minecart.getBukkitEntity(), -+ entityx.getBukkitEntity() ++ entity.getBukkitEntity() + ); + if (!collisionEvent.callEvent()) { + continue; + } + // CraftBukkit end - entityx.push(this.minecart); + entity.push(this.minecart); pushed = true; } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch similarity index 73% rename from paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch index 7e050a70bd9c..109c8c375e7e 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java -index f150b4c73870546cd639199d150416a263c87ae5..630677ccc0276882169265e1f7aa63ed0fdd86a3 100644 --- a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java -@@ -375,8 +375,22 @@ public class OldMinecartBehavior extends MinecartBehavior { +@@ -375,8 +_,22 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -31,20 +23,20 @@ index f150b4c73870546cd639199d150416a263c87ae5..630677ccc0276882169265e1f7aa63ed entity.push(this.minecart); } } -@@ -384,6 +398,12 @@ public class OldMinecartBehavior extends MinecartBehavior { +@@ -384,6 +_,12 @@ } else { - for (Entity entityx : this.level().getEntities(this.minecart, hitbox)) { - if (!this.minecart.hasPassenger(entityx) && entityx.isPushable() && entityx instanceof AbstractMinecart) { + for (Entity entity : this.level().getEntities(this.minecart, hitbox)) { + if (!this.minecart.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { + // CraftBukkit start + org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent( -+ (org.bukkit.entity.Vehicle) this.minecart.getBukkitEntity(), entityx.getBukkitEntity() ++ (org.bukkit.entity.Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity() + ); + if (!collisionEvent.callEvent()) continue; + // CraftBukkit end - entityx.push(this.minecart); + entity.push(this.minecart); } } -@@ -406,11 +426,18 @@ public class OldMinecartBehavior extends MinecartBehavior { +@@ -406,11 +_,18 @@ @Override public double getMaxSpeed(final ServerLevel level) { diff --git a/paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch similarity index 63% rename from paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index 1bad8f8f0df9..22f1af104fd4 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/BaseCommandBlock.java b/net/minecraft/world/level/BaseCommandBlock.java -index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004787bb6ab 100644 --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -30,6 +30,10 @@ public abstract class BaseCommandBlock { +@@ -30,6 +_,10 @@ private @Nullable Component lastOutput; private String command = ""; private @Nullable Component customName; @@ -19,23 +11,23 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 public int getSuccessCount() { return this.successCount; -@@ -107,7 +111,13 @@ public abstract class BaseCommandBlock { - this.successCount++; - } - }); -- level.getServer().getCommands().performPrefixedCommand(commandSourceStack, this.command); -+ // Paper start - ServerCommandEvent -+ org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(commandSourceStack.getBukkitSender(), net.minecraft.commands.Commands.trimOptionalPrefix(this.command)); -+ if (!event.callEvent()) { -+ return true; -+ } -+ level.getServer().getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); -+ // Paper end - ServerCommandEvent - } - } catch (Throwable var7) { - CrashReport report = CrashReport.forThrowable(var7, "Executing command block"); -@@ -128,8 +138,8 @@ public abstract class BaseCommandBlock { - } +@@ -109,7 +_,13 @@ + this.successCount++; + } + }); +- level.getServer().getCommands().performPrefixedCommand(commandSourceStack, this.command); ++ // Paper start - ServerCommandEvent ++ org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(commandSourceStack.getBukkitSender(), net.minecraft.commands.Commands.trimOptionalPrefix(this.command)); ++ if (!event.callEvent()) { ++ return true; ++ } ++ level.getServer().getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); ++ // Paper end - ServerCommandEvent + } + } catch (Throwable t) { + CrashReport report = CrashReport.forThrowable(t, "Executing command block"); +@@ -129,8 +_,8 @@ + return true; } - private BaseCommandBlock.@Nullable CloseableCommandBlockSource createSource(final ServerLevel level) { @@ -45,7 +37,7 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 } public Component getName() { -@@ -162,15 +172,23 @@ public abstract class BaseCommandBlock { +@@ -163,13 +_,21 @@ public abstract boolean isValid(); @@ -59,8 +51,6 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 + // Paper start - add back source when output disabled + private final boolean trackOutput; + public CloseableCommandBlockSource(final ServerLevel level, final boolean trackOutput) { - Objects.requireNonNull(BaseCommandBlock.this); - super(); this.level = level; + this.trackOutput = trackOutput; + } @@ -71,7 +61,7 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 } @Override -@@ -180,7 +198,7 @@ public abstract class BaseCommandBlock { +@@ -179,7 +_,7 @@ @Override public boolean acceptsFailure() { @@ -80,7 +70,7 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 } @Override -@@ -190,7 +208,8 @@ public abstract class BaseCommandBlock { +@@ -189,7 +_,8 @@ @Override public void sendSystemMessage(final Component message) { @@ -90,7 +80,7 @@ index 5810ac7e696a8d74e02d4fa60f5327558c5e66b1..ea95136200a320fbebd5ef7dfdf68004 BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message); BaseCommandBlock.this.onUpdated(this.level); } -@@ -200,5 +219,12 @@ public abstract class BaseCommandBlock { +@@ -199,5 +_,12 @@ public void close() throws Exception { this.closed = true; } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch similarity index 73% rename from paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 36ca62f57242..1f1bd6bad9c3 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d9807e2b3 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -89,8 +89,19 @@ import net.minecraft.world.phys.AABB; +@@ -89,8 +_,19 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; @@ -28,7 +20,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d public abstract class Level implements LevelAccessor, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); -@@ -132,6 +143,55 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -132,6 +_,55 @@ private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; @@ -84,7 +76,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d protected Level( final WritableLevelData levelData, final ResourceKey dimension, -@@ -141,7 +201,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -141,7 +_,25 @@ final boolean isDebug, final long biomeZoomSeed, final int maxChainedNeighborUpdates @@ -110,7 +102,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; this.dimension = dimension; -@@ -155,6 +233,46 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -155,6 +_,46 @@ this.damageSources = new DamageSources(registryAccess); } @@ -157,7 +149,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d @Override public boolean isClientSide() { return this.isClientSide; -@@ -165,8 +283,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -165,8 +_,15 @@ return null; } @@ -174,7 +166,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d } public boolean isInValidBounds(final BlockPos pos) { -@@ -178,7 +303,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -178,7 +_,7 @@ } private static boolean isInWorldBoundsHorizontal(final BlockPos pos) { @@ -183,7 +175,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d } private static boolean isInValidBoundsHorizontal(final BlockPos pos) { -@@ -191,14 +316,79 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -191,14 +_,79 @@ return y < -20000000 || y >= 20000000; } @@ -195,6 +187,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d @Override - public LevelChunk getChunk(final int chunkX, final int chunkZ) { - return (LevelChunk)this.getChunk(chunkX, chunkZ, ChunkStatus.FULL); +- } + public final LevelChunk getChunk(final int chunkX, final int chunkZ) { // Paper - final to help inline + // Paper start - Perf: make sure loaded chunks get the inlined variant of this function + net.minecraft.server.level.ServerChunkCache cps = ((ServerLevel)this).getChunkSource(); @@ -261,12 +254,12 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d + // reduces need to do isLoaded before getType + public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos pos) { + return this.getWorldBorder().isWithinBounds(pos) ? this.getBlockStateIfLoaded(pos) : null; - } ++ } + // Paper end @Override public @Nullable ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatus status, final boolean loadOrGenerate) { -@@ -217,6 +407,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -217,6 +_,22 @@ @Override public boolean setBlock(final BlockPos pos, final BlockState blockState, @Block.UpdateFlags final int updateFlags, final int updateLimit) { @@ -288,63 +281,62 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d + // CraftBukkit end if (!this.isInValidBounds(pos)) { return false; - } else if (!this.isClientSide() && this.isDebug()) { -@@ -224,11 +430,31 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } else { - LevelChunk chunk = this.getChunkAt(pos); - Block block = blockState.getBlock(); -+ // CraftBukkit start - capture blockstates -+ boolean captured = false; -+ if (this.captureBlockStates) { -+ final CraftBlockState snapshot; -+ if (!this.capturedBlockStates.containsKey(pos)) { -+ snapshot = (CraftBlockState) org.bukkit.craftbukkit.block.CraftBlock.at(this, pos).getState(); // Paper - use CB getState to get a suitable snapshot -+ this.capturedBlockStates.put(pos.immutable(), snapshot); -+ captured = true; -+ } else { -+ snapshot = this.capturedBlockStates.get(pos); -+ } -+ snapshot.setFlags(updateFlags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags + } +@@ -227,12 +_,32 @@ + + LevelChunk chunk = this.getChunkAt(pos); + Block block = blockState.getBlock(); ++ // CraftBukkit start - capture blockstates ++ boolean captured = false; ++ if (this.captureBlockStates) { ++ final CraftBlockState snapshot; ++ if (!this.capturedBlockStates.containsKey(pos)) { ++ snapshot = (CraftBlockState) org.bukkit.craftbukkit.block.CraftBlock.at(this, pos).getState(); // Paper - use CB getState to get a suitable snapshot ++ this.capturedBlockStates.put(pos.immutable(), snapshot); ++ captured = true; ++ } else { ++ snapshot = this.capturedBlockStates.get(pos); + } -+ // CraftBukkit end - capture blockstates - BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); - if (oldState == null) { -+ // CraftBukkit start - remove blockstate if failed (or the same) -+ if (this.captureBlockStates && captured) { -+ this.capturedBlockStates.remove(pos); -+ } -+ // CraftBukkit end - return false; - } else { - BlockState newState = this.getBlockState(pos); -+ /* // CraftBukkit - if (newState == blockState) { - if (oldState != newState) { - this.setBlocksDirty(pos, oldState, newState); -@@ -256,12 +482,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - this.updatePOIOnBlockStateChange(pos, oldState, newState); - } -+ */ // CraftBukkit -+ -+ // CraftBukkit start -+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates -+ // Modularize client and physic updates -+ // Spigot start -+ try { -+ this.notifyAndUpdatePhysics(pos, chunk, oldState, blockState, newState, updateFlags, updateLimit); -+ } catch (StackOverflowError ex) { -+ Level.lastPhysicsProblem = pos.immutable(); -+ } -+ // Spigot end -+ } -+ // CraftBukkit end ++ snapshot.setFlags(updateFlags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags ++ } ++ // CraftBukkit end - capture blockstates + BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); + if (oldState == null) { ++ // CraftBukkit start - remove blockstate if failed (or the same) ++ if (this.captureBlockStates && captured) { ++ this.capturedBlockStates.remove(pos); ++ } ++ // CraftBukkit end + return false; + } - return true; - } + BlockState newState = this.getBlockState(pos); ++ /* // CraftBukkit + if (newState == blockState) { + if (oldState != newState) { + this.setBlocksDirty(pos, oldState, newState); +@@ -260,9 +_,66 @@ + + this.updatePOIOnBlockStateChange(pos, oldState, newState); } - } ++ */ // CraftBukkit ++ ++ // CraftBukkit start ++ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates ++ // Modularize client and physic updates ++ // Spigot start ++ try { ++ this.notifyAndUpdatePhysics(pos, chunk, oldState, blockState, newState, updateFlags, updateLimit); ++ } catch (StackOverflowError ex) { ++ Level.lastPhysicsProblem = pos.immutable(); ++ } ++ // Spigot end ++ } ++ // CraftBukkit end + return true; + } ++ + // CraftBukkit start - Split off from above in order to directly send client and physic updates + public void notifyAndUpdatePhysics(BlockPos pos, LevelChunk chunkAt, BlockState oldState, BlockState newState, BlockState currentState, @Block.UpdateFlags int flags, int recursionLeft) { + BlockState state = newState; @@ -387,11 +379,10 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d + } + } + // CraftBukkit end -+ + public void updatePOIOnBlockStateChange(final BlockPos pos, final BlockState oldState, final BlockState newState) { } - -@@ -272,19 +555,37 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -274,20 +_,38 @@ } @Override @@ -400,40 +391,41 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d BlockState blockState = this.getBlockState(pos); if (blockState.isAir()) { return false; - } else { - FluidState fluidState = this.getFluidState(pos); -- if (!(blockState.getBlock() instanceof BaseFireBlock)) { -- this.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(blockState)); -+ // Paper start - BlockDestroyEvent; while the above removeBlock method looks very similar -+ // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent, -+ // it doesn't imply destruction of a block that plays a sound effect / drops an item. -+ boolean playEffect = true; -+ BlockState effectType = blockState; -+ int xp = blockState.getBlock().getExpDrop(blockState, (ServerLevel) this, pos, ItemStack.EMPTY, true); -+ if (com.destroystokyo.paper.event.block.BlockDestroyEvent.getHandlerList().getRegisteredListeners().length > 0) { -+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), fluidState.createLegacyBlock().asBlockData(), effectType.asBlockData(), xp, dropResources); -+ if (!event.callEvent()) { -+ return false; -+ } -+ effectType = ((CraftBlockData) event.getEffectBlock()).getState(); -+ playEffect = event.playEffect(); -+ dropResources = event.willDrop(); -+ xp = event.getExpToDrop(); + } + + FluidState fluidState = this.getFluidState(pos); +- if (!(blockState.getBlock() instanceof BaseFireBlock)) { +- this.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(blockState)); ++ // Paper start - BlockDestroyEvent; while the above removeBlock method looks very similar ++ // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent, ++ // it doesn't imply destruction of a block that plays a sound effect / drops an item. ++ boolean playEffect = true; ++ BlockState effectType = blockState; ++ int xp = blockState.getBlock().getExpDrop(blockState, (ServerLevel) this, pos, ItemStack.EMPTY, true); ++ if (com.destroystokyo.paper.event.block.BlockDestroyEvent.getHandlerList().getRegisteredListeners().length > 0) { ++ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), fluidState.createLegacyBlock().asBlockData(), effectType.asBlockData(), xp, dropResources); ++ if (!event.callEvent()) { ++ return false; + } -+ // Paper end - BlockDestroyEvent -+ if (playEffect && !(blockState.getBlock() instanceof BaseFireBlock)) { // Paper - BlockDestroyEvent -+ this.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(effectType)); // Paper - BlockDestroyEvent - } ++ effectType = ((CraftBlockData) event.getEffectBlock()).getState(); ++ playEffect = event.playEffect(); ++ dropResources = event.willDrop(); ++ xp = event.getExpToDrop(); ++ } ++ // Paper end - BlockDestroyEvent ++ if (playEffect && !(blockState.getBlock() instanceof BaseFireBlock)) { // Paper - BlockDestroyEvent ++ this.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(effectType)); // Paper - BlockDestroyEvent + } - if (dropResources) { - BlockEntity blockEntity = blockState.hasBlockEntity() ? this.getBlockEntity(pos) : null; -- Block.dropResources(blockState, this, pos, blockEntity, breaker, ItemStack.EMPTY); -+ Block.dropResources(blockState, this, pos, blockEntity, breaker, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping -+ blockState.getBlock().popExperience((ServerLevel) this, pos, xp, breaker); // Paper - Properly handle xp dropping; custom amount - } + if (dropResources) { + BlockEntity blockEntity = blockState.hasBlockEntity() ? this.getBlockEntity(pos) : null; +- Block.dropResources(blockState, this, pos, blockEntity, breaker, ItemStack.EMPTY); ++ Block.dropResources(blockState, this, pos, blockEntity, breaker, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping ++ blockState.getBlock().popExperience((ServerLevel) this, pos, xp, breaker); // Paper - Properly handle xp dropping; custom amount + } - boolean destroyed = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, updateLimit); -@@ -359,10 +660,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + boolean destroyed = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, updateLimit); +@@ -361,11 +_,19 @@ @Override public BlockState getBlockState(final BlockPos pos) { @@ -447,13 +439,14 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d + // CraftBukkit end if (!this.isInValidBounds(pos)) { return Blocks.VOID_AIR.defaultBlockState(); - } else { -- LevelChunk chunk = this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); -+ ChunkAccess chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, true); // Paper - manually inline to reduce hops and avoid unnecessary null check to reduce total byte code size, this should never return null and if it does we will see it the next line but the real stack trace will matter in the chunk engine - return chunk.getBlockState(pos); } + +- LevelChunk chunk = this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); ++ ChunkAccess chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, true); // Paper - manually inline to reduce hops and avoid unnecessary null check to reduce total byte code size, this should never return null and if it does we will see it the next line but the real stack trace will matter in the chunk engine + return chunk.getBlockState(pos); } -@@ -523,6 +832,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + +@@ -525,6 +_,7 @@ } public void addBlockEntityTicker(final TickingBlockEntity ticker) { @@ -461,7 +454,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(ticker); } -@@ -533,18 +843,23 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -535,18 +_,23 @@ this.pendingBlockEntityTickers.clear(); } @@ -489,23 +482,23 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d this.tickingBlockEntities = false; } -@@ -552,13 +867,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -554,12 +_,23 @@ try { tick.accept(entity); - } catch (Throwable var6) { -- CrashReport report = CrashReport.forThrowable(var6, "Ticking entity"); + } catch (Throwable t) { +- CrashReport report = CrashReport.forThrowable(t, "Ticking entity"); - CrashReportCategory category = report.addCategory("Entity being ticked"); - entity.fillCrashReportCategory(category); - throw new ReportedException(report); + // Paper start - Prevent block entity and entity crashes + final String msg = String.format("Entity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(entity.level()), entity.getX(), entity.getY(), entity.getZ()); -+ MinecraftServer.LOGGER.error(msg, var6); -+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent ++ MinecraftServer.LOGGER.error(msg, t); ++ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, t))); // Paper - ServerExceptionEvent + entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); + // Paper end - Prevent block entity and entity crashes } } - ++ + // Paper start - Option to prevent armor stands from doing entity lookups + @Override + public boolean noCollision(@Nullable Entity entity, AABB box) { @@ -514,11 +507,10 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d + return LevelAccessor.super.noCollision(entity, box); + } + // Paper end - Option to prevent armor stands from doing entity lookups -+ + public boolean shouldTickDeath(final Entity entity) { return true; - } -@@ -691,6 +1017,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -693,6 +_,12 @@ @Override public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { @@ -531,7 +523,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d if (!this.isInValidBounds(pos)) { return null; } else { -@@ -703,6 +1035,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -705,6 +_,12 @@ public void setBlockEntity(final BlockEntity blockEntity) { BlockPos pos = blockEntity.getBlockPos(); if (this.isInValidBounds(pos)) { @@ -544,7 +536,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d this.getChunkAt(pos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1110,7 +1448,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1116,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), @@ -554,7 +546,7 @@ index 0d3e379011b40b1dd611aff90cb51f72beae5267..838bad640b7f8e42fc8972918cfc7c1d public static final Codec CODEC = StringRepresentable.fromEnum(Level.ExplosionInteraction::values); private final String id; -@@ -1124,4 +1463,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1130,4 +_,16 @@ return this.id; } } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch similarity index 90% rename from paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index 43ae6f813b57..75847669c5c0 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e367f8251 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -77,6 +77,13 @@ public final class NaturalSpawner { +@@ -77,6 +_,13 @@ if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { @@ -22,7 +14,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e BlockPos pos = entity.blockPosition(); chunkGetter.query(ChunkPos.pack(pos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(pos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -101,17 +108,34 @@ public final class NaturalSpawner { +@@ -101,17 +_,34 @@ return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } @@ -59,7 +51,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e } } -@@ -133,6 +157,16 @@ public final class NaturalSpawner { +@@ -133,6 +_,16 @@ profiler.pop(); } @@ -76,7 +68,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e public static void spawnCategoryForChunk( final MobCategory mobCategory, final ServerLevel level, -@@ -162,8 +196,8 @@ public final class NaturalSpawner { +@@ -162,8 +_,8 @@ StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int yStart = start.getY(); @@ -87,7 +79,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); int clusterSize = 0; -@@ -185,7 +219,7 @@ public final class NaturalSpawner { +@@ -185,7 +_,7 @@ Player nearestPlayer = level.getNearestPlayer(xx, yStart, zz, -1.0, false); if (nearestPlayer != null) { double nearestPlayerDistanceSqr = nearestPlayer.distanceToSqr(xx, yStart, zz); @@ -96,7 +88,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e if (currentSpawnData == null) { Optional nextSpawnData = getRandomSpawnMobAt( level, structureManager, generator, mobCategory, level.random, pos -@@ -198,7 +232,13 @@ public final class NaturalSpawner { +@@ -198,7 +_,13 @@ max = currentSpawnData.minCount() + level.random.nextInt(1 + currentSpawnData.maxCount() - currentSpawnData.minCount()); } @@ -111,7 +103,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e && extraTest.test(currentSpawnData.type(), pos, chunk)) { Mob mob = getMobForSpawn(level, currentSpawnData.type()); if (mob == null) { -@@ -210,10 +250,15 @@ public final class NaturalSpawner { +@@ -210,10 +_,15 @@ groupData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.NATURAL, groupData ); @@ -131,8 +123,8 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e if (clusterSize >= mob.getMaxSpawnClusterSize()) { return; } -@@ -247,7 +292,15 @@ public final class NaturalSpawner { - } +@@ -247,7 +_,15 @@ + return Objects.equals(chunkPos, chunk.getPos()) || level.canSpawnEntitiesInChunk(chunkPos); } - private static boolean isValidSpawnPostitionForType( @@ -148,7 +140,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e final ServerLevel level, final MobCategory mobCategory, final StructureManager structureManager, -@@ -256,14 +309,27 @@ public final class NaturalSpawner { +@@ -256,14 +_,27 @@ final BlockPos.MutableBlockPos pos, final double nearestPlayerDistanceSqr ) { @@ -177,23 +169,23 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e } private static @Nullable Mob getMobForSpawn(final ServerLevel level, final EntityType type) { -@@ -275,6 +341,7 @@ public final class NaturalSpawner { +@@ -275,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(type)); - } catch (Exception var4) { - LOGGER.warn("Failed to create mob", (Throwable)var4); + } catch (Exception e) { + LOGGER.warn("Failed to create mob", e); + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var4); // Paper - ServerExceptionEvent } return null; -@@ -402,6 +469,7 @@ public final class NaturalSpawner { +@@ -402,6 +_,7 @@ entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); - } catch (Exception var27) { - LOGGER.warn("Failed to create mob", (Throwable)var27); + } catch (Exception e) { + LOGGER.warn("Failed to create mob", e); + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var27); // Paper - ServerExceptionEvent continue; } -@@ -416,7 +484,7 @@ public final class NaturalSpawner { +@@ -416,7 +_,7 @@ groupSpawnData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, groupSpawnData ); @@ -202,7 +194,7 @@ index 2d03f1b2312de0ee702507cb02a9280bd207a7dc..8ab7bdd487de7dbc5ea19d1f361ec52e success = true; } } -@@ -534,8 +602,10 @@ public final class NaturalSpawner { +@@ -534,8 +_,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch similarity index 85% rename from paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index 94b3f6baf970..3b42c770b6de 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/border/WorldBorder.java b/net/minecraft/world/level/border/WorldBorder.java -index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e673cb1eac 100644 --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -37,6 +37,8 @@ public class WorldBorder extends SavedData { +@@ -36,6 +_,8 @@ private double centerZ; private int absoluteMaxSize = 29999984; private WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); @@ -17,7 +9,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 public WorldBorder() { this(WorldBorder.Settings.DEFAULT); -@@ -58,6 +60,20 @@ public class WorldBorder extends SavedData { +@@ -57,6 +_,20 @@ return this.isWithinBounds(pos.getMinBlockX(), pos.getMinBlockZ()) && this.isWithinBounds(pos.getMaxBlockX(), pos.getMaxBlockZ()); } @@ -38,7 +30,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 public boolean isWithinBounds(final AABB aabb) { return this.isWithinBounds(aabb.minX, aabb.minZ, aabb.maxX - 1.0E-5F, aabb.maxZ - 1.0E-5F); } -@@ -161,7 +177,15 @@ public class WorldBorder extends SavedData { +@@ -160,7 +_,15 @@ return this.centerZ; } @@ -55,7 +47,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 this.centerX = x; this.centerZ = z; this.extent.onCenterChange(); -@@ -184,7 +208,18 @@ public class WorldBorder extends SavedData { +@@ -183,7 +_,18 @@ return this.extent.getLerpTarget(); } @@ -75,7 +67,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 this.extent = new WorldBorder.StaticBorderExtent(size); this.setDirty(); -@@ -193,7 +228,21 @@ public class WorldBorder extends SavedData { +@@ -192,7 +_,21 @@ } } @@ -95,10 +87,10 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 + ticks = event.getDurationTicks(); + } + // Paper end - Add worldborder events - this.extent = (WorldBorder.BorderExtent)(from == to - ? new WorldBorder.StaticBorderExtent(to) - : new WorldBorder.MovingBorderExtent(from, to, ticks, gameTime)); -@@ -209,6 +258,7 @@ public class WorldBorder extends SavedData { + this.extent = from == to ? new WorldBorder.StaticBorderExtent(to) : new WorldBorder.MovingBorderExtent(from, to, ticks, gameTime); + this.setDirty(); + +@@ -206,6 +_,7 @@ } public void addListener(final BorderChangeListener listener) { @@ -106,7 +98,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 this.listeners.add(listener); } -@@ -282,6 +332,12 @@ public class WorldBorder extends SavedData { +@@ -279,6 +_,12 @@ } public void tick() { @@ -119,7 +111,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 this.extent = this.extent.update(); } -@@ -302,6 +358,22 @@ public class WorldBorder extends SavedData { +@@ -299,6 +_,22 @@ } } @@ -142,7 +134,7 @@ index ba2e931621a163f7aca2e4f7597d60756991731b..01fa78999b0d206a74f64d46351547e6 private interface BorderExtent { double getMinX(final float deltaPartialTick); -@@ -438,6 +510,7 @@ public class WorldBorder extends SavedData { +@@ -433,6 +_,7 @@ this.previousSize = this.size; this.size = this.calculateSize(); if (this.lerpProgress <= 0L) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch new file mode 100644 index 000000000000..da7a238ee55b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/level/chunk/storage/RegionFile.java ++++ b/net/minecraft/world/level/chunk/storage/RegionFile.java +@@ -83,6 +_,14 @@ + if (offset != 0) { + int sectorNumber = getSectorNumber(offset); + int numSectors = getNumSectors(offset); ++ // Spigot start ++ if (numSectors == 255) { ++ // We're maxed out, so we need to read the proper length from the section ++ ByteBuffer realLen = ByteBuffer.allocate(4); ++ this.file.read(realLen, sectorNumber * 4096); ++ numSectors = (realLen.getInt(0) + 4) / 4096 + 1; ++ } ++ // Spigot end + if (sectorNumber < 2) { + LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i, sectorNumber); + this.offsets.put(i, 0); +@@ -117,6 +_,13 @@ + + int sectorNumber = getSectorNumber(offset); + int numSectors = getNumSectors(offset); ++ // Spigot start ++ if (numSectors == 255) { ++ ByteBuffer realLen = ByteBuffer.allocate(4); ++ this.file.read(realLen, sectorNumber * 4096); ++ numSectors = (realLen.getInt(0) + 4) / 4096 + 1; ++ } ++ // Spigot end + int sectorsLength = numSectors * 4096; + ByteBuffer buffer = ByteBuffer.allocate(sectorsLength); + this.file.read(buffer, sectorNumber * 4096); +@@ -258,6 +_,7 @@ + + return true; + } catch (IOException e) { ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(E); // Paper - ServerExceptionEvent + return false; + } + } +@@ -328,6 +_,11 @@ + try (FileChannel extFile = FileChannel.open(tmpPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { + data.position(5); + extFile.write(data); ++ // Paper start - ServerExceptionEvent ++ } catch (Throwable throwable) { ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); ++ throw throwable; ++ // Paper end - ServerExceptionEvent + } + + return () -> Files.move(tmpPath, path, StandardCopyOption.REPLACE_EXISTING); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch similarity index 54% rename from paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch index 544b1c544fd2..da26ce43b89d 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index c2a372e923ea76481adb08af51481c3fc5244db0..4473503da2459016859b2d72ecd7825df23f4be4 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -29,18 +29,20 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -29,26 +_,33 @@ this.info = info; } @@ -18,20 +10,20 @@ index c2a372e923ea76481adb08af51481c3fc5244db0..4473503da2459016859b2d72ecd7825d RegionFile region = this.regionCache.getAndMoveToFirst(key); if (region != null) { return region; - } else { -- if (this.regionCache.size() >= 256) { -+ int cacheSize = io.papermc.paper.configuration.GlobalConfiguration.get() == null ? 256 : io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize; // Paper - Sanitise RegionFileCache and make configurable - Config not available during initial FileFixerUpper run -+ if (this.regionCache.size() >= cacheSize) { // Paper - Sanitise RegionFileCache and make configurable - this.regionCache.removeLast().close(); - } + } - FileUtil.createDirectoriesSafe(this.folder); - Path file = this.folder.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); -+ if (existingOnly && !java.nio.file.Files.exists(file)) return null; // CraftBukkit - RegionFile newRegion = new RegionFile(this.info, file, this.folder, this.sync); - this.regionCache.putAndMoveToFirst(key, newRegion); - return newRegion; -@@ -48,7 +50,12 @@ public final class RegionFileStorage implements AutoCloseable { +- if (this.regionCache.size() >= 256) { ++ int cacheSize = io.papermc.paper.configuration.GlobalConfiguration.get() == null ? 256 : io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize; // Paper - Sanitise RegionFileCache and make configurable - Config not available during initial FileFixerUpper run ++ if (this.regionCache.size() >= cacheSize) { // Paper - Sanitise RegionFileCache and make configurable + this.regionCache.removeLast().close(); + } + + FileUtil.createDirectoriesSafe(this.folder); + Path file = this.folder.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); ++ if (existingOnly && !java.nio.file.Files.exists(file)) return null; // CraftBukkit + RegionFile newRegion = new RegionFile(this.info, file, this.folder, this.sync); + this.regionCache.putAndMoveToFirst(key, newRegion); + return newRegion; } public @Nullable CompoundTag read(final ChunkPos pos) throws IOException { @@ -43,9 +35,9 @@ index c2a372e923ea76481adb08af51481c3fc5244db0..4473503da2459016859b2d72ecd7825d + } + // CraftBukkit end - CompoundTag var4; try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { -@@ -63,7 +70,12 @@ public final class RegionFileStorage implements AutoCloseable { + return regionChunkInputStream == null ? null : NbtIo.read(regionChunkInputStream); +@@ -56,7 +_,12 @@ } public void scanChunk(final ChunkPos pos, final StreamTagVisitor scanner) throws IOException { @@ -59,7 +51,7 @@ index c2a372e923ea76481adb08af51481c3fc5244db0..4473503da2459016859b2d72ecd7825d try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { if (regionChunkInputStream != null) { -@@ -74,7 +86,7 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -67,7 +_,7 @@ protected void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch new file mode 100644 index 000000000000..16f33d810187 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -0,0 +1,137 @@ +--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java ++++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +@@ -92,6 +_,7 @@ + List entities, + List blockEntities, + CompoundTag structureData ++ , net.minecraft.nbt.@Nullable Tag persistentDataContainer // CraftBukkit - persistentDataContainer + ) { + private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); + private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); +@@ -107,6 +_,24 @@ + public static final String BLOCK_LIGHT_TAG = "BlockLight"; + public static final String SKY_LIGHT_TAG = "SkyLight"; + ++ // Paper start - guard against serializing mismatching coordinates ++ // TODO Note: This needs to be re-checked each update ++ public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) { ++ final int dataVersion = NbtUtils.getDataVersion(chunkData); ++ if (dataVersion < 2842) { // Level tag is removed after this version ++ final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); ++ return new ChunkPos(levelData.getIntOr("xPos", 0), levelData.getIntOr("zPos", 0)); ++ } else { ++ return new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); ++ } ++ } ++ // Paper end - guard against serializing mismatching coordinates ++ ++ // Paper start - Do not let the server load chunks from newer versions ++ private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().dataVersion().version(); ++ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); ++ // Paper end - Do not let the server load chunks from newer versions ++ + public static SerializableChunkData parse( + final LevelHeightAccessor levelHeight, final PalettedContainerFactory containerFactory, final CompoundTag chunkData + ) { +@@ -114,7 +_,15 @@ + return null; + } + +- ChunkPos chunkPos = new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); ++ // Paper start - Do not let the server load chunks from newer versions ++ chunkData.getInt("DataVersion").ifPresent(dataVersion -> { ++ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) { ++ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace(); ++ System.exit(1); ++ } ++ }); ++ // Paper end - Do not let the server load chunks from newer versions ++ ChunkPos chunkPos = new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate + long lastUpdateTime = chunkData.getLongOr("LastUpdate", 0L); + long inhabitedTime = chunkData.getLongOr("InhabitedTime", 0L); + ChunkStatus status = chunkData.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); +@@ -153,7 +_,7 @@ + CompoundTag structureData = chunkData.getCompoundOrEmpty("structures"); + ListTag sectionTags = chunkData.getListOrEmpty("sections"); + List sectionData = new ArrayList<>(sectionTags.size()); +- Codec>> biomesCodec = containerFactory.biomeContainerCodec(); ++ Codec>> biomesCodec = containerFactory.biomeContainerRWCodec(); // CraftBukkit - read/write + Codec> blockStatesCodec = containerFactory.blockStatesContainerCodec(); + + for (int i = 0; i < sectionTags.size(); i++) { +@@ -170,7 +_,7 @@ + .getOrThrow(SerializableChunkData.ChunkReadException::new) + ) + .orElseGet(containerFactory::createForBlockStates); +- PalettedContainerRO> biomes = sectionTag.getCompound("biomes") ++ PalettedContainer> biomes = sectionTag.getCompound("biomes") // CraftBukkit - read/write + .map( + container -> biomesCodec.parse(NbtOps.INSTANCE, container) + .promotePartial(msg -> logErrors(chunkPos, y, msg)) +@@ -207,6 +_,7 @@ + entities, + blockEntities, + structureData ++ , chunkData.get("ChunkBukkitValues") // CraftBukkit - ChunkBukkitValues + ); + } + +@@ -283,6 +_,12 @@ + } + } + ++ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. ++ if (this.persistentDataContainer instanceof CompoundTag compoundTag) { ++ chunk.persistentDataContainer.putAll(compoundTag); ++ } ++ // CraftBukkit end ++ + chunk.setLightCorrect(this.lightCorrect); + EnumSet toPrime = EnumSet.noneOf(Heightmap.Types.class); + +@@ -388,6 +_,12 @@ + .map(shorts -> shorts != null && !shorts.isEmpty() ? new ShortArrayList(shorts) : null) + .toArray(ShortList[]::new); + CompoundTag structureData = packStructureData(StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences()); ++ // CraftBukkit start - store chunk persistent data in nbt ++ CompoundTag persistentDataContainer = null; ++ if (!chunk.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. ++ persistentDataContainer = chunk.persistentDataContainer.toTagCompound(); ++ } ++ // CraftBukkit end + return new SerializableChunkData( + level.palettedContainerFactory(), + pos, +@@ -407,6 +_,7 @@ + entities, + blockEntities, + structureData ++ , persistentDataContainer // CraftBukkit - persistentDataContainer + ); + } + +@@ -473,6 +_,11 @@ + this.heightmaps.forEach((type, data) -> heightmapsTag.put(type.getSerializationKey(), new LongArrayTag(data))); + tag.put("Heightmaps", heightmapsTag); + tag.put("structures", this.structureData); ++ // CraftBukkit start - store chunk persistent data in nbt ++ if (this.persistentDataContainer != null) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. ++ tag.put("ChunkBukkitValues", this.persistentDataContainer); ++ } ++ // CraftBukkit end + return tag; + } + +@@ -556,6 +_,12 @@ + } else { + StructureStart start = StructureStart.loadStaticStart(context, startsTag.getCompoundOrEmpty(key), seed); + if (start != null) { ++ // CraftBukkit start - load persistent data for structure start ++ net.minecraft.nbt.Tag persistentBase = startsTag.getCompoundOrEmpty(key).get("StructureBukkitValues"); ++ if (persistentBase instanceof CompoundTag compoundTag) { ++ start.persistentDataContainer.putAll(compoundTag); ++ } ++ // CraftBukkit end + outmap.put(startFeature, start); + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch new file mode 100644 index 000000000000..33a6fe07c51a --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java ++++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +@@ -44,7 +_,19 @@ + } + + public CompletableFuture write(final ChunkPos pos, final Supplier supplier) { +- return this.worker.store(pos, supplier); ++ // Paper start - guard against possible chunk pos desync ++ final Supplier guardedPosCheck = () -> { ++ final CompoundTag nbt = supplier.get(); ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage && nbt != null && !pos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { ++ final String world = (this instanceof net.minecraft.server.level.ChunkMap chunkMap) ? io.papermc.paper.util.MCUtil.getLevelName(chunkMap.level) : null; ++ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos ++ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); ++ } ++ return nbt; ++ }; ++ return this.worker.store(pos, guardedPosCheck); ++ // Paper end - guard against possible chunk pos desync + } + + public CompoundTag upgradeChunkTag(CompoundTag chunkTag, final int defaultVersion, final @Nullable CompoundTag dataFixContextTag, final int targetVersion) { +@@ -54,8 +_,25 @@ + } + + try { ++ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty ++ boolean stopBelowZero = false; ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage) { ++ final boolean belowZeroGenerationInExistingChunks = (this instanceof net.minecraft.server.level.ChunkMap chunkMap) ++ ? chunkMap.level.spigotConfig.belowZeroGenerationInExistingChunks ++ : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; ++ if (version <= 2730 && !belowZeroGenerationInExistingChunks) { ++ stopBelowZero = "full".equals(chunkTag.getCompound("Level").flatMap(level -> level.getString("Status")).orElse(null)); ++ } ++ } ++ // Spigot end + injectDatafixingContext(chunkTag, dataFixContextTag); + chunkTag = this.dataFixType.update(this.fixerUpper, chunkTag, version, targetVersion); ++ // Spigot start ++ if (stopBelowZero) { ++ chunkTag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); ++ } ++ // Spigot end + removeDatafixingContext(chunkTag); + NbtUtils.addDataVersion(chunkTag, targetVersion); + return chunkTag; diff --git a/paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch similarity index 72% rename from paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index 786141c54ffe..c38a5221cf21 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java -index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e41561fa1a75 100644 --- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java -@@ -53,6 +53,16 @@ public class PersistentEntitySectionManager implements A +@@ -52,6 +_,16 @@ this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } @@ -25,7 +17,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 private void removeSectionIfEmpty(final long sectionPos, final EntitySection section) { if (section.isEmpty()) { this.sectionStorage.remove(sectionPos); -@@ -60,6 +70,7 @@ public class PersistentEntitySectionManager implements A +@@ -59,6 +_,7 @@ } private boolean addEntityUuid(final T entity) { @@ -33,7 +25,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 if (!this.knownUuids.add(entity.getUUID())) { LOGGER.warn("UUID of added entity already exists: {}", entity); return false; -@@ -73,6 +84,17 @@ public class PersistentEntitySectionManager implements A +@@ -72,6 +_,17 @@ } private boolean addEntity(final T entity, final boolean loaded) { @@ -50,8 +42,8 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 + // Paper end - chunk system hooks if (!this.addEntityUuid(entity)) { return false; - } else { -@@ -114,19 +136,23 @@ public class PersistentEntitySectionManager implements A + } +@@ -113,19 +_,23 @@ } private void startTicking(final T entity) { @@ -75,7 +67,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 this.callbacks.onTrackingEnd(entity); this.visibleEntityStorage.remove(entity); } -@@ -137,6 +163,7 @@ public class PersistentEntitySectionManager implements A +@@ -136,6 +_,7 @@ } public void updateChunkStatus(final ChunkPos pos, final Visibility chunkStatus) { @@ -83,7 +75,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 long chunkPosKey = pos.pack(); if (chunkStatus == Visibility.HIDDEN) { this.chunkVisibility.remove(chunkPosKey); -@@ -170,6 +197,7 @@ public class PersistentEntitySectionManager implements A +@@ -169,6 +_,7 @@ } public void ensureChunkQueuedForLoad(final long chunkPos) { @@ -91,7 +83,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPos); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.FRESH) { this.requestChunkLoad(chunkPos); -@@ -177,6 +205,11 @@ public class PersistentEntitySectionManager implements A +@@ -176,6 +_,11 @@ } private boolean storeChunkSections(final long chunkPos, final Consumer savedEntityVisitor) { @@ -103,23 +95,23 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPos); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) { return false; -@@ -187,6 +220,7 @@ public class PersistentEntitySectionManager implements A - .collect(Collectors.toList()); - if (rootEntitiesToSave.isEmpty()) { - if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) { -+ if (callEvent) org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level, ChunkPos.unpack(chunkPos), ImmutableList.of()); // CraftBukkit - this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), ImmutableList.of())); - } - -@@ -195,6 +229,7 @@ public class PersistentEntitySectionManager implements A - this.requestChunkLoad(chunkPos); - return false; - } else { -+ if (callEvent) org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level, ChunkPos.unpack(chunkPos), rootEntitiesToSave.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit - this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), rootEntitiesToSave)); - rootEntitiesToSave.forEach(savedEntityVisitor); - return true; -@@ -203,6 +238,7 @@ public class PersistentEntitySectionManager implements A +@@ -187,6 +_,7 @@ + .collect(Collectors.toList()); + if (rootEntitiesToSave.isEmpty()) { + if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) { ++ if (callEvent) org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level, ChunkPos.unpack(chunkPos), ImmutableList.of()); // CraftBukkit + this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), ImmutableList.of())); + } + +@@ -195,6 +_,7 @@ + this.requestChunkLoad(chunkPos); + return false; + } else { ++ if (callEvent) org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesUnloadEvent(((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level, ChunkPos.unpack(chunkPos), rootEntitiesToSave.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit + this.permanentStorage.storeEntities(new ChunkEntities<>(ChunkPos.unpack(chunkPos), rootEntitiesToSave)); + rootEntitiesToSave.forEach(savedEntityVisitor); + return true; +@@ -202,6 +_,7 @@ } private void requestChunkLoad(final long chunkKey) { @@ -127,7 +119,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 this.chunkLoadStatuses.put(chunkKey, PersistentEntitySectionManager.ChunkLoadStatus.PENDING); ChunkPos pos = ChunkPos.unpack(chunkKey); this.permanentStorage.loadEntities(pos).thenAccept(this.loadingInbox::add).exceptionally(t -> { -@@ -212,7 +248,8 @@ public class PersistentEntitySectionManager implements A +@@ -211,7 +_,8 @@ } private boolean processChunkUnload(final long chunkKey) { @@ -136,8 +128,8 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 + boolean storeSuccessful = this.storeChunkSections(chunkKey, entity -> entity.getPassengersAndSelf().forEach(this::unloadEntity), true); // CraftBukkit - add boolean for event call if (!storeSuccessful) { return false; - } else { -@@ -222,7 +259,7 @@ public class PersistentEntitySectionManager implements A + } +@@ -221,7 +_,7 @@ } private void unloadEntity(final EntityAccess e) { @@ -146,7 +138,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 e.setLevelCallback(EntityInLevelCallback.NULL); } -@@ -231,14 +268,20 @@ public class PersistentEntitySectionManager implements A +@@ -230,14 +_,20 @@ } public void processPendingLoads() { @@ -167,7 +159,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 this.processPendingLoads(); this.processUnloads(); } -@@ -256,6 +299,7 @@ public class PersistentEntitySectionManager implements A +@@ -255,6 +_,7 @@ } public void autoSave() { @@ -175,7 +167,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 this.getAllChunksToSave().forEach(chunkKey -> { boolean shouldUnload = this.chunkVisibility.get(chunkKey) == Visibility.HIDDEN; if (shouldUnload) { -@@ -267,6 +311,7 @@ public class PersistentEntitySectionManager implements A +@@ -266,6 +_,7 @@ } public void saveAll() { @@ -183,7 +175,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 LongSet chunksToSave = this.getAllChunksToSave(); while (!chunksToSave.isEmpty()) { -@@ -283,7 +328,13 @@ public class PersistentEntitySectionManager implements A +@@ -282,7 +_,13 @@ @Override public void close() throws IOException { @@ -198,7 +190,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 this.permanentStorage.close(); } -@@ -386,6 +437,7 @@ public class PersistentEntitySectionManager implements A +@@ -383,6 +_,7 @@ BlockPos pos = this.entity.blockPosition(); long newSectionPos = SectionPos.asLong(pos); if (newSectionPos != this.currentSectionKey) { @@ -206,7 +198,7 @@ index 5b5442e694f343ab6b2181c8a98f3e1fda5e4514..8b5e5757619a36fa3e4720c970a0e415 Visibility previousStatus = this.currentSection.getStatus(); if (!this.currentSection.remove(this.entity)) { PersistentEntitySectionManager.LOGGER -@@ -433,6 +485,7 @@ public class PersistentEntitySectionManager implements A +@@ -430,6 +_,7 @@ @Override public void onRemove(final Entity.RemovalReason reason) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch new file mode 100644 index 000000000000..e785ad48bc70 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java ++++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java +@@ -123,7 +_,7 @@ + public static final Codec CODEC = RecordCodecBuilder.create( + i -> i.group( + VibrationInfo.CODEC.lenientOptionalFieldOf("event").forGetter(o -> Optional.ofNullable(o.currentVibration)), +- VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.Data::getSelectionStrategy), ++ VibrationSelector.CODEC.optionalFieldOf("selector").xmap(o -> o.orElseGet(VibrationSelector::new), Optional::of).forGetter(VibrationSystem.Data::getSelectionStrategy), // Paper - fix MapLike spam for missing "selector" in 1.19.2 + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.Data::getTravelTimeInTicks) + ) + .apply( +@@ -223,7 +_,14 @@ + } + + Vec3 destination = listenerSourcePos.get(); +- if (!user.canReceiveVibration(level, BlockPos.containing(sourcePosition), event, context)) { ++ // CraftBukkit start ++ boolean defaultCancel = !user.canReceiveVibration(level, BlockPos.containing(sourcePosition), event, context); ++ Entity entity = context.sourceEntity(); ++ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(event), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(sourcePosition)), (entity == null) ? null : entity.getBukkitEntity()); ++ event1.setCancelled(defaultCancel); ++ level.getCraftServer().getPluginManager().callEvent(event1); ++ if (event1.isCancelled()) { ++ // CraftBukkit end + return false; + } + From 3449294fe086e5219b1f363216029698c097f0f4 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 13 May 2026 14:22:22 +0100 Subject: [PATCH 14/16] Finish source patches --- build.gradle.kts | 1 + paper-server/build.gradle.kts | 3 - .../chat/SignedMessageChain.java.patch | 44 ---- .../minecraft/util/ZeroBitStorage.java.patch | 40 ---- .../ExplorationMapFunction.java.patch | 38 ---- .../minecraft/commands/Commands.java.patch | 2 +- .../component/DataComponentPatch.java.patch | 30 +-- .../framework/GameTestServer.java.patch | 25 +-- .../chat/SignedMessageChain.java.patch | 37 ++++ .../dedicated/DedicatedServer.java.patch | 2 +- .../ServerCommonPacketListenerImpl.java.patch | 2 +- .../util/SimpleBitStorage.java.patch | 28 +-- .../minecraft/util/ZeroBitStorage.java.patch | 32 +++ .../world/effect/WeavingMobEffect.java.patch | 2 +- .../entity/animal/camel/Camel.java.patch | 42 ++-- .../world/entity/animal/goat/Goat.java.patch | 30 +-- .../entity/animal/parrot/Parrot.java.patch | 36 ++- .../boss/enderdragon/EndCrystal.java.patch | 64 +++--- .../entity/monster/piglin/Piglin.java.patch | 39 ++-- .../world/entity/player/Player.java.patch | 207 +++++++++--------- .../inventory/EnchantmentMenu.java.patch | 12 +- .../item/alchemy/PotionBrewing.java.patch | 50 ++--- .../crafting/SmithingTrimRecipe.java.patch | 28 +-- .../item/trading/MerchantOffer.java.patch | 45 ++-- .../world/level/NaturalSpawner.java.patch | 4 +- .../entity/LecternBlockEntity.java.patch | 6 +- .../block/entity/SignBlockEntity.java.patch | 6 +- .../world/level/chunk/LevelChunk.java.patch | 23 +- .../level/chunk/storage/RegionFile.java.patch | 2 +- .../structure/StructureCheck.java.patch | 32 +-- .../level/portal/PortalForcer.java.patch | 26 +-- .../world/level/portal/PortalShape.java.patch | 54 ++--- .../ExplorationMapFunction.java.patch | 29 +++ 33 files changed, 434 insertions(+), 587 deletions(-) delete mode 100644 paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch delete mode 100644 paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/core/component/DataComponentPatch.java.patch (76%) rename paper-server/patches/{rejected => sources}/net/minecraft/gametest/framework/GameTestServer.java.patch (66%) create mode 100644 paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/util/SimpleBitStorage.java.patch (71%) create mode 100644 paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/camel/Camel.java.patch (58%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/goat/Goat.java.patch (65%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/animal/parrot/Parrot.java.patch (55%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch (55%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/monster/piglin/Piglin.java.patch (60%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/entity/player/Player.java.patch (76%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/alchemy/PotionBrewing.java.patch (69%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch (71%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/item/trading/MerchantOffer.java.patch (71%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch (62%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/portal/PortalForcer.java.patch (89%) rename paper-server/patches/{rejected => sources}/net/minecraft/world/level/portal/PortalShape.java.patch (83%) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch diff --git a/build.gradle.kts b/build.gradle.kts index 2336fd226cbf..b68e134ff003 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,6 +40,7 @@ subprojects { } repositories { + mavenLocal() mavenCentral() maven(paperMavenPublicUrl) } diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index aa72cb431f80..ebea2573deb8 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,9 +14,6 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" -repositories { - mavenLocal() -} dependencies { mache("io.papermc:mache:26.1.2+build.local-SNAPSHOT") paperclip("io.papermc:paperclip:3.0.4") diff --git a/paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch deleted file mode 100644 index cd749cae11ae..000000000000 --- a/paper-server/patches/rejected/net/minecraft/network/chat/SignedMessageChain.java.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java -index ece327e088f0abab844b1d9e2f5bfaee8f196828..99a8a8b5cb65bd94d9496ddb6ff11b8a67f3a870 100644 ---- a/net/minecraft/network/chat/SignedMessageChain.java -+++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -44,14 +44,14 @@ public class SignedMessageChain { - if (signature == null) { - throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.MISSING_PROFILE_KEY); - } else if (profilePublicKey.data().hasExpired()) { -- throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY); -+ throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes - } else { - SignedMessageLink link = SignedMessageChain.this.nextLink; - if (link == null) { - throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN); - } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { - this.setChainBroken(); -- throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT); -+ throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes - } else { - SignedMessageChain.this.lastTimeStamp = body.timeStamp(); - PlayerChatMessage unpacked = new PlayerChatMessage(link, signature, body, null, FilterMask.PASS_THROUGH); -@@ -84,8 +84,15 @@ public class SignedMessageChain { - private static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); - private static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); - -- public DecodeException(final Component component) { -+ // Paper start -+ public final org.bukkit.event.player.PlayerKickEvent.Cause kickCause; -+ public DecodeException(Component component, org.bukkit.event.player.PlayerKickEvent.Cause event) { - super(component); -+ this.kickCause = event; -+ } -+ // Paper end -+ public DecodeException(final Component component) { -+ this(component, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); // Paper - } - } - diff --git a/paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch b/paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch deleted file mode 100644 index 174627de1a2a..000000000000 --- a/paper-server/patches/rejected/net/minecraft/util/ZeroBitStorage.java.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java -index 6e2786e9f0812ce0dfa9ce8dd59f5a5cf1141bf2..1ceb7e4a3abd4d9de5133d182d3267d2164918f6 100644 ---- a/net/minecraft/util/ZeroBitStorage.java -+++ b/net/minecraft/util/ZeroBitStorage.java -@@ -13,21 +13,21 @@ public class ZeroBitStorage implements BitStorage { - } - - @Override -- public int getAndSet(final int index, final int value) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); -- Validate.inclusiveBetween(0L, 0L, (long)value); -+ public final int getAndSet(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage -+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage -+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper - Perf: Optimize SimpleBitStorage - return 0; - } - - @Override -- public void set(final int index, final int value) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); -- Validate.inclusiveBetween(0L, 0L, (long)value); -+ public final void set(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage -+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage -+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper - Perf: Optimize SimpleBitStorage - } - - @Override -- public int get(final int index) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); -+ public final int get(final int index) { // Paper - Perf: Optimize SimpleBitStorage -+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage - return 0; - } - diff --git a/paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch b/paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch deleted file mode 100644 index f13f2772654b..000000000000 --- a/paper-server/patches/rejected/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -index 27e2c28bfabe090ee7035a4f78c6b4d8ce1eee92..425d499f45280b59ba225d19218a991614ce06db 100644 ---- a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -+++ b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -@@ -83,9 +83,25 @@ public class ExplorationMapFunction extends LootItemConditionalFunction { - Vec3 lootPos = context.getOptionalParameter(LootContextParams.ORIGIN); - if (lootPos != null) { - ServerLevel level = context.getLevel(); -+ // Paper start - Configurable cartographer treasure maps -+ // Simple heuristic for determining if this function is running in the context of a villager selecting -+ // an item for its offers. Technically other callers could satisfiy this but this minimises the diff and -+ // works for all plain vanilla usecases. -+ final boolean runningForVillagerTrade = context.hasParameter(LootContextParams.ADDITIONAL_COST_COMPONENT_ALLOWED) -+ && context.getOptionalParameter(LootContextParams.THIS_ENTITY) instanceof net.minecraft.world.entity.npc.villager.AbstractVillager; -+ if (!level.paperConfig().environment.treasureMaps.enabled) { -+ /* -+ * NOTE: I fear users will just get a plain map as their "treasure" -+ * This is preferable to disrespecting the config. -+ */ -+ return runningForVillagerTrade ? net.minecraft.world.item.ItemStack.EMPTY : itemStack; -+ } -+ final boolean shouldSkipKnownStructures = runningForVillagerTrade -+ ? !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager -+ : !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(!this.skipKnownStructures); -+ // Paper end - Configurable cartographer treasure maps - BlockPos nearestMapStructure = level.findNearestMapStructure( -- this.destination, BlockPos.containing(lootPos), this.searchRadius, this.skipKnownStructures -- ); -+ this.destination, BlockPos.containing(lootPos), this.searchRadius, shouldSkipKnownStructures); // Paper - Configurable cartographer treasure maps - if (nearestMapStructure != null) { - ItemStack map = MapItem.create(level, nearestMapStructure.getX(), nearestMapStructure.getZ(), this.zoom, true, true); - MapItem.renderBiomePreviewMap(level, map); diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index ebd705212a61..bd76d801d6ee 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -109,7 +109,7 @@ + // Paper start - Add UnknownCommandEvent + final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text(); + // sender.sendFailure(ComponentUtils.fromMessage(var7.getRawMessage())); -+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage())); ++ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(e.getRawMessage())); + // Paper end - Add UnknownCommandEvent if (e.getInput() != null && e.getCursor() >= 0) { int cursor = Math.min(e.getInput().length(), e.getCursor()); diff --git a/paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch rename to paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch index 9415190e5717..bf66928dede9 100644 --- a/paper-server/patches/rejected/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/core/component/DataComponentPatch.java b/net/minecraft/core/component/DataComponentPatch.java -index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896526417bc 100644 --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -106,6 +106,11 @@ public final class DataComponentPatch { +@@ -106,6 +_,11 @@ output.writeVarInt(0); output.writeVarInt(0); } else { @@ -20,7 +12,7 @@ index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896 int positiveCount = 0; int negativeCount = 0; -@@ -113,7 +118,7 @@ public final class DataComponentPatch { +@@ -113,7 +_,7 @@ patch.map )) { if (entry.getValue().isPresent()) { @@ -29,15 +21,15 @@ index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896 } else { negativeCount++; } -@@ -126,6 +131,7 @@ public final class DataComponentPatch { +@@ -126,6 +_,7 @@ patch.map )) { - Optional value = entryx.getValue(); -+ value = io.papermc.paper.util.sanitizer.ItemComponentSanitizer.override(itemObfuscationSession, entryx.getKey(), entryx.getValue()); // Paper - data sanitization for items + Optional value = entry.getValue(); ++ value = io.papermc.paper.util.sanitizer.ItemComponentSanitizer.override(itemObfuscationSession, entry.getKey(), entry.getValue()); // Paper - data sanitization for items if (value.isPresent()) { - DataComponentType type = entryx.getKey(); + DataComponentType type = entry.getKey(); DataComponentType.STREAM_CODEC.encode(output, type); -@@ -145,7 +151,13 @@ public final class DataComponentPatch { +@@ -145,7 +_,13 @@ } private void encodeComponent(final RegistryFriendlyByteBuf output, final DataComponentType type, final Object value) { @@ -52,10 +44,11 @@ index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896 } }; } -@@ -256,6 +268,42 @@ public final class DataComponentPatch { +@@ -255,6 +_,42 @@ + private Builder() { } - ++ + // CraftBukkit start + public void copy(DataComponentPatch orig) { + this.map.putAll(orig.map); @@ -91,7 +84,6 @@ index 703570fe930bef64ebdf2c6798565b00c0e6267d..1df1ffe9b19a82d199314935dad82896 + return this.map.hashCode(); + } + // CraftBukkit end -+ + public DataComponentPatch.Builder set(final DataComponentType type, final T value) { this.map.put(type, Optional.of(value)); - return this; diff --git a/paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch similarity index 66% rename from paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch rename to paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index 1482a3588d07..d4acbfb1c257 100644 --- a/paper-server/patches/rejected/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/gametest/framework/GameTestServer.java b/net/minecraft/gametest/framework/GameTestServer.java -index 6e368ce9256beb9db4dec8037d9d77dd2b4519c1..17541fbe120bcb21689ac2a08c4c65913ee03cb7 100644 --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -155,6 +155,8 @@ public class GameTestServer extends MinecraftServer { +@@ -154,6 +_,8 @@ final int repeatCount ) { super( @@ -17,21 +9,18 @@ index 6e368ce9256beb9db4dec8037d9d77dd2b4519c1..17541fbe120bcb21689ac2a08c4c6591 serverThread, levelStorageSource, packRepository, -@@ -173,13 +175,21 @@ public class GameTestServer extends MinecraftServer { +@@ -172,9 +_,17 @@ @Override protected boolean initServer() { +- this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) {}); + // Paper start - this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) { - { - Objects.requireNonNull(GameTestServer.this); - } -+ ++ this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) { + @Override + public void loadAndSaveFiles() { + throw new UnsupportedOperationException("Should not be called in a GameTestServer"); + } - }); ++ }); + this.initPostWorld(); Gizmos.withCollector(GizmoCollector.NOOP); - this.loadLevel(); @@ -40,7 +29,7 @@ index 6e368ce9256beb9db4dec8037d9d77dd2b4519c1..17541fbe120bcb21689ac2a08c4c6591 ServerLevel level = this.overworld(); this.testBatches = this.evaluateTestsToRun(level); LOGGER.info("Started game test server"); -@@ -385,6 +395,13 @@ public class GameTestServer extends MinecraftServer { +@@ -380,6 +_,13 @@ return false; } @@ -54,7 +43,7 @@ index 6e368ce9256beb9db4dec8037d9d77dd2b4519c1..17541fbe120bcb21689ac2a08c4c6591 @Override public boolean isSingleplayerOwner(final NameAndId nameAndId) { return false; -@@ -432,5 +449,16 @@ public class GameTestServer extends MinecraftServer { +@@ -427,5 +_,16 @@ @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch new file mode 100644 index 000000000000..3bb5db8b395e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/network/chat/SignedMessageChain.java ++++ b/net/minecraft/network/chat/SignedMessageChain.java +@@ -41,7 +_,7 @@ + } + + if (profilePublicKey.data().hasExpired()) { +- throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY); ++ throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.EXPIRED_PROFILE_KEY, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes + } + + SignedMessageLink link = SignedMessageChain.this.nextLink; +@@ -51,7 +_,7 @@ + + if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { + this.setChainBroken(); +- throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT); ++ throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes + } + + SignedMessageChain.this.lastTimeStamp = body.timeStamp(); +@@ -83,8 +_,15 @@ + private static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); + private static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); + +- public DecodeException(final Component component) { ++ // Paper start ++ public final org.bukkit.event.player.PlayerKickEvent.Cause kickCause; ++ public DecodeException(Component component, org.bukkit.event.player.PlayerKickEvent.Cause event) { + super(component); ++ this.kickCause = event; ++ } ++ // Paper end ++ public DecodeException(final Component component) { ++ this(component, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); // Paper + } + } + diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index 401112c2a841..7e43d28d3f0c 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -157,7 +157,7 @@ LOGGER.warn("**** FAILED TO BIND TO PORT!"); LOGGER.warn("The exception was: {}", e.toString()); LOGGER.warn("Perhaps a server is already running on that port?"); -+ if (true) throw new IllegalStateException("Failed to bind to port", var11); // Paper - Propagate failed to bind to port error ++ if (true) throw new IllegalStateException("Failed to bind to port", e); // Paper - Propagate failed to bind to port error return false; } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index cd0231da8081..19e75f568090 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -188,7 +188,7 @@ + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // use vanilla's 15000L between keep alive packets if (this.keepAlivePending) { - this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE); -+ if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected ++ if (elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected + this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, io.papermc.paper.connection.DisconnectionReason.TIMEOUT); // Paper - kick event cause + } + // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings diff --git a/paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch b/paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch similarity index 71% rename from paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch rename to paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch index 73a321a9f4ef..a65553b73845 100644 --- a/paper-server/patches/rejected/net/minecraft/util/SimpleBitStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/SimpleBitStorage.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java -index dff969b9f0d320616f93bd7dca1b5660b5f316bd..cd9b408afdabb632ceba265c8de6035e1276024f 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java -@@ -204,8 +204,8 @@ public class SimpleBitStorage implements BitStorage { +@@ -204,8 +_,8 @@ private final long mask; private final int size; private final int valuesPerLong; @@ -19,7 +11,7 @@ index dff969b9f0d320616f93bd7dca1b5660b5f316bd..cd9b408afdabb632ceba265c8de6035e private final int divideShift; public SimpleBitStorage(final int bits, final int size, final int[] values) { -@@ -248,8 +248,8 @@ public class SimpleBitStorage implements BitStorage { +@@ -248,8 +_,8 @@ this.mask = (1L << bits) - 1L; this.valuesPerLong = (char)(64 / bits); int row = 3 * (this.valuesPerLong - 1); @@ -30,7 +22,7 @@ index dff969b9f0d320616f93bd7dca1b5660b5f316bd..cd9b408afdabb632ceba265c8de6035e this.divideShift = MAGIC[row + 2]; int requiredLength = (size + this.valuesPerLong - 1) / this.valuesPerLong; if (data != null) { -@@ -264,15 +264,11 @@ public class SimpleBitStorage implements BitStorage { +@@ -264,15 +_,11 @@ } private int cellIndex(final int bitIndex) { @@ -42,29 +34,29 @@ index dff969b9f0d320616f93bd7dca1b5660b5f316bd..cd9b408afdabb632ceba265c8de6035e @Override - public int getAndSet(final int index, final int value) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); -- Validate.inclusiveBetween(0L, this.mask, (long)value); +- Validate.inclusiveBetween(0L, this.size - 1, index); +- Validate.inclusiveBetween(0L, this.mask, value); + public final int getAndSet(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage int cellIndex = this.cellIndex(index); long cellValue = this.data[cellIndex]; int bitIndex = (index - cellIndex * this.valuesPerLong) * this.bits; -@@ -282,9 +278,7 @@ public class SimpleBitStorage implements BitStorage { +@@ -282,9 +_,7 @@ } @Override - public void set(final int index, final int value) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); -- Validate.inclusiveBetween(0L, this.mask, (long)value); +- Validate.inclusiveBetween(0L, this.size - 1, index); +- Validate.inclusiveBetween(0L, this.mask, value); + public final void set(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage int cellIndex = this.cellIndex(index); long cellValue = this.data[cellIndex]; int bitIndex = (index - cellIndex * this.valuesPerLong) * this.bits; -@@ -292,8 +286,7 @@ public class SimpleBitStorage implements BitStorage { +@@ -292,8 +_,7 @@ } @Override - public int get(final int index) { -- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); +- Validate.inclusiveBetween(0L, this.size - 1, index); + public final int get(final int index) { // Paper - Perf: Optimize SimpleBitStorage int cellIndex = this.cellIndex(index); long cellValue = this.data[cellIndex]; diff --git a/paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch b/paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch new file mode 100644 index 000000000000..e6aba154593b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/util/ZeroBitStorage.java.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/util/ZeroBitStorage.java ++++ b/net/minecraft/util/ZeroBitStorage.java +@@ -13,21 +_,21 @@ + } + + @Override +- public int getAndSet(final int index, final int value) { +- Validate.inclusiveBetween(0L, this.size - 1, index); +- Validate.inclusiveBetween(0L, 0L, value); ++ public final int getAndSet(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage ++ //Validate.inclusiveBetween(0L, this.size - 1, index); // Paper - Perf: Optimize SimpleBitStorage ++ //Validate.inclusiveBetween(0L, 0L, value); // Paper - Perf: Optimize SimpleBitStorage + return 0; + } + + @Override +- public void set(final int index, final int value) { +- Validate.inclusiveBetween(0L, this.size - 1, index); +- Validate.inclusiveBetween(0L, 0L, value); ++ public final void set(final int index, final int value) { // Paper - Perf: Optimize SimpleBitStorage ++ //Validate.inclusiveBetween(0L, this.size - 1, index); // Paper - Perf: Optimize SimpleBitStorage ++ //Validate.inclusiveBetween(0L, 0L, value); // Paper - Perf: Optimize SimpleBitStorage + } + + @Override +- public int get(final int index) { +- Validate.inclusiveBetween(0L, this.size - 1, index); ++ public final int get(final int index) { // Paper - Perf: Optimize SimpleBitStorage ++ //Validate.inclusiveBetween(0L, this.size - 1, index); // Paper - Perf: Optimize SimpleBitStorage + return 0; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch index 5ceb689af4fd..5656eff4b856 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -18,7 +18,7 @@ } for (BlockPos blockPos : positionsToTransform) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPosx, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places level.setBlock(blockPos, Blocks.COBWEB.defaultBlockState(), Block.UPDATE_ALL); level.levelEvent(LevelEvent.ANIMATION_SPAWN_COBWEB, blockPos, 0); } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch similarity index 58% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch index 2b40899874ad..f8b8732305f8 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,29 +1,21 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java -index 64e09cdbfabc7cf7c627bca7e0b4e7a162329f30..1aa18543428578ff773a32c24f33b843b10e8e27 100644 --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -419,12 +419,12 @@ public class Camel extends AbstractHorse { - } else { - boolean couldHeal = this.getHealth() < this.getMaxHealth(); - if (couldHeal) { -- this.heal(2.0F); -+ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason - } +@@ -419,12 +_,12 @@ - boolean couldSetInLove = this.isTamed() && this.getAge() == 0 && this.canFallInLove(); - if (couldSetInLove) { -- this.setInLove(player); -+ this.setInLove(player, itemStack.copy()); // Paper - Fix EntityBreedEvent copying - } + boolean couldHeal = this.getHealth() < this.getMaxHealth(); + if (couldHeal) { +- this.heal(2.0F); ++ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason + } - boolean couldAgeUp = this.canAgeUp(); -@@ -482,9 +482,13 @@ public class Camel extends AbstractHorse { + boolean couldSetInLove = this.isTamed() && this.getAge() == 0 && this.canFallInLove(); + if (couldSetInLove) { +- this.setInLove(player); ++ this.setInLove(player, itemStack.copy()); // Paper - Fix EntityBreedEvent copying + } + + boolean couldAgeUp = this.canAgeUp(); +@@ -481,9 +_,13 @@ } @Override @@ -39,7 +31,7 @@ index 64e09cdbfabc7cf7c627bca7e0b4e7a162329f30..1aa18543428578ff773a32c24f33b843 } @Override -@@ -581,7 +585,7 @@ public class Camel extends AbstractHorse { +@@ -580,7 +_,7 @@ } public void sitDown() { @@ -48,7 +40,7 @@ index 64e09cdbfabc7cf7c627bca7e0b4e7a162329f30..1aa18543428578ff773a32c24f33b843 this.makeSound(this.getSitDownSound()); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -590,7 +594,7 @@ public class Camel extends AbstractHorse { +@@ -589,7 +_,7 @@ } public void standUp() { @@ -57,7 +49,7 @@ index 64e09cdbfabc7cf7c627bca7e0b4e7a162329f30..1aa18543428578ff773a32c24f33b843 this.makeSound(this.getStandUpSound()); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -607,6 +611,7 @@ public class Camel extends AbstractHorse { +@@ -606,6 +_,7 @@ } public void standUpInstantly() { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch similarity index 65% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch index a01af29d62d9..55be4351a51f 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java -index 72854d67bd96eafaa0530df646aad89e476d37c3..e7beaf8f5a1c6c393e158f15da422217976850f0 100644 --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -213,8 +213,16 @@ public class Goat extends Animal { +@@ -213,8 +_,16 @@ public InteractionResult mobInteract(final Player player, final InteractionHand hand) { ItemStack heldItem = player.getItemInHand(hand); if (heldItem.is(Items.BUCKET) && !this.isBaby()) { @@ -25,18 +17,18 @@ index 72854d67bd96eafaa0530df646aad89e476d37c3..e7beaf8f5a1c6c393e158f15da422217 + ItemStack bucketOrMilkBucket = ItemUtils.createFilledResult(heldItem, player, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit player.setItemInHand(hand, bucketOrMilkBucket); return InteractionResult.SUCCESS; - } else { -@@ -328,8 +336,7 @@ public class Goat extends Animal { - double deltaY = Mth.randomBetween(this.random, 0.3F, 0.7F); - double deltaZ = Mth.randomBetween(this.random, -0.2F, 0.2F); - ItemEntity itemEntity = new ItemEntity(this.level(), bodyPosition.x(), bodyPosition.y(), bodyPosition.z(), item, deltaX, deltaY, deltaZ); -- this.level().addFreshEntity(itemEntity); -- return true; -+ return this.spawnAtLocation((net.minecraft.server.level.ServerLevel) this.level(), itemEntity) != null; // Paper - Call EntityDropItemEvent - } } +@@ -330,8 +_,7 @@ + double deltaY = Mth.randomBetween(this.random, 0.3F, 0.7F); + double deltaZ = Mth.randomBetween(this.random, -0.2F, 0.2F); + ItemEntity itemEntity = new ItemEntity(this.level(), bodyPosition.x(), bodyPosition.y(), bodyPosition.z(), item, deltaX, deltaY, deltaZ); +- this.level().addFreshEntity(itemEntity); +- return true; ++ return this.spawnAtLocation((net.minecraft.server.level.ServerLevel) this.level(), itemEntity) != null; // Paper - Call EntityDropItemEvent } -@@ -352,4 +359,15 @@ public class Goat extends Animal { + + public boolean isScreamingGoat() { +@@ -352,4 +_,15 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); } diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch similarity index 55% rename from paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index bb463f36c2ca..873d72918306 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/animal/parrot/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/animal/parrot/Parrot.java b/net/minecraft/world/entity/animal/parrot/Parrot.java -index e1c653b2a4f77f0a5f4e35104439b71b59a7877d..11d599a8b3af8422de4b4c4043674c96d04cae13 100644 --- a/net/minecraft/world/entity/animal/parrot/Parrot.java +++ b/net/minecraft/world/entity/animal/parrot/Parrot.java -@@ -270,7 +270,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { +@@ -270,7 +_,7 @@ } if (!this.level().isClientSide()) { @@ -17,7 +9,7 @@ index e1c653b2a4f77f0a5f4e35104439b71b59a7877d..11d599a8b3af8422de4b4c4043674c96 this.tame(player); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -291,7 +291,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { +@@ -291,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemStack); @@ -26,7 +18,7 @@ index e1c653b2a4f77f0a5f4e35104439b71b59a7877d..11d599a8b3af8422de4b4c4043674c96 if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -384,8 +384,8 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { +@@ -384,8 +_,8 @@ } @Override @@ -37,18 +29,18 @@ index e1c653b2a4f77f0a5f4e35104439b71b59a7877d..11d599a8b3af8422de4b4c4043674c96 } @Override -@@ -400,8 +400,13 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal { - if (this.isInvulnerableTo(level, source)) { +@@ -401,8 +_,13 @@ return false; - } else { -+ // CraftBukkit start -+ if (!super.hurtServer(level, source, damage)) { -+ return false; -+ } - this.setOrderedToSit(false); -- return super.hurtServer(level, source, damage); -+ return true; -+ // CraftBukkit } + ++ // CraftBukkit start ++ if (!super.hurtServer(level, source, damage)) { ++ return false; ++ } + this.setOrderedToSit(false); +- return super.hurtServer(level, source, damage); ++ return true; ++ // CraftBukkit } + public Parrot.Variant getVariant() { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch similarity index 55% rename from paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch index 2971a2fbcd49..6c255ac04f2e 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java -index 921744784f95f46f13ad776502b3ec451ffff2e2..b45208810c5e1623fc8d0f77a2b42d448fc8912b 100644 --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java -@@ -26,6 +26,7 @@ public class EndCrystal extends Entity { +@@ -26,6 +_,7 @@ private static final EntityDataAccessor DATA_SHOW_BOTTOM = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.BOOLEAN); private static final boolean DEFAULT_SHOW_BOTTOM = true; public int time; @@ -16,15 +8,17 @@ index 921744784f95f46f13ad776502b3ec451ffff2e2..b45208810c5e1623fc8d0f77a2b42d44 public EndCrystal(final EntityType type, final Level level) { super(type, level); -@@ -57,21 +58,37 @@ public class EndCrystal extends Entity { +@@ -57,21 +_,37 @@ if (this.level() instanceof ServerLevel) { BlockPos pos = this.blockPosition(); if (((ServerLevel)this.level()).getDragonFight() != null && this.level().getBlockState(pos).isAir()) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), pos, this).isCancelled()) { // Paper this.level().setBlockAndUpdate(pos, BaseFireBlock.getState(this.level(), pos)); +- } +- } + } // Paper - } - } ++ } ++ } + + // Paper start - Fix invulnerable end crystals + if (this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) { @@ -54,30 +48,30 @@ index 921744784f95f46f13ad776502b3ec451ffff2e2..b45208810c5e1623fc8d0f77a2b42d44 } @Override -@@ -92,10 +109,24 @@ public class EndCrystal extends Entity { - return false; - } else { - if (!this.isRemoved()) { -- this.remove(Entity.RemovalReason.KILLED); -+ // CraftBukkit start - All non-living entities need this -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage, false)) { +@@ -95,10 +_,24 @@ + } + + if (!this.isRemoved()) { +- this.remove(Entity.RemovalReason.KILLED); ++ // CraftBukkit start - All non-living entities need this ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, damage, false)) { ++ return false; ++ } ++ // CraftBukkit end + if (!source.is(DamageTypeTags.IS_EXPLOSION)) { + DamageSource damageSource = source.getEntity() != null ? this.damageSources().explosion(this, source.getEntity()) : null; +- level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), 6.0F, false, Level.ExplosionInteraction.BLOCK); ++ // CraftBukkit start ++ org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false); ++ if (event.isCancelled()) { + return false; + } -+ // CraftBukkit end - if (!source.is(DamageTypeTags.IS_EXPLOSION)) { - DamageSource damageSource = source.getEntity() != null ? this.damageSources().explosion(this, source.getEntity()) : null; -- level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), 6.0F, false, Level.ExplosionInteraction.BLOCK); -+ // CraftBukkit start -+ org.bukkit.event.entity.ExplosionPrimeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false); -+ if (event.isCancelled()) { -+ return false; -+ } + -+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // Paper - add Bukkit remove cause -+ level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.BLOCK); -+ } else { -+ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // Paper - add Bukkit remove cause -+ // CraftBukkit end - } ++ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // Paper - add Bukkit remove cause ++ level.explode(this, damageSource, null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.BLOCK); ++ } else { ++ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // Paper - add Bukkit remove cause ++ // CraftBukkit end + } - this.onDestroyedBy(level, source); + this.onDestroyedBy(level, source); diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch similarity index 60% rename from paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 811cac983289..c24dbb871d6b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java -index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6354c0a64 100644 --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -96,6 +96,12 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -96,6 +_,12 @@ List.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR), PiglinAi::getActivities ); @@ -21,7 +13,7 @@ index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6 public Piglin(final EntityType type, final Level level) { super(type, level); -@@ -108,6 +114,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -108,6 +_,10 @@ output.putBoolean("IsBaby", this.isBaby()); output.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(output); @@ -32,7 +24,7 @@ index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6 } @Override -@@ -116,6 +126,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -116,6 +_,10 @@ this.setBaby(input.getBooleanOr("IsBaby", false)); this.setCannotHunt(input.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(input); @@ -43,7 +35,7 @@ index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6 } @VisibleForDebug -@@ -282,7 +296,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -282,7 +_,9 @@ @Override protected void finishConversion(final ServerLevel level) { PiglinAi.cancelAdmiring(level, this); @@ -53,7 +45,7 @@ index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6 super.finishConversion(level); } -@@ -359,7 +375,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -359,7 +_,7 @@ } protected void holdInOffHand(final ItemStack itemStack) { @@ -62,18 +54,17 @@ index 3802515c0c1c8caf3684ff75337ee0bb722ad853..e77384f3c7dd2cfe522ce2d91f71e4d6 this.setItemSlot(EquipmentSlot.OFFHAND, itemStack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -384,8 +400,8 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento - return false; - } else { - TagKey preferredWeaponType = this.getPreferredWeaponType(); -- boolean newItemWanted = PiglinAi.isLovedItem(newItemStack) || preferredWeaponType != null && newItemStack.is(preferredWeaponType); -- boolean currentItemWanted = PiglinAi.isLovedItem(currentItemStack) || preferredWeaponType != null && currentItemStack.is(preferredWeaponType); -+ boolean newItemWanted = PiglinAi.isLovedItem(newItemStack, this) || preferredWeaponType != null && newItemStack.is(preferredWeaponType); // CraftBukkit -+ boolean currentItemWanted = PiglinAi.isLovedItem(currentItemStack, this) || preferredWeaponType != null && currentItemStack.is(preferredWeaponType); // CraftBukkit - return newItemWanted && !currentItemWanted - || (newItemWanted || !currentItemWanted) && super.canReplaceCurrentItem(newItemStack, currentItemStack, slot); +@@ -385,15 +_,15 @@ } -@@ -393,7 +409,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento + + TagKey preferredWeaponType = this.getPreferredWeaponType(); +- boolean newItemWanted = PiglinAi.isLovedItem(newItemStack) || preferredWeaponType != null && newItemStack.is(preferredWeaponType); +- boolean currentItemWanted = PiglinAi.isLovedItem(currentItemStack) || preferredWeaponType != null && currentItemStack.is(preferredWeaponType); ++ boolean newItemWanted = PiglinAi.isLovedItem(newItemStack, this) || preferredWeaponType != null && newItemStack.is(preferredWeaponType); // CraftBukkit ++ boolean currentItemWanted = PiglinAi.isLovedItem(currentItemStack, this) || preferredWeaponType != null && currentItemStack.is(preferredWeaponType); // CraftBukkit + return newItemWanted && !currentItemWanted + || (newItemWanted || !currentItemWanted) && super.canReplaceCurrentItem(newItemStack, currentItemStack, slot); + } @Override protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { diff --git a/paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch similarity index 76% rename from paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 539139be1e0b..f13116920ae6 100644 --- a/paper-server/patches/rejected/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5b5318309 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -150,7 +150,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -149,7 +_,7 @@ private static final int DEFAULT_SCORE = 0; public static final float CREATIVE_ENTITY_INTERACTION_RANGE_MODIFIER_VALUE = 2.0F; private final Inventory inventory; @@ -17,7 +9,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -172,6 +172,18 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -171,6 +_,18 @@ private Optional lastDeathLocation = Optional.empty(); public @Nullable FishingHook fishing; public float hurtDir; @@ -36,7 +28,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 public Player(final Level level, final GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -238,6 +250,13 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -241,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -50,7 +42,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -267,7 +286,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -270,7 +_,7 @@ ItemStack mainHandItemStack = this.getMainHandItem(); if (!ItemStack.matches(this.lastItemInMainHand, mainHandItemStack)) { if (!ItemStack.isSameItem(this.lastItemInMainHand, mainHandItemStack)) { @@ -59,7 +51,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } this.lastItemInMainHand = mainHandItemStack.copy(); -@@ -318,7 +337,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -321,7 +_,7 @@ } private void turtleHelmetTick() { @@ -68,7 +60,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } private boolean isEquipped(final Item item) { -@@ -419,6 +438,18 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -422,6 +_,18 @@ } } @@ -87,7 +79,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -430,8 +461,14 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -433,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -104,36 +96,36 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 super.rideTick(); } } -@@ -684,10 +721,10 @@ public abstract class Player extends Avatar implements ContainerUser { - if (this.isDeadOrDying()) { - return false; - } else { -- this.removeEntitiesOnShoulder(); -+ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down - if (source.scalesWithDifficulty()) { - if (level.getDifficulty() == Difficulty.PEACEFUL) { -- damage = 0.0F; -+ return false; // CraftBukkit - damage = 0.0F -> return false - } +@@ -691,10 +_,10 @@ + return false; + } - if (level.getDifficulty() == Difficulty.EASY) { -@@ -699,7 +736,14 @@ public abstract class Player extends Avatar implements ContainerUser { - } - } +- this.removeEntitiesOnShoulder(); ++ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down + if (source.scalesWithDifficulty()) { + if (level.getDifficulty() == Difficulty.PEACEFUL) { +- damage = 0.0F; ++ return false; // CraftBukkit - damage = 0.0F -> return false + } -- return damage != 0.0F && super.hurtServer(level, source, damage); -+ // return damage != 0.0F && super.hurtServer(level, source, damage); -+ // CraftBukkit start - Don't filter out 0 damage -+ boolean damaged = super.hurtServer(level, source, damage); -+ if (damaged) { -+ this.removeEntitiesOnShoulder(); -+ } -+ return damaged; -+ // CraftBukkit end + if (level.getDifficulty() == Difficulty.EASY) { +@@ -706,7 +_,14 @@ } } + +- return damage != 0.0F && super.hurtServer(level, source, damage); ++ // return damage != 0.0F && super.hurtServer(level, source, damage); ++ // CraftBukkit start - Don't filter out 0 damage ++ boolean damaged = super.hurtServer(level, source, damage); ++ if (damaged) { ++ this.removeEntitiesOnShoulder(); ++ } ++ return damaged; ++ // CraftBukkit end } -@@ -711,7 +755,7 @@ public abstract class Player extends Avatar implements ContainerUser { + + @Override +@@ -716,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = attacker.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -142,7 +134,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } } -@@ -721,9 +765,29 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -726,9 +_,29 @@ } public boolean canHarmPlayer(final Player target) { @@ -175,7 +167,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } @Override -@@ -737,7 +801,12 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -742,7 +_,12 @@ } @Override @@ -189,16 +181,16 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 if (!this.isInvulnerableTo(level, source)) { dmg = this.getDamageAfterArmorAbsorb(source, dmg); dmg = this.getDamageAfterMagicAbsorb(source, dmg); -@@ -749,7 +818,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -755,7 +_,7 @@ } - if (var8 != 0.0F) { + if (dmg != 0.0F) { - this.causeFoodExhaustion(source.getFoodExhaustion()); + this.causeFoodExhaustion(source.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent - this.getCombatTracker().recordDamage(source, var8); - this.setHealth(this.getHealth() - var8); - if (var8 < 3.4028235E37F) { -@@ -759,6 +828,7 @@ public abstract class Player extends Avatar implements ContainerUser { + this.getCombatTracker().recordDamage(source, dmg); + this.setHealth(this.getHealth() - dmg); + if (dmg < 3.4028235E37F) { +@@ -765,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -206,7 +198,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } public boolean isTextFilteringEnabled() { -@@ -852,14 +922,16 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -858,14 +_,16 @@ } @Override @@ -226,7 +218,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } @Override -@@ -938,15 +1010,25 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -946,15 +_,25 @@ } public void attack(final Entity entity) { @@ -256,7 +248,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 if (baseDamage > 0.0F || magicBoost > 0.0F) { boolean fullStrengthAttack = attackStrengthScale > 0.9F; boolean knockbackAttack; -@@ -959,7 +1041,9 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -967,7 +_,9 @@ baseDamage += attackingItemStack.getItem().getAttackDamageBonus(entity, baseDamage, damageSource); boolean criticalAttack = fullStrengthAttack && this.canCriticalAttack(entity); @@ -266,7 +258,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 baseDamage *= 1.5F; } -@@ -982,7 +1066,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -990,7 +_,7 @@ this.setLastHurtMob(entity); this.itemAttackInteraction(entity, attackingItemStack, damageSource, true); this.damageStatsAndHearts(entity, oldLivingEntityHealth); @@ -275,7 +267,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } else { this.playServerSideSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); } -@@ -994,7 +1078,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1002,7 +_,7 @@ } private void playServerSideSound(final SoundEvent sound) { @@ -284,7 +276,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } private DamageSource createAttackSource(final ItemStack attackingItemStack) { -@@ -1005,11 +1089,12 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1013,11 +_,12 @@ return !entity.isAttackable() || entity.skipAttackInteraction(this); } @@ -299,7 +291,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 return true; } else { return false; -@@ -1109,19 +1194,40 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1117,19 +_,40 @@ public void causeExtraKnockback(final Entity entity, final float knockbackAmount, final Vec3 oldMovement) { if (knockbackAmount > 0.0F) { if (entity instanceof LivingEntity livingTarget) { @@ -342,7 +334,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } } -@@ -1142,8 +1248,11 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1150,8 +_,11 @@ && !(nearby instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(nearby) < 9.0) { float enchantedDamage = this.getEnchantedDamage(nearby, var12, damageSource) * attackStrengthScale; @@ -356,7 +348,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 EnchantmentHelper.doPostAttackEffects(serverLevel, nearby, damageSource); } } -@@ -1176,7 +1285,16 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1184,7 +_,16 @@ public boolean stabAttack( final EquipmentSlot slot, final Entity target, float baseDamage, final boolean dealsDamage, final boolean dealsKnockback, final boolean dismounts ) { @@ -372,28 +364,28 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 + if (!playerAttackEntityEvent.callEvent() || cannotAttack) { // Logic moved to cannotAttack local variable. + // Paper end - PlayerAttackEntityEvent return false; - } else { - ItemStack weaponItem = this.getItemBySlot(slot); -@@ -1187,7 +1305,8 @@ public abstract class Player extends Avatar implements ContainerUser { - baseDamage *= this.baseDamageScaleFactor(); - } + } -- if (dealsKnockback && this.deflectProjectile(target)) { -+ final float dmgFinal = magicBoost; // Paper - damage events -+ if (dealsKnockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, dmgFinal, false))) { // Paper - damage events - return true; - } else { - float totalDamage = dealsDamage ? baseDamage + magicBoost : 0.0F; -@@ -1215,7 +1334,7 @@ public abstract class Player extends Avatar implements ContainerUser { - this.setLastHurtMob(target); - this.itemAttackInteraction(target, weaponItem, damageSource, wasHurt); - this.damageStatsAndHearts(target, oldLivingEntityHealth); -- this.causeFoodExhaustion(0.1F); -+ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value - return true; - } - } -@@ -1226,8 +1345,8 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1196,7 +_,8 @@ + baseDamage *= this.baseDamageScaleFactor(); + } + +- if (dealsKnockback && this.deflectProjectile(target)) { ++ final float dmgFinal = magicBoost; // Paper - damage events ++ if (dealsKnockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, dmgFinal, false))) { // Paper - damage events + return true; + } + +@@ -1226,7 +_,7 @@ + this.setLastHurtMob(target); + this.itemAttackInteraction(target, weaponItem, damageSource, wasHurt); + this.damageStatsAndHearts(target, oldLivingEntityHealth); +- this.causeFoodExhaustion(0.1F); ++ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value + return true; + } + +@@ -1234,8 +_,8 @@ } @Override @@ -404,7 +396,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1295,6 +1414,12 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1303,6 +_,12 @@ } public Either startSleepInBed(final BlockPos pos) { @@ -417,16 +409,16 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 this.startSleeping(pos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1411,7 +1536,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1419,7 +_,7 @@ @Override public boolean causeFallDamage(final double fallDistance, final float damageModifier, final DamageSource damageSource) { - if (this.abilities.mayfly) { + if (this.abilities.mayfly && !this.flyingFallDamage.toBooleanOrElse(false)) { // Paper - flying fall damage return false; - } else { - if (fallDistance >= 2.0) { -@@ -1432,7 +1557,15 @@ public abstract class Player extends Avatar implements ContainerUser { + } + +@@ -1440,7 +_,15 @@ } public void startFallFlying() { @@ -442,7 +434,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } @Override -@@ -1530,7 +1663,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1538,7 +_,7 @@ if (amount > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float vol = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -451,7 +443,7 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 this.lastLevelUpTime = this.tickCount; } } -@@ -1538,15 +1671,35 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1546,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -489,13 +481,14 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 } } } -@@ -1807,10 +1960,39 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1807,10 +_,39 @@ } @Override - public void onAttack() { - this.resetOnlyAttackStrengthTicker(); - super.onAttack(); +- } + // Paper start + public void onAttack(@Nullable Entity entity) { + if (entity != null) { @@ -527,12 +520,12 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 + + this.lastItemInMainHand = mainHandItem.copy(); + } - } ++ } + // Paper end - Force update attributes. public void resetOnlyAttackStrengthTicker() { this.attackStrengthTicker = 0; -@@ -1843,17 +2025,32 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1843,19 +_,34 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -554,28 +547,30 @@ index 683a2d70b24cb76ebfe903eef957ade129af50c5..391f3048f34edfa3d5759abfd56e17d5 public ItemStack getProjectile(final ItemStack heldWeapon) { if (!(heldWeapon.getItem() instanceof ProjectileWeaponItem)) { return ItemStack.EMPTY; - } else { -- Predicate supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getSupportedHeldProjectiles(); -+ final org.apache.commons.lang3.mutable.MutableBoolean anyEventCancelled = new org.apache.commons.lang3.mutable.MutableBoolean(); // Paper - PlayerReadyArrowEvent -+ Predicate supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getSupportedHeldProjectiles().and(item -> this.tryReadyArrow(heldWeapon, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent - ItemStack heldProjectile = ProjectileWeaponItem.getHeldProjectile(this, supportedProjectiles); - if (!heldProjectile.isEmpty()) { - return heldProjectile; - } else { -- supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getAllSupportedProjectiles(); -+ supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getAllSupportedProjectiles().and(item -> this.tryReadyArrow(heldWeapon, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent + } - for (int i = 0; i < this.inventory.getContainerSize(); i++) { - ItemStack itemStack = this.inventory.getItem(i); -@@ -1862,6 +2059,7 @@ public abstract class Player extends Avatar implements ContainerUser { - } - } +- Predicate supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getSupportedHeldProjectiles(); ++ final org.apache.commons.lang3.mutable.MutableBoolean anyEventCancelled = new org.apache.commons.lang3.mutable.MutableBoolean(); // Paper - PlayerReadyArrowEvent ++ Predicate supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getSupportedHeldProjectiles().and(item -> this.tryReadyArrow(heldWeapon, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent + ItemStack heldProjectile = ProjectileWeaponItem.getHeldProjectile(this, supportedProjectiles); + if (!heldProjectile.isEmpty()) { + return heldProjectile; + } + +- supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getAllSupportedProjectiles(); ++ supportedProjectiles = ((ProjectileWeaponItem)heldWeapon.getItem()).getAllSupportedProjectiles().and(item -> this.tryReadyArrow(heldWeapon, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent -+ if (anyEventCancelled.booleanValue() && !this.abilities.instabuild && this instanceof final ServerPlayer player) this.resyncUsingItem(player); // Paper - resync if no item matched the Predicate - return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; + for (int i = 0; i < this.inventory.getContainerSize(); i++) { + ItemStack itemStack = this.inventory.getItem(i); +@@ -1864,6 +_,7 @@ } } -@@ -2025,5 +2223,6 @@ public abstract class Player extends Avatar implements ContainerUser { + ++ if (anyEventCancelled.booleanValue() && !this.abilities.instabuild && this instanceof final ServerPlayer player) this.resyncUsingItem(player); // Paper - resync if no item matched the Predicate + return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; + } + +@@ -2027,5 +_,6 @@ public static final Player.BedSleepingProblem OBSTRUCTED = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.obstructed")); public static final Player.BedSleepingProblem OTHER_PROBLEM = new Player.BedSleepingProblem(null); public static final Player.BedSleepingProblem NOT_SAFE = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.not_safe")); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index e288a8f9255c..382ded7cb2e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -107,7 +107,7 @@ this.broadcastChanges(); }); } else { -@@ -148,19 +_,55 @@ +@@ -148,19 +_,52 @@ } this.access.execute((level, pos) -> { @@ -119,6 +119,7 @@ + // CraftBukkit start + IdMap> registry = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + if (true || !newEnchantment.isEmpty()) { ++ // player.onEnchantmentPerformed(enchantmentItem, enchantmentCost); // Moved down + java.util.Map enchants = new java.util.HashMap<>(); + for (EnchantmentInstance instance : newEnchantment) { + enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment()), instance.level()); @@ -145,6 +146,9 @@ + enchantmentItem = enchantmentItem.transmuteCopy(Items.ENCHANTED_BOOK); this.enchantSlots.setItem(0, enchantmentItem); } +- +- for (EnchantmentInstance enchantment : newEnchantment) { +- enchantmentItem.enchant(enchantment.enchantment(), enchantment.level()); + // Paper end + + // CraftBukkit start @@ -155,14 +159,10 @@ + } + + enchantmentItem.enchant(enchantment, entry.getValue()); -+ } + } + // CraftBukkit end + player.onEnchantmentPerformed(enchantmentItem, enchantmentCost); - for (EnchantmentInstance enchantment : newEnchantment) { - enchantmentItem.enchant(enchantment.enchantment(), enchantment.level()); - } - + // CraftBukkit - TODO: let plugins change this currency.consume(enchantmentCost, player); if (currency.isEmpty()) { diff --git a/paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch similarity index 69% rename from paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 9f93d79ef458..e08b63a5bed7 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/alchemy/PotionBrewing.java b/net/minecraft/world/item/alchemy/PotionBrewing.java -index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f5485c9843e6 100644 --- a/net/minecraft/world/item/alchemy/PotionBrewing.java +++ b/net/minecraft/world/item/alchemy/PotionBrewing.java -@@ -19,6 +19,7 @@ public class PotionBrewing { +@@ -19,6 +_,7 @@ private final List containers; private final List> potionMixes; private final List> containerMixes; @@ -16,7 +8,7 @@ index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f548 private PotionBrewing( final List containers, final List> potionMixes, final List> containerMixes -@@ -29,7 +30,7 @@ public class PotionBrewing { +@@ -29,7 +_,7 @@ } public boolean isIngredient(final ItemStack ingredient) { @@ -25,7 +17,7 @@ index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f548 } private boolean isContainer(final ItemStack input) { -@@ -73,6 +74,11 @@ public class PotionBrewing { +@@ -73,6 +_,11 @@ } public boolean hasMix(final ItemStack source, final ItemStack ingredient) { @@ -37,24 +29,25 @@ index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f548 return this.isContainer(source) && (this.hasContainerMix(source, ingredient) || this.hasPotionMix(source, ingredient)); } -@@ -109,6 +115,13 @@ public class PotionBrewing { - if (potion.isEmpty()) { - return source; - } else { -+ // Paper start - Custom Potion Mixes -+ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { -+ if (mix.input().test(source) && mix.ingredient().test(ingredient)) { -+ return mix.result().copy(); -+ } -+ } -+ // Paper end - Custom Potion Mixes - for (PotionBrewing.Mix mix : this.containerMixes) { - if (source.is(mix.from) && mix.ingredient.test(ingredient)) { - return PotionContents.createItemStack(mix.to.value(), potion.get()); -@@ -192,6 +205,50 @@ public class PotionBrewing { +@@ -111,6 +_,13 @@ + return source; + } + ++ // Paper start - Custom Potion Mixes ++ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { ++ if (mix.input().test(source) && mix.ingredient().test(ingredient)) { ++ return mix.result().copy(); ++ } ++ } ++ // Paper end - Custom Potion Mixes + for (PotionBrewing.Mix mix : this.containerMixes) { + if (source.is(mix.from) && mix.ingredient.test(ingredient)) { + return PotionContents.createItemStack(mix.to.value(), potion.get()); +@@ -191,6 +_,50 @@ + builder.addMix(Potions.AWKWARD, Items.PHANTOM_MEMBRANE, Potions.SLOW_FALLING); builder.addMix(Potions.SLOW_FALLING, Items.REDSTONE, Potions.LONG_SLOW_FALLING); } - ++ + // Paper start - Custom Potion Mixes + public boolean isCustomIngredient(ItemStack stack) { + for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { @@ -98,7 +91,6 @@ index e1e68bd79323ff150a66818aa9ed64fc314fa1d2..dac9d0e80736df8f89cd3428d1c0f548 + return bootstrap(flags); + } + // Paper end - Custom Potion Mixes -+ + public static class Builder { private final List containers = new ArrayList<>(); - private final List> potionMixes = new ArrayList<>(); diff --git a/paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch similarity index 71% rename from paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index ea4fd9a6e02a..1651b9de70b9 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -index e8e56b454adafb5650cbdba7e23a98592d794e34..f9fa7d0eaf9f32959a4bd12b82e5a49ea808a44c 100644 --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -47,11 +47,20 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { +@@ -47,11 +_,20 @@ private final Ingredient base; private final Ingredient addition; private final Holder pattern; @@ -29,7 +21,7 @@ index e8e56b454adafb5650cbdba7e23a98592d794e34..f9fa7d0eaf9f32959a4bd12b82e5a49e this.template = template; this.base = base; this.addition = addition; -@@ -60,10 +69,15 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { +@@ -60,10 +_,15 @@ @Override public ItemStack assemble(final SmithingRecipeInput input) { @@ -46,16 +38,16 @@ index e8e56b454adafb5650cbdba7e23a98592d794e34..f9fa7d0eaf9f32959a4bd12b82e5a49e Holder material = materialItem.get(DataComponents.PROVIDES_TRIM_MATERIAL); if (material != null) { ArmorTrim existingTrim = baseItem.get(DataComponents.TRIM); -@@ -71,7 +85,7 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { - if (Objects.equals(existingTrim, newTrim)) { +@@ -72,7 +_,7 @@ return ItemStack.EMPTY; - } else { -- ItemStack trimmedItem = baseItem.copyWithCount(1); -+ ItemStack trimmedItem = copyDataComponents ? baseItem.copyWithCount(1) : new ItemStack(baseItem.getItem(), 1); // Paper - Option to prevent data components copy - trimmedItem.set(DataComponents.TRIM, newTrim); - return trimmedItem; } -@@ -120,4 +134,10 @@ public class SmithingTrimRecipe extends SimpleSmithingRecipe { + +- ItemStack trimmedItem = baseItem.copyWithCount(1); ++ ItemStack trimmedItem = copyDataComponents ? baseItem.copyWithCount(1) : new ItemStack(baseItem.getItem(), 1); // Paper - Option to prevent data components copy + trimmedItem.set(DataComponents.TRIM, newTrim); + return trimmedItem; + } else { +@@ -120,4 +_,10 @@ ) ); } diff --git a/paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch b/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch similarity index 71% rename from paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch index 65531b433f2a..502f80ea046b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/item/trading/MerchantOffer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/item/trading/MerchantOffer.java b/net/minecraft/world/item/trading/MerchantOffer.java -index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea8180019e 100644 --- a/net/minecraft/world/item/trading/MerchantOffer.java +++ b/net/minecraft/world/item/trading/MerchantOffer.java -@@ -21,6 +21,7 @@ public class MerchantOffer { +@@ -21,6 +_,7 @@ Codec.INT.lenientOptionalFieldOf("demand", 0).forGetter(o -> o.demand), Codec.FLOAT.lenientOptionalFieldOf("priceMultiplier", 0.0F).forGetter(o -> o.priceMultiplier), Codec.INT.lenientOptionalFieldOf("xp", 1).forGetter(o -> o.xp) @@ -16,7 +8,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea ) .apply(i, MerchantOffer::new) ); -@@ -37,6 +38,21 @@ public class MerchantOffer { +@@ -37,6 +_,21 @@ public int demand; public float priceMultiplier; public int xp; @@ -38,7 +30,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea private MerchantOffer( final ItemCost baseCostA, -@@ -49,6 +65,7 @@ public class MerchantOffer { +@@ -49,6 +_,7 @@ final int demand, final float priceMultiplier, final int xp @@ -46,7 +38,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea ) { this.baseCostA = baseCostA; this.costB = costB; -@@ -60,6 +77,7 @@ public class MerchantOffer { +@@ -60,6 +_,7 @@ this.demand = demand; this.priceMultiplier = priceMultiplier; this.xp = xp; @@ -54,7 +46,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea } public MerchantOffer(final ItemCost buy, final ItemStack result, final int maxUses, final int xp, final float priceMultiplier) { -@@ -94,7 +112,7 @@ public class MerchantOffer { +@@ -94,7 +_,7 @@ final float priceMultiplier, final int demand ) { @@ -63,7 +55,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea } private MerchantOffer(final MerchantOffer offer) { -@@ -109,6 +127,7 @@ public class MerchantOffer { +@@ -109,6 +_,7 @@ offer.demand, offer.priceMultiplier, offer.xp @@ -71,7 +63,7 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea ); } -@@ -144,6 +163,7 @@ public class MerchantOffer { +@@ -144,6 +_,7 @@ public void updateDemand() { this.demand = this.demand + this.uses - (this.maxUses - this.uses); @@ -79,16 +71,15 @@ index 36b397c56faa2aeaf2c7b580b3071eed724634de..006e8400349131faadc946fe3f5bd9ea } public ItemStack assemble() { -@@ -222,7 +242,11 @@ public class MerchantOffer { - if (!this.satisfiedBy(buyA, buyB)) { +@@ -223,7 +_,11 @@ return false; - } else { -- buyA.shrink(this.getCostA().getCount()); -+ // CraftBukkit start -+ if (!this.getCostA().isEmpty()) { -+ buyA.shrink(this.getCostA().getCount()); -+ } -+ // CraftBukkit end - if (!this.getCostB().isEmpty()) { - buyB.shrink(this.getCostB().getCount()); - } + } + ++ // CraftBukkit start ++ if (!this.getCostA().isEmpty()) { + buyA.shrink(this.getCostA().getCount()); ++ } ++ // CraftBukkit end + if (!this.getCostB().isEmpty()) { + buyB.shrink(this.getCostB().getCount()); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index 75847669c5c0..4082bf1cc21c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -173,7 +173,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(type)); } catch (Exception e) { LOGGER.warn("Failed to create mob", e); -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var4); // Paper - ServerExceptionEvent ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(e); // Paper - ServerExceptionEvent } return null; @@ -181,7 +181,7 @@ entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception e) { LOGGER.warn("Failed to create mob", e); -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var27); // Paper - ServerExceptionEvent ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(e); // Paper - ServerExceptionEvent continue; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index 06c6f167d4d7..2a4f512c9356 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -35,7 +_,56 @@ +@@ -35,7 +_,52 @@ public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -8,10 +8,6 @@ + // CraftBukkit start - add fields and methods + public final Container bookAccess = new LecternInventory(); + public class LecternInventory implements Container { -+ { -+ Objects.requireNonNull(LecternBlockEntity.this); -+ } -+ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = 1; + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 54c714051140..8265f984dff7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -88,17 +88,17 @@ + if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), commandLine); + } -+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent( ++ final io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent bukkitEvent = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent( + (org.bukkit.entity.Player) player.getBukkitEntity(), + commandLine, + new org.bukkit.craftbukkit.util.LazyPlayerSet(level.getServer()), + (org.bukkit.block.Sign) org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition).getState(), + isFrontText ? org.bukkit.block.sign.Side.FRONT : org.bukkit.block.sign.Side.BACK + ); -+ if (!event.callEvent()) { ++ if (!bukkitEvent.callEvent()) { + return false; + } -+ level.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), level, pos), event.getMessage()); ++ level.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) bukkitEvent.getPlayer()).getHandle(), level, pos), bukkitEvent.getMessage()); + // Paper end - Fix commands from signs not firing command events hasAnyClickCommand = true; break; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index 894bf76d305c..62cede9f9b1a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -254,27 +254,24 @@ BlockState state = blockEntity.getBlockState(); BlockEntityTicker ticker = state.getTicker(this.level, (BlockEntityType)blockEntity.getType()); if (ticker == null) { -@@ -749,23 +_,24 @@ +@@ -749,7 +_,11 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; - } else if (!this.loggedInvalidBlockState) { -- this.loggedInvalidBlockState = true; -- LevelChunk.LOGGER -- .warn( -- "Block entity {} @ {} state {} invalid for ticking:", -- LogUtils.defer(this::getType), -- LogUtils.defer(this::getPos), -- blockState -- ); + // Paper start - Remove the Block Entity if it's invalid + } else { + LevelChunk.this.removeBlockEntity(this.getPos()); + if (!this.loggedInvalidBlockState) { -+ this.loggedInvalidBlockState = true; -+ LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer(this::getType), LogUtils.defer(this::getPos), blockState); -+ } -+ // Paper end - Remove the Block Entity if it's invalid ++ // Paper end - Remove the Block Entity if it's invalid + this.loggedInvalidBlockState = true; + LevelChunk.LOGGER + .warn( +@@ -758,14 +_,17 @@ + LogUtils.defer(this::getPos), + blockState + ); ++ } // Paper - Remove the Block Entity if it's invalid } profiler.pop(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch index da7a238ee55b..159743d931ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch @@ -33,7 +33,7 @@ return true; } catch (IOException e) { -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(E); // Paper - ServerExceptionEvent ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(e); // Paper - ServerExceptionEvent return false; } } diff --git a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch similarity index 62% rename from paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch index 9459e299d55b..52b470ddc5e9 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index a3a99a0995b6c93041110164fde70d6e1547955a..469fb7695b46420b5817928b8f905c4df3aa9bfe 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -43,7 +43,7 @@ public class StructureCheck { +@@ -43,7 +_,7 @@ private final ChunkScanAccess storageAccess; private final RegistryAccess registryAccess; private final StructureTemplateManager structureTemplateManager; @@ -17,7 +9,7 @@ index a3a99a0995b6c93041110164fde70d6e1547955a..469fb7695b46420b5817928b8f905c4d private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; -@@ -57,7 +57,7 @@ public class StructureCheck { +@@ -57,7 +_,7 @@ final ChunkScanAccess storageAccess, final RegistryAccess registryAccess, final StructureTemplateManager structureTemplateManager, @@ -26,7 +18,7 @@ index a3a99a0995b6c93041110164fde70d6e1547955a..469fb7695b46420b5817928b8f905c4d final ChunkGenerator chunkGenerator, final RandomState randomState, final LevelHeightAccessor heightAccessor, -@@ -77,6 +77,20 @@ public class StructureCheck { +@@ -77,6 +_,20 @@ this.fixerUpper = fixerUpper; } @@ -47,12 +39,12 @@ index a3a99a0995b6c93041110164fde70d6e1547955a..469fb7695b46420b5817928b8f905c4d public StructureCheckResult checkStart(final ChunkPos pos, final Structure structure, final StructurePlacement placement, final boolean requireUnreferenced) { long posKey = pos.pack(); Object2IntMap cachedResult = this.loadedChunks.get(posKey); -@@ -86,7 +100,7 @@ public class StructureCheck { - StructureCheckResult storageCheckResult = this.tryLoadFromStorage(pos, structure, requireUnreferenced, posKey); - if (storageCheckResult != null) { - return storageCheckResult; -- } else if (!placement.applyAdditionalChunkRestrictions(pos.x(), pos.z(), this.seed)) { -+ } else if (!placement.applyAdditionalChunkRestrictions(pos.x(), pos.z(), this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs - return StructureCheckResult.START_NOT_PRESENT; - } else { - boolean isFeatureChunk = this.featureChecks +@@ -89,7 +_,7 @@ + return storageCheckResult; + } + +- if (!placement.applyAdditionalChunkRestrictions(pos.x(), pos.z(), this.seed)) { ++ if (!placement.applyAdditionalChunkRestrictions(pos.x(), pos.z(), this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs + return StructureCheckResult.START_NOT_PRESENT; + } + diff --git a/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch similarity index 89% rename from paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch index febf1b50a595..ee4f7d6f285e 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalForcer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/portal/PortalForcer.java b/net/minecraft/world/level/portal/PortalForcer.java -index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469f7a500a3 100644 --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java -@@ -39,18 +39,32 @@ public class PortalForcer { +@@ -39,18 +_,32 @@ this.level = level; } @@ -42,7 +34,7 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, portalAxis); double closestFullDistanceSqr = -1.0; BlockPos closestFullPosition = null; -@@ -58,10 +72,15 @@ public class PortalForcer { +@@ -58,10 +_,15 @@ BlockPos closestPartialPosition = null; WorldBorder worldBorder = this.level.getWorldBorder(); int maxPlaceableY = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); @@ -59,7 +51,7 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 int height = Math.min(maxPlaceableY, this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, columnPos.getX(), columnPos.getZ())); if (worldBorder.isWithinBounds(columnPos) && worldBorder.isWithinBounds(columnPos.move(direction, 1))) { columnPos.move(direction.getOpposite(), 1); -@@ -105,6 +124,7 @@ public class PortalForcer { +@@ -105,6 +_,7 @@ closestFullDistanceSqr = closestPartialDistanceSqr; } @@ -67,7 +59,7 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 if (closestFullDistanceSqr == -1.0) { int minStartY = Math.max(this.level.getMinY() - -1, 70); int maxStartY = maxPlaceableY - 9; -@@ -129,7 +149,7 @@ public class PortalForcer { +@@ -129,7 +_,7 @@ height, width * direction.getStepZ() + box * clockWise.getStepZ() ); @@ -76,7 +68,7 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 } } } -@@ -139,7 +159,7 @@ public class PortalForcer { +@@ -139,7 +_,7 @@ for (int height = -1; height < 4; height++) { if (width == -1 || width == 2 || height == -1 || height == 3) { mutable.setWithOffset(closestFullPosition, width * direction.getStepX(), height, width * direction.getStepZ()); @@ -85,10 +77,10 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 } } } -@@ -149,10 +169,20 @@ public class PortalForcer { +@@ -149,10 +_,20 @@ for (int width = 0; width < 2; width++) { - for (int heightx = 0; heightx < 3; heightx++) { - mutable.setWithOffset(closestFullPosition, width * direction.getStepX(), heightx, width * direction.getStepZ()); + for (int height = 0; height < 3; height++) { + mutable.setWithOffset(closestFullPosition, width * direction.getStepX(), height, width * direction.getStepZ()); - this.level.setBlock(mutable, portalBlockState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE); + blockList.setBlock(mutable, portalBlockState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE); // CraftBukkit } @@ -107,7 +99,7 @@ index 175a34daea97b7d261f91c6fd187c126007af7f1..08ac4ce3f34f2dc955ef2bfb2401f469 return Optional.of(new BlockUtil.FoundRectangle(closestFullPosition.immutable(), 2, 3)); } -@@ -169,6 +199,13 @@ public class PortalForcer { +@@ -169,6 +_,13 @@ mutable.setWithOffset( origin, direction.getStepX() * width + clockWise.getStepX() * offset, height, direction.getStepZ() * width + clockWise.getStepZ() * offset ); diff --git a/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch similarity index 83% rename from paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch index 508418c11b6e..d1d321acf75b 100644 --- a/paper-server/patches/rejected/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,14 +1,6 @@ -From 96e4ace8a69c515c1d75f731dcd6f01e57d19245 Mon Sep 17 00:00:00 2001 -From: File -Date: Sun, 20 Apr 1997 14:37:42 +0100 -Subject: [PATCH] paper File Patches - - -diff --git a/net/minecraft/world/level/portal/PortalShape.java b/net/minecraft/world/level/portal/PortalShape.java -index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014ddf4b549 100644 --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -38,10 +38,14 @@ public class PortalShape { +@@ -38,10 +_,14 @@ private final BlockPos bottomLeft; private final int height; private final int width; @@ -24,7 +16,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 this.axis = axis; this.numPortalBlocks = portalBlockCount; this.rightDir = rightDir; -@@ -67,23 +71,24 @@ public class PortalShape { +@@ -67,23 +_,24 @@ } public static PortalShape findAnyShape(final BlockGetter level, final BlockPos pos, final Direction.Axis axis) { @@ -35,20 +27,20 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 if (bottomLeft == null) { - return new PortalShape(axis, 0, rightDir, pos, 0, 0); + return new PortalShape(axis, 0, rightDir, pos, 0, 0, blocks); // CraftBukkit - } else { -- int width = calculateWidth(level, bottomLeft, rightDir); -+ int width = calculateWidth(level, bottomLeft, rightDir, blocks); // CraftBukkit - if (width == 0) { -- return new PortalShape(axis, 0, rightDir, bottomLeft, 0, 0); -+ return new PortalShape(axis, 0, rightDir, bottomLeft, 0, 0, blocks); // CraftBukkit - } else { - MutableInt portalBlockCountOutput = new MutableInt(); -- int height = calculateHeight(level, bottomLeft, rightDir, width, portalBlockCountOutput); -- return new PortalShape(axis, portalBlockCountOutput.intValue(), rightDir, bottomLeft, width, height); -+ int height = calculateHeight(level, bottomLeft, rightDir, width, portalBlockCountOutput, blocks); // CraftBukkit -+ return new PortalShape(axis, portalBlockCountOutput.intValue(), rightDir, bottomLeft, width, height, blocks); // CraftBukkit - } } + +- int width = calculateWidth(level, bottomLeft, rightDir); ++ int width = calculateWidth(level, bottomLeft, rightDir, blocks); // CraftBukkit + if (width == 0) { +- return new PortalShape(axis, 0, rightDir, bottomLeft, 0, 0); ++ return new PortalShape(axis, 0, rightDir, bottomLeft, 0, 0, blocks); // CraftBukkit + } + + MutableInt portalBlockCountOutput = new MutableInt(); +- int height = calculateHeight(level, bottomLeft, rightDir, width, portalBlockCountOutput); +- return new PortalShape(axis, portalBlockCountOutput.intValue(), rightDir, bottomLeft, width, height); ++ int height = calculateHeight(level, bottomLeft, rightDir, width, portalBlockCountOutput, blocks); // CraftBukkit ++ return new PortalShape(axis, portalBlockCountOutput.intValue(), rightDir, bottomLeft, width, height, blocks); // CraftBukkit } - private static @Nullable BlockPos calculateBottomLeft(final BlockGetter level, final Direction rightDir, BlockPos pos) { @@ -56,7 +48,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 int minY = Math.max(level.getMinY(), pos.getY() - 21); while (pos.getY() > minY && isEmpty(level.getBlockState(pos.below()))) { -@@ -91,16 +96,16 @@ public class PortalShape { +@@ -91,16 +_,16 @@ } Direction leftDir = rightDir.getOpposite(); @@ -77,7 +69,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); for (int width = 0; width <= 21; width++) { -@@ -108,6 +113,7 @@ public class PortalShape { +@@ -108,6 +_,7 @@ BlockState blockState = level.getBlockState(blockPos); if (!isEmpty(blockState)) { if (FRAME.test(blockState, level, blockPos)) { @@ -85,7 +77,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 return width; } break; -@@ -117,27 +123,29 @@ public class PortalShape { +@@ -117,27 +_,29 @@ if (!FRAME.test(belowState, level, blockPos)) { break; } @@ -119,7 +111,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 } return true; -@@ -149,7 +157,7 @@ public class PortalShape { +@@ -149,7 +_,7 @@ final Direction rightDir, final BlockPos.MutableBlockPos pos, final int width, @@ -128,7 +120,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 ) { for (int height = 0; height < 21; height++) { pos.set(bottomLeft).move(Direction.UP, height).move(rightDir, -1); -@@ -173,6 +181,10 @@ public class PortalShape { +@@ -173,6 +_,10 @@ portalBlockCount.increment(); } } @@ -139,7 +131,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 } return 21; -@@ -186,10 +198,23 @@ public class PortalShape { +@@ -186,10 +_,23 @@ return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -149,7 +141,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 + org.bukkit.World bworld = level.getMinecraftWorld().getWorld(); + // Copy below for loop BlockState portalState = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); -+ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + .forEach(pos -> this.blocks.setBlock(pos, portalState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE)); + org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getSnapshotBlocks(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); + level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); // todo the list is not really mutable here unlike other call and the portal frame is included @@ -158,7 +150,7 @@ index e7634a5695b82a222183d2d1c1dcf26f91850839..36ce33a0eac27a34ae2fc036972f4014 + return false; + } + // CraftBukkit end - BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) ++ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) .forEach(pos -> level.setBlock(pos, portalState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE)); + return true; // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch new file mode 100644 index 000000000000..e93e70da8abf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java ++++ b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +@@ -84,8 +_,25 @@ + Vec3 lootPos = context.getOptionalParameter(LootContextParams.ORIGIN); + if (lootPos != null) { + ServerLevel level = context.getLevel(); ++ // Paper start - Configurable cartographer treasure maps ++ // Simple heuristic for determining if this function is running in the context of a villager selecting ++ // an item for its offers. Technically other callers could satisfiy this but this minimises the diff and ++ // works for all plain vanilla usecases. ++ final boolean runningForVillagerTrade = context.hasParameter(LootContextParams.ADDITIONAL_COST_COMPONENT_ALLOWED) ++ && context.getOptionalParameter(LootContextParams.THIS_ENTITY) instanceof net.minecraft.world.entity.npc.villager.AbstractVillager; ++ if (!level.paperConfig().environment.treasureMaps.enabled) { ++ /* ++ * NOTE: I fear users will just get a plain map as their "treasure" ++ * This is preferable to disrespecting the config. ++ */ ++ return runningForVillagerTrade ? net.minecraft.world.item.ItemStack.EMPTY : itemStack; ++ } ++ final boolean shouldSkipKnownStructures = runningForVillagerTrade ++ ? !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager ++ : !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(!this.skipKnownStructures); ++ // Paper end - Configurable cartographer treasure maps + BlockPos nearestMapStructure = level.findNearestMapStructure( +- this.destination, BlockPos.containing(lootPos), this.searchRadius, this.skipKnownStructures ++ this.destination, BlockPos.containing(lootPos), this.searchRadius, shouldSkipKnownStructures // Paper - Configurable cartographer treasure maps + ); + if (nearestMapStructure != null) { + ItemStack map = MapItem.create(level, nearestMapStructure.getX(), nearestMapStructure.getZ(), this.zoom, true, true); From 991fcc4bfa935906f685d671f09bff3ab49edbe8 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 13 May 2026 18:27:51 +0100 Subject: [PATCH 15/16] Feature patches --- .../0001-Moonrise-optimisation-patches.patch | 2071 ++++++++--------- .../0002-Rewrite-dataconverter-system.patch | 38 +- ...tion-and-add-advanced-packet-support.patch | 28 +- ...004-Allow-Saving-of-Oversized-Chunks.patch | 14 +- .../0005-Entity-Activation-Range-2.0.patch | 41 +- .../0006-Optimize-Voxel-Shape-Merging.patch | 8 +- ...007-optimize-dirt-and-snow-spreading.patch | 10 +- ...ocity-compression-and-cipher-natives.patch | 67 +- ...oalSelector-Goal.Flag-Set-operations.patch | 25 +- .../0012-Remove-streams-from-hot-code.patch | 8 +- ...der-Remove-Streams-Optimized-collect.patch | 58 +- ...er-desync-when-new-players-are-added.patch | 6 +- ...nate-Current-redstone-implementation.patch | 10 +- ...-data-to-disk-if-it-serializes-witho.patch | 12 +- ...018-Entity-load-save-limit-per-chunk.patch | 8 +- ...culate-regionfile-header-if-it-is-co.patch | 307 +-- ...-Incremental-chunk-and-player-saving.patch | 25 +- ...on-checking-in-player-move-packet-ha.patch | 6 +- .../0024-Improve-keepalive-ping-system.patch | 6 +- ...025-Optimise-EntityScheduler-ticking.patch | 10 +- ...0026-DataConverter-Moonrise-co-fixes.patch | 8 +- .../0027-Optional-per-player-mob-spawns.patch | 14 +- ...ng-PreCreatureSpawnEvent-with-per-pl.patch | 12 +- .../features/0029-Optimize-Hoppers.patch | 220 +- .../patches/features/0030-Anti-Xray.patch | 96 +- ...elay-open-close-callbacks-for-chests.patch | 32 +- ...rove-exact-choice-recipe-ingredients.patch | 36 +- 27 files changed, 1584 insertions(+), 1592 deletions(-) diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index 2f5fc143544b..d12ba1e460a0 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -23689,7 +23689,7 @@ index 0000000000000000000000000000000000000000..8424cf9d4617b4732d44cc460d25b044 + +} diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java -index 3f516ffd7a76f1d17daaa865f7446803b8217bcc..240fb1346b721e4aaf8517b01fa205760cee4bbd 100644 +index bb0c36283b4bdcfa10a4e1b5668b0c34c11cdced..46547155b817a89a8afe2f8d1a30bf881efc07bc 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java @@ -29,7 +29,7 @@ import org.joml.Vector3f; @@ -23746,7 +23746,7 @@ index 3f516ffd7a76f1d17daaa865f7446803b8217bcc..240fb1346b721e4aaf8517b01fa20576 + } + // Paper end - optimise collisions - private Direction( + Direction( final int data3d, @@ -153,14 +193,13 @@ public enum Direction implements StringRepresentable { } @@ -23798,7 +23798,7 @@ index 3f516ffd7a76f1d17daaa865f7446803b8217bcc..240fb1346b721e4aaf8517b01fa20576 + // Paper end - optimise collisions } diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java -index 3c1490ac7c259da04031db2f170e0c0a5f512191..470d7c770ae9d045b97e2df145cfe3cf9d101deb 100644 +index 9d9fa99ff7694a3356421df711c7b1443047b057..c79206e0eb455081f63cf4de2c97413638fd6596 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java @@ -58,6 +58,19 @@ public class MappedRegistry implements WritableRegistry { @@ -23821,16 +23821,16 @@ index 3c1490ac7c259da04031db2f170e0c0a5f512191..470d7c770ae9d045b97e2df145cfe3cf public MappedRegistry(final ResourceKey> key, final Lifecycle lifecycle) { this(key, lifecycle, false); } -@@ -123,6 +136,7 @@ public class MappedRegistry implements WritableRegistry { - this.registrationInfos.put(key, registrationInfo); - this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); - this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API -+ this.injectFluidRegister(key, value); // Paper - fluid method optimisations - return holder; - } +@@ -126,6 +139,7 @@ public class MappedRegistry implements WritableRegistry { + this.registrationInfos.put(key, registrationInfo); + this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); + this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API ++ this.injectFluidRegister(key, value); // Paper - fluid method optimisations + return holder; } + diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index d22f55c63eb950e1b979280612eb9f155e986406..93690b360e5eb1b8d2f8ab2198aa087c9be7ffe2 100644 +index 8e3169acbdaa8b7538cebb38fc501b48da9b2799..5bdb7d130cc2e47c9b55f85acae64e83d6ee2546 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -191,7 +191,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; @@ -23935,7 +23935,7 @@ index d22f55c63eb950e1b979280612eb9f155e986406..93690b360e5eb1b8d2f8ab2198aa087c public MinecraftServer( // CraftBukkit start -@@ -853,7 +939,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop l.getChunkSource().chunkMap.hasWork())) { // Paper - rewrite chunk system this.nextTickTimeNanos = Util.getNanos() + TimeUtil.NANOSECONDS_PER_MILLISECOND; - for (ServerLevel levelx : this.getAllLevels()) { -@@ -992,17 +1083,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); @@ -24071,7 +24071,7 @@ index d22f55c63eb950e1b979280612eb9f155e986406..93690b360e5eb1b8d2f8ab2198aa087c this.tickFrame.end(); this.recordEndOfTick(); // Paper - improve tick loop profiler.pop(); -@@ -2618,6 +2737,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop r.map(List::of)); -- } else { -- int chunkCount = Mth.square(range * 2 + 1); -- List>> deps = new ArrayList<>(chunkCount); -- ChunkPos centerPos = centerChunk.getPos(); +- } - -- for (int z = -range; z <= range; z++) { -- for (int x = -range; x <= range; x++) { -- int distance = Math.max(Math.abs(x), Math.abs(z)); -- long chunkNode = ChunkPos.pack(centerPos.x() + x, centerPos.z() + z); -- ChunkHolder chunk = this.getUpdatingChunkIfPresent(chunkNode); -- if (chunk == null) { -- return UNLOADED_CHUNK_LIST_FUTURE; -- } +- int chunkCount = Mth.square(range * 2 + 1); +- List>> deps = new ArrayList<>(chunkCount); +- ChunkPos centerPos = centerChunk.getPos(); - -- ChunkStatus depStatus = distanceToStatus.apply(distance); -- deps.add(chunk.scheduleChunkGenerationTask(depStatus, this)); +- for (int z = -range; z <= range; z++) { +- for (int x = -range; x <= range; x++) { +- int distance = Math.max(Math.abs(x), Math.abs(z)); +- long chunkNode = ChunkPos.pack(centerPos.x() + x, centerPos.z() + z); +- ChunkHolder chunk = this.getUpdatingChunkIfPresent(chunkNode); +- if (chunk == null) { +- return UNLOADED_CHUNK_LIST_FUTURE; - } -- } - -- return Util.sequence(deps).thenApply(chunkResults -> { -- List chunks = new ArrayList<>(chunkResults.size()); +- ChunkStatus depStatus = distanceToStatus.apply(distance); +- deps.add(chunk.scheduleChunkGenerationTask(depStatus, this)); +- } +- } - -- for (ChunkResult chunkResult : chunkResults) { -- if (chunkResult == null) { -- throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); -- } +- return Util.sequence(deps).thenApply(chunkResults -> { +- List chunks = new ArrayList<>(chunkResults.size()); - -- ChunkAccess chunkx = chunkResult.orElse(null); -- if (chunkx == null) { -- return UNLOADED_CHUNK_LIST_RESULT; -- } +- for (ChunkResult chunkResult : chunkResults) { +- if (chunkResult == null) { +- throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); +- } - -- chunks.add(chunkx); +- ChunkAccess chunkx = chunkResult.orElse(null); +- if (chunkx == null) { +- return UNLOADED_CHUNK_LIST_RESULT; - } - -- return ChunkResult.of(chunks); -- }); -- } +- chunks.add(chunkx); +- } +- +- return ChunkResult.of(chunks); +- }); + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -24796,34 +24796,34 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 private @Nullable ChunkHolder updateChunkScheduling(final long node, final int level, @Nullable ChunkHolder chunk, final int oldLevel) { - if (!ChunkLevel.isLoaded(oldLevel) && !ChunkLevel.isLoaded(level)) { - return chunk; -- } else { -- if (chunk != null) { -- chunk.setTicketLevel(level); -- } +- } - -- if (chunk != null) { -- if (!ChunkLevel.isLoaded(level)) { -- this.toDrop.add(node); -- } else { -- this.toDrop.remove(node); -- } -- } +- if (chunk != null) { +- chunk.setTicketLevel(level); +- } - -- if (ChunkLevel.isLoaded(level) && chunk == null) { -- chunk = this.pendingUnloads.remove(node); -- if (chunk != null) { -- chunk.setTicketLevel(level); -- } else { -- chunk = new ChunkHolder(ChunkPos.unpack(node), level, this.level, this.lightEngine, this::onLevelChange, this); -- ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, chunk); // Paper -- } +- if (chunk != null) { +- if (!ChunkLevel.isLoaded(level)) { +- this.toDrop.add(node); +- } else { +- this.toDrop.remove(node); +- } +- } - -- this.updatingChunkMap.put(node, chunk); -- this.modified = true; +- if (ChunkLevel.isLoaded(level) && chunk == null) { +- chunk = this.pendingUnloads.remove(node); +- if (chunk != null) { +- chunk.setTicketLevel(level); +- } else { +- chunk = new ChunkHolder(ChunkPos.unpack(node), level, this.level, this.lightEngine, this::onLevelChange, this); +- ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, chunk); // Paper - } - -- return chunk; +- this.updatingChunkMap.put(node, chunk); +- this.modified = true; - } +- +- return chunk; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -24987,11 +24987,11 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 protected boolean promoteChunkMap() { - if (!this.modified) { - return false; -- } else { -- this.visibleChunkMap = this.updatingChunkMap.clone(); -- this.modified = false; -- return true; - } +- +- this.visibleChunkMap = this.updatingChunkMap.clone(); +- this.modified = false; +- return true; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -25023,7 +25023,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 } private ChunkAccess handleChunkLoadFailure(final Throwable throwable, final ChunkPos pos) { -@@ -659,229 +436,139 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -659,231 +436,139 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @Override public GenerationChunkHolder acquireGeneration(final long chunkNode) { @@ -25046,25 +25046,25 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 - ChunkPos pos = chunkHolder.getPos(); - if (step.targetStatus() == ChunkStatus.EMPTY) { - return this.scheduleChunkLoad(pos); -- } else { -- try { -- GenerationChunkHolder holder = cache.get(pos.x(), pos.z()); -- ChunkAccess centerChunk = holder.getChunkIfPresentUnchecked(step.targetStatus().getParent()); -- if (centerChunk == null) { -- throw new IllegalStateException("Parent chunk missing"); -- } else { -- return step.apply(this.worldGenContext, cache, centerChunk); -- } -- } catch (Exception var8) { -- var8.getStackTrace(); -- CrashReport report = CrashReport.forThrowable(var8, "Exception generating new chunk"); -- CrashReportCategory category = report.addCategory("Chunk to be generated"); -- category.setDetail("Status being generated", () -> step.targetStatus().getName()); -- category.setDetail("Location", String.format(Locale.ROOT, "%d,%d", pos.x(), pos.z())); -- category.setDetail("Position hash", ChunkPos.pack(pos.x(), pos.z())); -- category.setDetail("Generator", this.generator()); -- throw new ReportedException(report); +- } +- +- try { +- GenerationChunkHolder holder = cache.get(pos.x(), pos.z()); +- ChunkAccess centerChunk = holder.getChunkIfPresentUnchecked(step.targetStatus().getParent()); +- if (centerChunk == null) { +- throw new IllegalStateException("Parent chunk missing"); +- } else { +- return step.apply(this.worldGenContext, cache, centerChunk); - } +- } catch (Exception e) { +- e.getStackTrace(); +- CrashReport report = CrashReport.forThrowable(e, "Exception generating new chunk"); +- CrashReportCategory category = report.addCategory("Chunk to be generated"); +- category.setDetail("Status being generated", () -> step.targetStatus().getName()); +- category.setDetail("Location", String.format(Locale.ROOT, "%d,%d", pos.x(), pos.z())); +- category.setDetail("Position hash", ChunkPos.pack(pos.x(), pos.z())); +- category.setDetail("Generator", this.generator()); +- throw new ReportedException(report); - } + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -25150,23 +25150,25 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 - ChunkAccess chunkAccess = chunk.getLatestChunk(); - if (!(chunkAccess instanceof ImposterProtoChunk) && !(chunkAccess instanceof LevelChunk)) { - return false; -- } else if (!chunkAccess.isUnsaved()) { +- } +- +- if (!chunkAccess.isUnsaved()) { - return false; -- } else { -- long chunkPos = chunkAccess.getPos().pack(); -- long nextSaveTime = this.nextChunkSaveTime.getOrDefault(chunkPos, -1L); -- if (now < nextSaveTime) { -- return false; -- } else { -- boolean saved = this.save(chunkAccess); -- chunk.refreshAccessibility(); -- if (saved) { -- this.nextChunkSaveTime.put(chunkPos, now + 10000L); -- } +- } - -- return saved; -- } +- long chunkPos = chunkAccess.getPos().pack(); +- long nextSaveTime = this.nextChunkSaveTime.getOrDefault(chunkPos, -1L); +- if (now < nextSaveTime) { +- return false; +- } +- +- boolean saved = this.save(chunkAccess); +- chunk.refreshAccessibility(); +- if (saved) { +- this.nextChunkSaveTime.put(chunkPos, now + 10000L); - } +- +- return saved; - } else { - return false; - } @@ -25177,39 +25179,39 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 - this.poiManager.flush(chunk.getPos()); - if (!chunk.tryMarkSaved()) { - return false; -- } else { -- ChunkPos pos = chunk.getPos(); +- } - -- try { -- ChunkStatus status = chunk.getPersistedStatus(); -- if (status.getChunkType() != ChunkType.LEVELCHUNK) { -- if (this.isExistingChunkFull(pos)) { -- return false; -- } +- ChunkPos pos = chunk.getPos(); - -- if (status == ChunkStatus.EMPTY && chunk.getAllStarts().values().stream().noneMatch(StructureStart::isValid)) { -- return false; -- } +- try { +- ChunkStatus status = chunk.getPersistedStatus(); +- if (status.getChunkType() != ChunkType.LEVELCHUNK) { +- if (this.isExistingChunkFull(pos)) { +- return false; - } - -- Profiler.get().incrementCounter("chunkSave"); -- this.activeChunkWrites.incrementAndGet(); -- SerializableChunkData data = SerializableChunkData.copyOf(this.level, chunk); -- CompletableFuture encodedData = CompletableFuture.supplyAsync(data::write, Util.backgroundExecutor()); -- this.write(pos, encodedData::join).handle((ignored, throwable) -> { -- if (throwable != null) { -- this.level.getServer().reportChunkSaveFailure(throwable, this.storageInfo(), pos); -- } -- -- this.activeChunkWrites.decrementAndGet(); -- return null; -- }); -- this.markPosition(pos, status.getChunkType()); -- return true; -- } catch (Exception var6) { -- this.level.getServer().reportChunkSaveFailure(var6, this.storageInfo(), pos); -- return false; +- if (status == ChunkStatus.EMPTY && chunk.getAllStarts().values().stream().noneMatch(StructureStart::isValid)) { +- return false; +- } - } +- +- Profiler.get().incrementCounter("chunkSave"); +- this.activeChunkWrites.incrementAndGet(); +- SerializableChunkData data = SerializableChunkData.copyOf(this.level, chunk); +- CompletableFuture encodedData = CompletableFuture.supplyAsync(data::write, Util.backgroundExecutor()); +- this.write(pos, encodedData::join).handle((ignored, throwable) -> { +- if (throwable != null) { +- this.level.getServer().reportChunkSaveFailure(throwable, this.storageInfo(), pos); +- } +- +- this.activeChunkWrites.decrementAndGet(); +- return null; +- }); +- this.markPosition(pos, status.getChunkType()); +- return true; +- } catch (Exception e) { +- this.level.getServer().reportChunkSaveFailure(e, this.storageInfo(), pos); +- return false; - } + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -25218,23 +25220,23 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 - byte cachedChunkType = this.chunkTypeCache.get(pos.pack()); - if (cachedChunkType != 0) { - return cachedChunkType == 1; -- } else { -- CompoundTag currentTag; -- try { -- currentTag = this.readChunk(pos).join().orElse(null); -- if (currentTag == null) { -- this.markPositionReplaceable(pos); -- return false; -- } -- } catch (Exception var5) { -- LOGGER.error("Failed to read chunk {}", pos, var5); +- } +- +- CompoundTag currentTag; +- try { +- currentTag = this.readChunk(pos).join().orElse(null); +- if (currentTag == null) { - this.markPositionReplaceable(pos); - return false; - } -- -- ChunkType chunkType = SerializableChunkData.getChunkStatusFromTag(currentTag).getChunkType(); -- return this.markPosition(pos, chunkType) == 1; +- } catch (Exception e) { +- LOGGER.error("Failed to read chunk {}", pos, e); +- this.markPositionReplaceable(pos); +- return false; - } +- +- ChunkType chunkType = SerializableChunkData.getChunkStatusFromTag(currentTag).getChunkType(); +- return this.markPosition(pos, chunkType) == 1; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -25279,8 +25281,8 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 private static void dropChunk(final ServerPlayer player, final ChunkPos pos) { - player.connection.chunkSender.dropChunk(player, pos); + // Paper - rewrite chunk system - } - ++ } ++ + // Paper start - rewrite chunk system + @Override + public CompletableFuture> read(final ChunkPos pos) { @@ -25307,8 +25309,8 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 + ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionFileType.CHUNK_DATA + ); + return null; -+ } -+ + } + + @Override + public CompletableFuture synchronize(final boolean flush) { + try { @@ -25326,7 +25328,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 public @Nullable LevelChunk getChunkToSend(final long key) { ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(key); return chunkHolder == null ? null : chunkHolder.getChunkToSend(); -@@ -963,7 +650,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -965,7 +650,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP return this.read(pos).thenApplyAsync(chunkTag -> chunkTag.map(this::upgradeChunkTag), Util.backgroundExecutor().forName("upgradeChunk")); } @@ -25335,7 +25337,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 return this.upgradeChunkTag( tag, -1, -@@ -979,23 +666,66 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -981,23 +666,66 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP return contextTag; } @@ -25411,7 +25413,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 if (holder != null) { LevelChunk chunk = holder.getTickingChunk(); if (chunk != null) { -@@ -1011,8 +741,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1013,8 +741,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos, boolean reducedRange) { @@ -25422,7 +25424,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 // Spigot end } -@@ -1036,7 +766,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1038,7 +766,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP private boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos, final boolean reducedRange) { double blockRange; // Paper - use from event // Spigot end @@ -25444,7 +25446,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 // Paper start - PlayerNaturallySpawnCreaturesEvent com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; blockRange = 16384.0; -@@ -1052,26 +795,41 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1054,26 +795,41 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } return false; @@ -25455,24 +25457,23 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 - long key = pos.pack(); - if (!this.distanceManager.hasPlayersNearby(key).toBoolean(true)) { - return List.of(); -- } else { -- Builder builder = ImmutableList.builder(); + // Paper start - chunk tick iteration optimisation + final ca.spottedleaf.moonrise.common.list.ReferenceList players = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers( + pos, ca.spottedleaf.moonrise.common.misc.NearbyPlayers.NearbyMapType.SPAWN_RANGE + ); + if (players == null) { + return new ArrayList<>(); -+ } -+ + } + +- Builder builder = ImmutableList.builder(); + List ret = null; -+ + +- for (ServerPlayer player : this.playerMap.getAllPlayers()) { +- if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot +- builder.add(player); + final ServerPlayer[] raw = players.getRawDataUnchecked(); + final int len = players.size(); - -- for (ServerPlayer player : this.playerMap.getAllPlayers()) { -- if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot -- builder.add(player); ++ + Objects.checkFromIndexSize(0, len, raw.length); + for (int i = 0; i < len; ++i) { + final ServerPlayer player = raw[i]; @@ -25482,12 +25483,11 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 + ret.add(player); + } else { + ret.add(player); - } ++ } } -- -- return builder.build(); } -+ + +- return builder.build(); + return ret == null ? new ArrayList<>() : ret; + // Paper end - chunk tick iteration optimisation } @@ -25496,8 +25496,8 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 + public boolean playerIsCloseEnoughForSpawning(final ServerPlayer player, final ChunkPos pos, final double range) { // Spigot // Paper - chunk tick iteration optimisation - public if (player.isSpectator()) { return false; - } else { -@@ -1109,18 +867,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + } +@@ -1111,18 +867,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.updatePlayerPos(player); if (!ignored) { this.distanceManager.addPlayer(SectionPos.of(player), player); @@ -25520,7 +25520,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 } } -@@ -1130,13 +890,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1132,13 +890,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void move(final ServerPlayer player) { @@ -25535,7 +25535,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 SectionPos oldSection = player.getLastSectionPos(); SectionPos newSection = SectionPos.of(player); -@@ -1145,6 +899,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1147,6 +899,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP boolean positionChanged = oldSection.asLong() != newSection.asLong(); if (positionChanged || wasIgnored != ignored) { this.updatePlayerPos(player); @@ -25543,7 +25543,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 if (!wasIgnored) { this.distanceManager.removePlayer(oldSection, player); } -@@ -1161,47 +916,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1163,47 +916,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.playerMap.unIgnorePlayer(player); } @@ -25602,20 +25602,20 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 } public void addEntity(final Entity entity) { -@@ -1225,6 +962,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP - } else { - ChunkMap.TrackedEntity trackedEntity = new ChunkMap.TrackedEntity(entity, range, updateInterval, type.trackDeltas()); - this.entityMap.put(entity.getId(), trackedEntity); -+ // Paper start - optimise entity tracker -+ if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$getTrackedEntity() != null) { -+ throw new IllegalStateException("Entity is already tracked"); -+ } -+ ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$setTrackedEntity(trackedEntity); -+ // Paper end - optimise entity tracker - trackedEntity.updatePlayers(this.level.players()); - if (entity instanceof ServerPlayer player) { - this.updatePlayerStatus(player, true); -@@ -1254,12 +997,38 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1228,6 +963,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + + ChunkMap.TrackedEntity trackedEntity = new ChunkMap.TrackedEntity(entity, range, updateInterval, type.trackDeltas()); + this.entityMap.put(entity.getId(), trackedEntity); ++ // Paper start - optimise entity tracker ++ if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$getTrackedEntity() != null) { ++ throw new IllegalStateException("Entity is already tracked"); ++ } ++ ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$setTrackedEntity(trackedEntity); ++ // Paper end - optimise entity tracker + trackedEntity.updatePlayers(this.level.players()); + if (entity instanceof ServerPlayer player) { + this.updatePlayerStatus(player, true); +@@ -1256,12 +997,38 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP if (trackedEntity != null) { trackedEntity.broadcastRemoved(); } @@ -25656,7 +25656,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 List movedPlayers = Lists.newArrayList(); List players = this.level.players(); -@@ -1359,17 +1128,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1361,17 +1128,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void waitForLightBeforeSending(final ChunkPos centerChunk, final int chunkRadius) { @@ -25676,14 +25676,13 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 LevelChunk chunk = chunkHolder.getChunkToSend(); if (chunk != null) { consumer.accept(chunk); -@@ -1377,15 +1140,22 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1379,14 +1140,21 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } - public class DistanceManager extends net.minecraft.server.level.DistanceManager { + public class DistanceManager extends net.minecraft.server.level.DistanceManager implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager { // Paper - rewrite chunk system protected DistanceManager(final TicketStorage ticketStorage, final Executor executor, final Executor mainThreadExecutor) { - Objects.requireNonNull(ChunkMap.this); super(ticketStorage, executor, mainThreadExecutor); } @@ -25701,7 +25700,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 } @Override -@@ -1399,13 +1169,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1400,13 +1168,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -25711,7 +25710,7 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 private final Entity entity; private final int range; private SectionPos lastSectionPos; - public final Set seenBy; + public final Set seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl + // Paper start - optimise entity tracker + private long lastChunkUpdate = -1L; @@ -25797,9 +25796,9 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 + // Paper end - optimise entity tracker + public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { - Objects.requireNonNull(ChunkMap.this); - super(); -@@ -1520,17 +1373,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper + this.entity = entity; +@@ -1518,17 +1369,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private int getEffectiveRange() { @@ -25833,10 +25832,10 @@ index c129d7a0823d7eaae677ca3b54839e299a9c3408..0b28fdd0a2fb5b45457f92192a712797 public void updatePlayers(final List players) { diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java -index abc610594c3d37993df8762783baaae0c053a5cc..f1fa6c7169635724e202c10adafe7d70e14ac7de 100644 +index 31badcd3a478f770e1a8d296dbb5d9e4b529ae7d..63cc7970b9df5e84743084ca99650bc3d13b970e 100644 --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -32,94 +32,79 @@ import net.minecraft.world.level.chunk.LevelChunk; +@@ -31,94 +31,79 @@ import net.minecraft.world.level.chunk.LevelChunk; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -25980,7 +25979,7 @@ index abc610594c3d37993df8762783baaae0c053a5cc..f1fa6c7169635724e202c10adafe7d70 } public void removePlayer(final SectionPos pos, final ServerPlayer player) { -@@ -131,71 +116,79 @@ public abstract class DistanceManager { +@@ -130,71 +115,79 @@ public abstract class DistanceManager { if (chunkPlayers == null || chunkPlayers.isEmpty()) { // Paper end - some state corruption happens here, don't crash, clean up gracefully this.playersPerChunk.remove(chunkPos); @@ -26090,15 +26089,15 @@ index abc610594c3d37993df8762783baaae0c053a5cc..f1fa6c7169635724e202c10adafe7d70 } public boolean hasTickets() { -@@ -249,6 +242,7 @@ public abstract class DistanceManager { +@@ -246,6 +239,7 @@ public abstract class DistanceManager { } } +/* // Paper - rewrite chunk system private class PlayerTicketTracker extends DistanceManager.FixedPlayerDistanceChunkTracker { private int viewDistance; - private final Long2IntMap queueLevels; -@@ -330,5 +324,5 @@ public abstract class DistanceManager { + private final Long2IntMap queueLevels = Long2IntMaps.synchronize(new Long2IntOpenHashMap()); +@@ -324,5 +318,5 @@ public abstract class DistanceManager { private boolean haveTicketFor(final int level) { return level <= this.viewDistance; } @@ -26106,7 +26105,7 @@ index abc610594c3d37993df8762783baaae0c053a5cc..f1fa6c7169635724e202c10adafe7d70 + }*/ // Paper - rewrite chunk system } diff --git a/net/minecraft/server/level/GenerationChunkHolder.java b/net/minecraft/server/level/GenerationChunkHolder.java -index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e181c0048f 100644 +index bd140f2d39307d4f909b11cc78da84e03aa4c3ca..75686eb990d7275b442e16df39b7b2e181c0048f 100644 --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java @@ -26,12 +26,7 @@ public abstract class GenerationChunkHolder { @@ -26129,19 +26128,19 @@ index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e1 public CompletableFuture> scheduleChunkGenerationTask(final ChunkStatus status, final ChunkMap scheduler) { - if (this.isStatusDisallowed(status)) { - return UNLOADED_CHUNK_FUTURE; -- } else { -- CompletableFuture> future = this.getOrCreateFuture(status); -- if (future.isDone()) { -- return future; -- } else { -- ChunkGenerationTask task = this.task.get(); -- if (task == null || status.isAfter(task.targetStatus)) { -- this.rescheduleChunkTask(scheduler, status); -- } +- } - -- return future; -- } +- CompletableFuture> future = this.getOrCreateFuture(status); +- if (future.isDone()) { +- return future; +- } +- +- ChunkGenerationTask task = this.task.get(); +- if (task == null || status.isAfter(task.targetStatus)) { +- this.rescheduleChunkTask(scheduler, status); - } +- +- return future; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -26220,25 +26219,25 @@ index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e1 private CompletableFuture> getOrCreateFuture(final ChunkStatus status) { - if (this.isStatusDisallowed(status)) { - return UNLOADED_CHUNK_FUTURE; -- } else { -- int index = status.getIndex(); -- CompletableFuture> future = this.futures.get(index); +- } - -- while (future == null) { -- CompletableFuture> newValue = new CompletableFuture<>(); -- future = this.futures.compareAndExchange(index, null, newValue); -- if (future == null) { -- if (this.isStatusDisallowed(status)) { -- this.failAndClearPendingFuture(index, newValue); -- return UNLOADED_CHUNK_FUTURE; -- } +- int index = status.getIndex(); +- CompletableFuture> future = this.futures.get(index); - -- return newValue; +- while (future == null) { +- CompletableFuture> newValue = new CompletableFuture<>(); +- future = this.futures.compareAndExchange(index, null, newValue); +- if (future == null) { +- if (this.isStatusDisallowed(status)) { +- this.failAndClearPendingFuture(index, newValue); +- return UNLOADED_CHUNK_FUTURE; - } -- } - -- return future; +- return newValue; +- } - } +- +- return future; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -26290,24 +26289,24 @@ index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e1 private @Nullable ChunkStatus findHighestStatusWithPendingFuture(final @Nullable ChunkStatus newStatus) { - if (newStatus == null) { - return null; -- } else { -- ChunkStatus highestStatus = newStatus; +- } - -- for (ChunkStatus alreadyStarted = this.startedWork.get(); -- alreadyStarted == null || highestStatus.isAfter(alreadyStarted); -- highestStatus = highestStatus.getParent() -- ) { -- if (this.futures.get(highestStatus.getIndex()) != null) { -- return highestStatus; -- } +- ChunkStatus highestStatus = newStatus; - -- if (highestStatus == ChunkStatus.EMPTY) { -- break; -- } +- for (ChunkStatus alreadyStarted = this.startedWork.get(); +- alreadyStarted == null || highestStatus.isAfter(alreadyStarted); +- highestStatus = highestStatus.getParent() +- ) { +- if (this.futures.get(highestStatus.getIndex()) != null) { +- return highestStatus; - } - -- return null; +- if (highestStatus == ChunkStatus.EMPTY) { +- break; +- } - } +- +- return null; + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -26372,10 +26371,10 @@ index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e1 - ChunkStatus status = this.startedWork.get(); - if (status == null) { - return null; -- } else { -- ChunkAccess chunk = this.getChunkIfPresentUnchecked(status); -- return chunk != null ? chunk : this.getChunkIfPresentUnchecked(status.getParent()); - } +- +- ChunkAccess chunk = this.getChunkIfPresentUnchecked(status); +- return chunk != null ? chunk : this.getChunkIfPresentUnchecked(status.getParent()); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder.ChunkCompletion lastCompletion = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)(Object)this).moonrise$getRealChunkHolder().getLastChunkCompletion(); + return lastCompletion == null ? null : lastCompletion.chunk(); @@ -26421,10 +26420,10 @@ index 531cc9b4375f7eb7c1ca6dcd40c29b74b600ec63..75686eb990d7275b442e16df39b7b2e1 - ChunkStatus status = this.startedWork.get(); - if (status == null) { - return null; -- } else { -- ChunkAccess chunk = this.getChunkIfPresentUnchecked(status); -- return chunk != null ? status : status.getParent(); - } +- +- ChunkAccess chunk = this.getChunkIfPresentUnchecked(status); +- return chunk != null ? status : status.getParent(); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder.ChunkCompletion lastCompletion = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)(Object)this).moonrise$getRealChunkHolder().getLastChunkCompletion(); + return lastCompletion == null ? null : lastCompletion.genStatus(); @@ -26445,7 +26444,7 @@ index b107715893fc5329ae4a27967780d3587166b6dd..15cd107d347ee01c809938684bf90cc2 } } diff --git a/net/minecraft/server/level/PlayerSpawnFinder.java b/net/minecraft/server/level/PlayerSpawnFinder.java -index 045d4b0ab26622e2763d1583e1e8fcb83ba44427..ddffd36d8213a40dc3f6cbb0ef0f33a0a7490ac1 100644 +index 8e02980d29a15086805a93f1f1a416f0308c70b9..a7799e8c12713e00124f2caf69f74a616b1af3e7 100644 --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -115,9 +115,9 @@ public class PlayerSpawnFinder { @@ -26471,7 +26470,7 @@ index 045d4b0ab26622e2763d1583e1e8fcb83ba44427..ddffd36d8213a40dc3f6cbb0ef0f33a0 } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e749a73f93 100644 +index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475bd54789b 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -54,7 +54,7 @@ import net.minecraft.world.level.storage.SavedDataStorage; @@ -26483,7 +26482,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; private final ServerLevel level; -@@ -82,6 +82,106 @@ public class ServerChunkCache extends ChunkSource { +@@ -82,6 +82,105 @@ public class ServerChunkCache extends ChunkSource { } long chunkFutureAwaitCounter; // Paper end @@ -26586,11 +26585,10 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 + } + } + // Paper end - chunk tick iteration optimisations -+ public ServerChunkCache( final ServerLevel level, -@@ -141,13 +241,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -141,13 +240,7 @@ public class ServerChunkCache extends ChunkSource { } // CraftBukkit end // Paper start @@ -26605,47 +26603,44 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 @Nullable public ChunkAccess getChunkAtImmediately(int x, int z) { -@@ -212,67 +306,42 @@ public class ServerChunkCache extends ChunkSource { +@@ -212,66 +305,41 @@ public class ServerChunkCache extends ChunkSource { @Override public @Nullable ChunkAccess getChunk(final int x, final int z, final ChunkStatus targetStatus, final boolean loadOrGenerate) { - if (Thread.currentThread() != this.mainThread) { - return CompletableFuture.supplyAsync(() -> this.getChunk(x, z, targetStatus, loadOrGenerate), this.mainThreadProcessor).join(); -- } else { -- ProfilerFiller profiler = Profiler.get(); -- profiler.incrementCounter("getChunk"); -- long pos = ChunkPos.pack(x, z); -- -- for (int i = 0; i < 4; i++) { -- if (pos == this.lastChunkPos[i] && targetStatus == this.lastChunkStatus[i]) { -- ChunkAccess chunkAccess = this.lastChunk[i]; -- if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime -- return chunkAccess; -- } -- } -- } +- } + // Paper start - rewrite chunk system + if (targetStatus == ChunkStatus.FULL) { + final LevelChunk ret = this.fullChunks.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(x, z)); -- profiler.incrementCounter("getChunkCacheMiss"); -- CompletableFuture> serverFuture = this.getChunkFutureMainThread(x, z, targetStatus, loadOrGenerate); -- this.mainThreadProcessor.managedBlock(serverFuture::isDone); -- // com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x, z); // Paper - Add debug for sync chunk loads -- ChunkResult chunkResult = serverFuture.join(); -- ChunkAccess chunk = chunkResult.orElse(null); -- if (chunk == null && loadOrGenerate) { -- throw (IllegalStateException)Util.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkResult.getError())); -- } else { -- this.storeInCache(pos, chunk, targetStatus); -- return chunk; +- ProfilerFiller profiler = Profiler.get(); +- profiler.incrementCounter("getChunk"); +- long pos = ChunkPos.pack(x, z); +- +- for (int i = 0; i < 4; i++) { +- if (pos == this.lastChunkPos[i] && targetStatus == this.lastChunkStatus[i]) { +- ChunkAccess chunkAccess = this.lastChunk[i]; +- if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime +- return chunkAccess; +- } + if (ret != null) { + return ret; } -+ +- } + +- profiler.incrementCounter("getChunkCacheMiss"); +- CompletableFuture> serverFuture = this.getChunkFutureMainThread(x, z, targetStatus, loadOrGenerate); +- this.mainThreadProcessor.managedBlock(serverFuture::isDone); +- ChunkResult chunkResult = serverFuture.join(); +- ChunkAccess chunk = chunkResult.orElse(null); +- if (chunk == null && loadOrGenerate) { +- throw (IllegalStateException)Util.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkResult.getError())); + return loadOrGenerate ? this.getChunkFallback(x, z, targetStatus, loadOrGenerate) : null; } -+ + +- this.storeInCache(pos, chunk, targetStatus); +- return chunk; + return this.getChunkFallback(x, z, targetStatus, loadOrGenerate); + // Paper end - rewrite chunk system } @@ -26654,51 +26649,48 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 public @Nullable LevelChunk getChunkNow(final int x, final int z) { - if (Thread.currentThread() != this.mainThread) { - return null; -- } else { -- Profiler.get().incrementCounter("getChunkNow"); -- long pos = ChunkPos.pack(x, z); + // Paper start - rewrite chunk system + final LevelChunk ret = this.fullChunks.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(x, z)); + if (!ca.spottedleaf.moonrise.common.PlatformHooks.get().hasCurrentlyLoadingChunk()) { + return ret; + } -- for (int i = 0; i < 4; i++) { -- if (pos == this.lastChunkPos[i] && this.lastChunkStatus[i] == ChunkStatus.FULL) { -- ChunkAccess chunkAccess = this.lastChunk[i]; -- return chunkAccess instanceof LevelChunk ? (LevelChunk)chunkAccess : null; -- } +- Profiler.get().incrementCounter("getChunkNow"); +- long pos = ChunkPos.pack(x, z); +- +- for (int i = 0; i < 4; i++) { +- if (pos == this.lastChunkPos[i] && this.lastChunkStatus[i] == ChunkStatus.FULL) { +- ChunkAccess chunkAccess = this.lastChunk[i]; +- return chunkAccess instanceof LevelChunk ? (LevelChunk)chunkAccess : null; - } -+ } - -- ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(pos); -- if (chunkHolder == null) { -- return null; -- } else { -- ChunkAccess chunk = chunkHolder.getChunkIfPresent(ChunkStatus.FULL); -- if (chunk != null) { -- this.storeInCache(pos, chunk, ChunkStatus.FULL); -- if (chunk instanceof LevelChunk) { -- return (LevelChunk)chunk; -- } -- } + if (ret != null || !ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) { + return ret; -+ } + } -- return null; +- ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(pos); +- if (chunkHolder == null) { +- return null; +- } +- +- ChunkAccess chunk = chunkHolder.getChunkIfPresent(ChunkStatus.FULL); +- if (chunk != null) { +- this.storeInCache(pos, chunk, ChunkStatus.FULL); +- if (chunk instanceof LevelChunk) { +- return (LevelChunk)chunk; - } + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler() + .chunkHolderManager.getChunkHolder(x, z); + if (holder == null) { + return ret; } -+ + +- return null; + return ca.spottedleaf.moonrise.common.PlatformHooks.get().getCurrentlyLoadingChunk(holder.vanillaChunkHolder); + // Paper end - rewrite chunk system } private void clearCache() { -@@ -300,53 +369,62 @@ public class ServerChunkCache extends ChunkSource { +@@ -299,53 +367,62 @@ public class ServerChunkCache extends ChunkSource { private CompletableFuture> getChunkFutureMainThread( final int x, final int z, final ChunkStatus targetStatus, final boolean loadOrGenerate ) { @@ -26795,7 +26787,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 } @Override -@@ -359,28 +437,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -358,28 +435,18 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -26804,20 +26796,20 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 - this.chunkMap.runGenerationTasks(); - if (!updated && !promoted) { - return false; -- } else { -- this.clearCache(); -- return true; - } +- +- this.clearCache(); +- return true; + return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(); // Paper - rewrite chunk system } public boolean isPositionTicking(final long chunkKey) { - if (!this.level.shouldTickBlocksAt(chunkKey)) { - return false; -- } else { -- ChunkHolder holder = this.getVisibleChunkIfPresent(chunkKey); -- return holder != null && holder.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).isSuccess(); - } +- +- ChunkHolder holder = this.getVisibleChunkIfPresent(chunkKey); +- return holder != null && holder.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).isSuccess(); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder newChunkHolder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkKey); + return newChunkHolder != null && newChunkHolder.isTickingReady(); @@ -26830,7 +26822,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 this.chunkMap.saveAllChunks(flushStorage); } -@@ -391,17 +459,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -390,17 +457,15 @@ public class ServerChunkCache extends ChunkSource { } public void close(boolean save) throws IOException { @@ -26851,7 +26843,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 ProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("purge"); -@@ -425,6 +491,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -424,6 +489,7 @@ public class ServerChunkCache extends ChunkSource { this.runDistanceManagerUpdates(); profiler.popPush("chunks"); if (tickChunks) { @@ -26859,7 +26851,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 this.tickChunks(); this.chunkMap.tick(); } -@@ -457,7 +524,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -456,7 +522,7 @@ public class ServerChunkCache extends ChunkSource { profiler.push("broadcast"); for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { @@ -26868,7 +26860,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 if (chunk != null) { chunkHolder.broadcastChanges(chunk); } -@@ -498,7 +565,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -497,7 +563,10 @@ public class ServerChunkCache extends ChunkSource { profiler.popPush("filteringSpawningChunks"); this.chunkMap.collectSpawningChunks(spawningChunks); profiler.popPush("shuffleSpawningChunks"); @@ -26879,7 +26871,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 profiler.popPush("tickSpawningChunks"); for (LevelChunk chunk : spawningChunks) { -@@ -509,7 +579,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -508,7 +577,7 @@ public class ServerChunkCache extends ChunkSource { } profiler.popPush("tickTickingChunks"); @@ -26888,7 +26880,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 if (doMobSpawning) { profiler.popPush("customSpawners"); this.level.tickCustomSpawners(this.spawnEnemies); -@@ -523,22 +593,25 @@ public class ServerChunkCache extends ChunkSource { +@@ -522,22 +591,25 @@ public class ServerChunkCache extends ChunkSource { ) { ChunkPos chunkPos = chunk.getPos(); chunk.incrementInhabitedTime(timeDiff); @@ -26919,21 +26911,23 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 } @Override -@@ -596,17 +669,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -595,19 +667,11 @@ public class ServerChunkCache extends ChunkSource { } public CompletableFuture addTicketAndLoadWithRadius(final TicketType type, final ChunkPos pos, final int radius) { - if (!type.doesLoad()) { - throw new IllegalStateException("Ticket type " + type + " does not trigger chunk loading"); -- } else if (type.canExpireIfUnloaded()) { +- } +- +- if (type.canExpireIfUnloaded()) { - throw new IllegalStateException("Ticket type " + type + " can expire before it loads, cannot fetch asynchronously"); -- } else { -- this.addTicketWithRadius(type, pos, radius); -- this.runDistanceManagerUpdates(); -- ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(pos.pack()); -- Objects.requireNonNull(chunkHolder, "No chunk was scheduled for loading"); -- return this.chunkMap.getChunkRangeFuture(chunkHolder, radius, distance -> ChunkStatus.FULL); - } +- +- this.addTicketWithRadius(type, pos, radius); +- this.runDistanceManagerUpdates(); +- ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(pos.pack()); +- Objects.requireNonNull(chunkHolder, "No chunk was scheduled for loading"); +- return this.chunkMap.getChunkRangeFuture(chunkHolder, radius, distance -> ChunkStatus.FULL); + // Paper start - rewrite chunk system + return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAndLoadWithRadius( + type, pos, radius, ChunkStatus.FULL, ca.spottedleaf.concurrentutil.util.Priority.NORMAL @@ -26942,7 +26936,7 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 } public void addTicketWithRadius(final TicketType type, final ChunkPos pos, final int radius) { -@@ -656,6 +723,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -657,6 +721,12 @@ public class ServerChunkCache extends ChunkSource { this.chunkMap.setServerViewDistance(newDistance); } @@ -26955,32 +26949,29 @@ index bf8496c8cadb29db9c46015e202e7d59e2ed2f5e..f4e033fb5e5b116245dd4a381366c4e7 public void setSimulationDistance(final int simulationDistance) { this.distanceManager.updateSimulationDistance(simulationDistance); } -@@ -736,18 +809,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -736,18 +806,12 @@ public class ServerChunkCache extends ChunkSource { @Override protected boolean pollTask() { - try { // CraftBukkit - process pending Chunk loadCallback() and unloadCallback() after each run task -- if (ServerChunkCache.this.runDistanceManagerUpdates()) { -+ // Paper start - rewrite chunk system -+ final ServerChunkCache serverChunkCache = ServerChunkCache.this; -+ if (serverChunkCache.runDistanceManagerUpdates()) { + if (ServerChunkCache.this.runDistanceManagerUpdates()) { return true; - } else { -- ServerChunkCache.this.lightEngine.tryScheduleUpdate(); -- return super.pollTask(); -- } + } + +- ServerChunkCache.this.lightEngine.tryScheduleUpdate(); +- return super.pollTask(); - // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task - } finally { - ServerChunkCache.this.chunkMap.callbackExecutor.run(); -+ return super.pollTask() | ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)serverChunkCache.level).moonrise$getChunkTaskScheduler().executeMainThreadTask(); - } +- } - // CraftBukkit end - process pending Chunk loadCallback() and unloadCallback() after each run task -+ // Paper end - rewrite chunk system ++ // Paper - rewrite chunk system ++ return super.pollTask() | ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)ServerChunkCache.this.level).moonrise$getChunkTaskScheduler().executeMainThreadTask(); // Paper - rewrite chunk system } } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index de75dda2e6f17f0ae6e7f6a5620fd3eac9d389e5..6774d12d04fa848624fb8bf7a3c2b8bcb88f6e8f 100644 +index 160eeda06cd6bfcec60bac43235760d92fe8d63d..a62ec41b1319857f0d6cd223d013a92b1e2c2b0d 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -90,6 +90,11 @@ public class ServerEntity { @@ -26996,7 +26987,7 @@ index de75dda2e6f17f0ae6e7f6a5620fd3eac9d389e5..6774d12d04fa848624fb8bf7a3c2b8bc List passengers = this.entity.getPassengers(); if (!passengers.equals(this.lastPassengers)) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index f39d48821d728232472ebc5bd6868e6a0d644721..91d27b90a9c9c348d3f93624ff8dbff8a70f522c 100644 +index 97eba37cd2179bec46854f97a1617eae7cb95754..89da20b0682708ba8bfc0d10381eb9784d80c395 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -182,7 +182,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; @@ -27525,7 +27516,7 @@ index f39d48821d728232472ebc5bd6868e6a0d644721..91d27b90a9c9c348d3f93624ff8dbff8 - int sectionY = chunk.getSectionYFromSectionIndex(sectionIndex); - int minYInSection = SectionPos.sectionToBlockCoord(sectionY); - -- for (int ix = 0; ix < tickSpeed; ix++) { +- for (int i = 0; i < tickSpeed; i++) { - BlockPos pos = this.getBlockRandomPos(minX, minYInSection, minZ, 15); - profiler.push("randomTick"); - BlockState blockState = section.getBlockState(pos.getX() - minX, pos.getY() - minYInSection, pos.getZ() - minZ); @@ -27633,8 +27624,8 @@ index f39d48821d728232472ebc5bd6868e6a0d644721..91d27b90a9c9c348d3f93624ff8dbff8 - if (entity.getSelfAndPassengers().map(Entity::getUUID).anyMatch(this.entityManager::isLoaded)) { + if (entity.getSelfAndPassengers().map(Entity::getUUID).anyMatch(this.moonrise$getEntityLookup()::hasEntity)) { // Paper - rewrite chunk system return false; - } else { - this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit + } + @@ -2112,7 +2423,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } @@ -27778,10 +27769,10 @@ index f39d48821d728232472ebc5bd6868e6a0d644721..91d27b90a9c9c348d3f93624ff8dbff8 "Server weather", () -> String.format( diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d..41816ca8d4ef3d959d2b88cd4b2eedaaa541e612 100644 +index 7ef50f10afc8085e24c955e001d989035261cbdd..bf2cc87fcd62c6054472b41353a91527f81527d3 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -203,7 +203,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; +@@ -202,7 +202,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -27790,7 +27781,7 @@ index 2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d..41816ca8d4ef3d959d2b88cd4b2eedaa private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -449,6 +449,36 @@ public class ServerPlayer extends Player { +@@ -430,6 +430,36 @@ public class ServerPlayer extends Player { public com.destroystokyo.paper.event.entity.@Nullable PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent public org.bukkit.event.player.PlayerQuitEvent.@Nullable QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event @@ -27827,7 +27818,7 @@ index 2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d..41816ca8d4ef3d959d2b88cd4b2eedaa public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) { super(level, gameProfile); this.server = server; -@@ -471,7 +501,7 @@ public class ServerPlayer extends Player { +@@ -452,7 +482,7 @@ public class ServerPlayer extends Player { @Override public BlockPos adjustSpawnLocation(final ServerLevel level, final BlockPos spawnSuggestion) { CompletableFuture future = PlayerSpawnFinder.findSpawn(level, spawnSuggestion); @@ -27837,7 +27828,7 @@ index 2ffb9c7388e15ec3e3afd3fa50cc0149c0c8910d..41816ca8d4ef3d959d2b88cd4b2eedaa } diff --git a/net/minecraft/server/level/ThreadedLevelLightEngine.java b/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 46ce24ea601b1525834c1165075fc89d7ed8c69b..c050f208f485f67061fe5bf617915cd83860e5f3 100644 +index 9579dd385417752b07c2ad8d074025f9143bfe85..948a8a2b38d8ba3a2ea61cb2c85c3039bb938f2d 100644 --- a/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -23,15 +23,144 @@ import net.minecraft.world.level.lighting.LevelLightEngine; @@ -28187,7 +28178,7 @@ index 46ce24ea601b1525834c1165075fc89d7ed8c69b..c050f208f485f67061fe5bf617915cd8 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - private static enum TaskType { + private enum TaskType { diff --git a/net/minecraft/server/level/Ticket.java b/net/minecraft/server/level/Ticket.java index 40f97e3657a1672d3865ab915c7f36d3dbf88c6e..b075d7f68a263422cfa1f35b1f896038d3c712dd 100644 --- a/net/minecraft/server/level/Ticket.java @@ -28399,7 +28390,7 @@ index 4de90a597bd5c5ac639fd228b3494e70a945d7ff..147cd0458d719be6679b6bac2b6617b4 return this == PLUGIN ? PLUGIN_TYPE_TIMEOUT : this.timeout; } diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java -index 690bb45bc91e4ca76754ca8f125c844a54484caf..f288ac0ddc60841ea263c74e15a2060e070c84a0 100644 +index f4a426af2e638b79b783f5181da665d4e0552949..692f8684b9bccd76ab03edbc2ef31149d8a67cc8 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java @@ -76,6 +76,36 @@ public class WorldGenRegion implements WorldGenLevel { @@ -28453,36 +28444,36 @@ index c974b6cafb1f6aa2a57cfdc8a39c887f02f42b1d..ec40f02032f965f548b0c0a29aa9d9bb // Paper start - PlayerChunkLoadEvent if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { diff --git a/net/minecraft/server/network/config/PrepareSpawnTask.java b/net/minecraft/server/network/config/PrepareSpawnTask.java -index 83af9ee3ba150da85b9b694cd76a5fabb5b2d8ef..1fb40837bd02672850ec9adc2797190df22b33fc 100644 +index 5576bfd83e101aa81b6f79f7144be69f2fbfda08..f087b290ffbb2cd719b68de98b5381b789f442df 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -171,7 +171,7 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -165,7 +165,7 @@ public class PrepareSpawnTask implements ConfigurationTask { + private Vec2 spawnAngle; // Paper - remove final + private @Nullable CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture eventFuture; // Paper +- private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); ++ private final ChunkLoadCounter chunkLoadCounter = new ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter(); // Paper - rewrite chunk system + private Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { - Objects.requireNonNull(PrepareSpawnTask.this); - super(); -- this.chunkLoadCounter = new ChunkLoadCounter(); -+ this.chunkLoadCounter = new ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter(); // Paper - rewrite chunk system this.spawnLevel = spawnLevel; - this.spawnPosition = spawnPosition; - this.spawnAngle = spawnAngle; -@@ -236,11 +236,7 @@ public class PrepareSpawnTask implements ConfigurationTask { - } - // Paper end - PlayerSpawnLocationEvent - ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition)); -- this.chunkLoadCounter -- .track( -- this.spawnLevel, -- () -> this.chunkLoadFuture = this.spawnLevel.getChunkSource().addTicketAndLoadWithRadius(TicketType.PLAYER_SPAWN, spawnChunk, 3) -- ); -+ this.chunkLoadFuture = ((ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter)this.chunkLoadCounter).trackLoadWithRadius(this.spawnLevel, spawnChunk, 3, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, ca.spottedleaf.concurrentutil.util.Priority.HIGH, () -> { Preparing.this.spawnLevel.getChunkSource().addTicketWithRadius(TicketType.PLAYER_SPAWN, spawnChunk, 3); }); // Paper - rewrite chunk system - PrepareSpawnTask.this.loadListener.start(LevelLoadListener.Stage.LOAD_PLAYER_CHUNKS, this.chunkLoadCounter.totalChunks()); - PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), spawnChunk); +@@ -233,11 +233,7 @@ public class PrepareSpawnTask implements ConfigurationTask { } + // Paper end - PlayerSpawnLocationEvent + ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition)); +- this.chunkLoadCounter +- .track( +- this.spawnLevel, +- () -> this.chunkLoadFuture = this.spawnLevel.getChunkSource().addTicketAndLoadWithRadius(TicketType.PLAYER_SPAWN, spawnChunk, 3) +- ); ++ this.chunkLoadFuture = ((ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter)this.chunkLoadCounter).trackLoadWithRadius(this.spawnLevel, spawnChunk, 3, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, ca.spottedleaf.concurrentutil.util.Priority.HIGH, () -> { Preparing.this.spawnLevel.getChunkSource().addTicketWithRadius(TicketType.PLAYER_SPAWN, spawnChunk, 3); }); // Paper - rewrite chunk system + PrepareSpawnTask.this.loadListener.start(LevelLoadListener.Stage.LOAD_PLAYER_CHUNKS, this.chunkLoadCounter.totalChunks()); + PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), spawnChunk); + } diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index eff42b94fd182abace988d9649952e04dc35b268..02605ebe6ef10727badadbf7fc4cec52583df965 100644 +index 581ea052c288ea9d0c40878c38c1506699b75d62..8feac5ea25620b765a4f1e7b1aab00034d860f34 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -982,8 +982,8 @@ public abstract class PlayerList { +@@ -981,8 +981,8 @@ public abstract class PlayerList { player.connection.send(level.clockManager().createFullSyncPacket(player)); // Paper - per-world time; per-player time player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); // Paper start - view distances @@ -28493,7 +28484,7 @@ index eff42b94fd182abace988d9649952e04dc35b268..02605ebe6ef10727badadbf7fc4cec52 // Paper end - view distances if (level.isRaining()) { // CraftBukkit start - handle player weather -@@ -1200,7 +1200,7 @@ public abstract class PlayerList { +@@ -1199,7 +1199,7 @@ public abstract class PlayerList { public void setViewDistance(final int viewDistance) { this.viewDistance = viewDistance; @@ -28502,7 +28493,7 @@ index eff42b94fd182abace988d9649952e04dc35b268..02605ebe6ef10727badadbf7fc4cec52 for (ServerLevel level : this.server.getAllLevels()) { level.getChunkSource().setViewDistance(viewDistance); -@@ -1209,7 +1209,7 @@ public abstract class PlayerList { +@@ -1208,7 +1208,7 @@ public abstract class PlayerList { public void setSimulationDistance(final int simulationDistance) { this.simulationDistance = simulationDistance; @@ -28548,7 +28539,7 @@ index a7fb2632bd55ed422dea2a559272645c5b422cc1..48f6671ecabfd5a8c9f8151ccb59f9ea + // Paper end - block counting } diff --git a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java -index 8df91fc917c22f3b633fe6df2f5311151c1cc54e..8cfb6a17b10130b5ad809698f5b021096e20dca8 100644 +index 1086960c32e4b02d06a09ec8ebc80444c8c4b6cd..444aa788b4f8265fb675230000e606d746aeed42 100644 --- a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java +++ b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java @@ -7,7 +7,7 @@ import java.util.Iterator; @@ -28591,7 +28582,7 @@ index 8df91fc917c22f3b633fe6df2f5311151c1cc54e..8cfb6a17b10130b5ad809698f5b02109 public void addMapping(final K key, final int id) { diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java -index cd9b408afdabb632ceba265c8de6035e1276024f..5e0e33cdbd590e5aee8044f49a562434c230a426 100644 +index 74dcdbb1f701c600cb5aca247a5a832fd05d7f03..851363603a3f8180f841c6f1b08dbac2db70f97a 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java @@ -208,6 +208,20 @@ public class SimpleBitStorage implements BitStorage { @@ -28764,11 +28755,11 @@ index cd9b408afdabb632ceba265c8de6035e1276024f..5e0e33cdbd590e5aee8044f49a562434 private InitializationException(final String message) { super(message); diff --git a/net/minecraft/util/SortedArraySet.java b/net/minecraft/util/SortedArraySet.java -index b36eda8e0176ec52eff318d868b7a4cc39d93759..f996f95f42f8afabcfdaffccc61bd3906a63e604 100644 +index c08c8388b6a81f861caf6716c0c999205e1ae487..295b29ba4e46aa438813180802e6c452392c7109 100644 --- a/net/minecraft/util/SortedArraySet.java +++ b/net/minecraft/util/SortedArraySet.java -@@ -9,12 +9,88 @@ import java.util.NoSuchElementException; - import java.util.Objects; +@@ -8,12 +8,88 @@ import java.util.Iterator; + import java.util.NoSuchElementException; import org.jspecify.annotations.Nullable; -public class SortedArraySet extends AbstractSet { @@ -28858,7 +28849,7 @@ index b36eda8e0176ec52eff318d868b7a4cc39d93759..f996f95f42f8afabcfdaffccc61bd390 this.comparator = comparator; if (initialCapacity < 0) { diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java -index 1ceb7e4a3abd4d9de5133d182d3267d2164918f6..eb2fa32cff6824c14f865c8731df7d082122f62b 100644 +index 09b6da207530987b483444cebeadc2f1c9a15247..3666c3efd188508153b6482db425648e3ca77dc7 100644 --- a/net/minecraft/util/ZeroBitStorage.java +++ b/net/minecraft/util/ZeroBitStorage.java @@ -62,4 +62,22 @@ public class ZeroBitStorage implements BitStorage { @@ -28885,7 +28876,7 @@ index 1ceb7e4a3abd4d9de5133d182d3267d2164918f6..eb2fa32cff6824c14f865c8731df7d08 + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4e81a3d3a 100644 +index 8f09dac837a0af6aabba1b312bb0c8520647ec3b..593265d78564b60bacbb4899f18a6e74bf56601d 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -167,7 +167,7 @@ public abstract class Entity @@ -29236,25 +29227,24 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 } private static float[] collectCandidateStepUpHeights( -@@ -2738,21 +2886,110 @@ public abstract class Entity +@@ -2737,21 +2885,110 @@ public abstract class Entity } public boolean isInWall() { + // Paper start - optimise collisions if (this.noPhysics) { return false; -- } else { -- float checkWidth = this.dimensions.width() * 0.8F; -- AABB eyeBb = AABB.ofSize(this.getEyePosition(), checkWidth, 1.0E-6, checkWidth); -- return BlockPos.betweenClosedStream(eyeBb) -- .anyMatch( -- pos -> { -- BlockState state = this.level().getBlockState(pos); -- return !state.isAir() -- && state.isSuffocating(this.level(), pos) -- && Shapes.joinIsNotEmpty(state.getCollisionShape(this.level(), pos).move(pos), Shapes.create(eyeBb), BooleanOp.AND); -+ } -+ + } + +- float checkWidth = this.dimensions.width() * 0.8F; +- AABB eyeBb = AABB.ofSize(this.getEyePosition(), checkWidth, 1.0E-6, checkWidth); +- return BlockPos.betweenClosedStream(eyeBb) +- .anyMatch( +- pos -> { +- BlockState state = this.level().getBlockState(pos); +- return !state.isAir() +- && state.isSuffocating(this.level(), pos) +- && Shapes.joinIsNotEmpty(state.getCollisionShape(this.level(), pos).move(pos), Shapes.create(eyeBb), BooleanOp.AND); + final double reducedWith = (double)(this.dimensions.width() * 0.8F); + final AABB boundingBox = AABB.ofSize(this.getEyePosition(), reducedWith, 1.0E-6D, reducedWith); + final Level world = this.level; @@ -29291,8 +29281,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 + final int sectionIdx = currChunkY - minSection; + if (sectionIdx < 0 || sectionIdx >= sections.length) { + continue; - } -- ); ++ } + final net.minecraft.world.level.chunk.LevelChunkSection section = sections[sectionIdx]; + if (section.hasOnlyAir()) { + // empty @@ -29349,16 +29338,17 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 + } + } + } -+ } + } +- ); + } - } ++ } + + return false; + // Paper end - optimise collisions } public InteractionResult interact(final Player player, final InteractionHand hand, final Vec3 location) { -@@ -4363,15 +4600,17 @@ public abstract class Entity +@@ -4365,15 +4602,17 @@ public abstract class Entity } public Iterable getIndirectPassengers() { @@ -29384,7 +29374,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 } public int countPlayerPassengers() { -@@ -4682,6 +4921,15 @@ public abstract class Entity +@@ -4684,6 +4923,15 @@ public abstract class Entity } public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { @@ -29400,7 +29390,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 if (!checkPosition(this, x, y, z)) { return; } -@@ -4831,6 +5079,12 @@ public abstract class Entity +@@ -4833,6 +5081,12 @@ public abstract class Entity @Override public final void setRemoved(final Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause @@ -29413,7 +29403,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { -@@ -4841,7 +5095,7 @@ public abstract class Entity +@@ -4843,7 +5097,7 @@ public abstract class Entity this.stopRiding(); } @@ -29422,7 +29412,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 this.levelCallback.onRemove(reason); this.onRemoval(reason); // Paper start - Folia schedulers -@@ -4875,7 +5129,7 @@ public abstract class Entity +@@ -4877,7 +5131,7 @@ public abstract class Entity public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) && !this.isPassenger() @@ -29432,37 +29422,37 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4 @Override diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 3325e7d4827067a65b176c5ba01aa491abd222a5..a8f2b22436ff0f4bff06b2c5cf01375da755cfde 100644 +index 3e71b3d17ffa02ce82040958c83f419121a1830e..2940dbc31a20eb49e24418ec84b73f2bfbdcfc32 100644 --- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -88,12 +88,16 @@ public class AcquirePoi { - return true; - } - }; -- Set, BlockPos>> poiPositions = poiManager.findAllClosestFirstWithType( -- poiType, cacheTest, body.blockPosition(), SCAN_RANGE, PoiManager.Occupancy.HAS_SPACE -- ) -- .limit(5L) -- .filter(px -> validPoi.test(level, (BlockPos)px.getSecond())) -- .collect(Collectors.toSet()); -+ // Paper start - optimise POI searches -+ java.util.List, BlockPos>> poiPositionsRaw = new java.util.ArrayList<>(); -+ ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.findNearestPoiPositions(poiManager, poiType, cacheTest, body.blockPosition(), SCAN_RANGE, Double.MAX_VALUE, PoiManager.Occupancy.HAS_SPACE, ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.LOAD_FOR_SEARCHING, 5, poiPositionsRaw); -+ Set, BlockPos>> poiPositions = new java.util.HashSet<>(poiPositionsRaw.size()); -+ for (Pair, BlockPos> pair : poiPositionsRaw) { -+ if (validPoi.test(level, pair.getSecond())) { -+ poiPositions.add(pair); -+ } -+ } -+ // Paper end - optimise POI searches - Path path = findPathToPois(body, poiPositions); - if (path != null && path.canReach()) { - BlockPos targetPos = path.getTarget(); +@@ -94,12 +94,16 @@ public class AcquirePoi { + retryMarker.markAttempt(timestamp); + return true; + }; +- Set, BlockPos>> poiPositions = poiManager.findAllClosestFirstWithType( +- poiType, cacheTest, body.blockPosition(), SCAN_RANGE, PoiManager.Occupancy.HAS_SPACE +- ) +- .limit(5L) +- .filter(px -> validPoi.test(level, (BlockPos)px.getSecond())) +- .collect(Collectors.toSet()); ++ // Paper start - optimise POI searches ++ java.util.List, BlockPos>> poiPositionsRaw = new java.util.ArrayList<>(); ++ ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.findNearestPoiPositions(poiManager, poiType, cacheTest, body.blockPosition(), SCAN_RANGE, Double.MAX_VALUE, PoiManager.Occupancy.HAS_SPACE, ca.spottedleaf.moonrise.patches.poi_lookup.PoiAccess.LOAD_FOR_SEARCHING, 5, poiPositionsRaw); ++ Set, BlockPos>> poiPositions = new java.util.HashSet<>(poiPositionsRaw.size()); ++ for (Pair, BlockPos> pair : poiPositionsRaw) { ++ if (validPoi.test(level, pair.getSecond())) { ++ poiPositions.add(pair); ++ } ++ } ++ // Paper end - optimise POI searches + Path path = findPathToPois(body, poiPositions); + if (path != null && path.canReach()) { + BlockPos targetPos = path.getTarget(); diff --git a/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9dde64d339 100644 +index 96d28b513d39c4bc364d97bef7bd6024349c1bd9..a67c3ccfd24172df1bd2e440a48d7e5f262af82f 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -41,12 +41,137 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; +@@ -40,12 +40,137 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; import net.minecraft.world.level.chunk.storage.SimpleRegionStorage; import org.jspecify.annotations.Nullable; @@ -29601,7 +29591,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d public PoiManager( final RegionStorageInfo info, final Path folder, -@@ -67,6 +192,7 @@ public class PoiManager extends SectionStorage { +@@ -66,6 +191,7 @@ public class PoiManager extends SectionStorage { levelHeightAccessor ); this.distanceTracker = new PoiManager.DistanceTracker(); @@ -29609,7 +29599,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public @Nullable PoiRecord add(final BlockPos pos, final Holder type) { -@@ -88,18 +214,29 @@ public class PoiManager extends SectionStorage { +@@ -87,18 +213,29 @@ public class PoiManager extends SectionStorage { public Stream getInSquare( final Predicate> predicate, final BlockPos center, final int radius, final PoiManager.Occupancy occupancy ) { @@ -29646,7 +29636,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } @VisibleForDebug -@@ -118,7 +255,15 @@ public class PoiManager extends SectionStorage { +@@ -117,7 +254,15 @@ public class PoiManager extends SectionStorage { final int radius, final PoiManager.Occupancy occupancy ) { @@ -29663,7 +29653,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public Stream, BlockPos>> findAllWithType( -@@ -128,7 +273,17 @@ public class PoiManager extends SectionStorage { +@@ -127,7 +272,17 @@ public class PoiManager extends SectionStorage { final int radius, final PoiManager.Occupancy occupancy ) { @@ -29682,7 +29672,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public Stream, BlockPos>> findAllClosestFirstWithType( -@@ -138,7 +293,21 @@ public class PoiManager extends SectionStorage { +@@ -137,7 +292,21 @@ public class PoiManager extends SectionStorage { final int radius, final PoiManager.Occupancy occupancy ) { @@ -29705,7 +29695,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public Optional find( -@@ -148,21 +317,31 @@ public class PoiManager extends SectionStorage { +@@ -147,21 +316,31 @@ public class PoiManager extends SectionStorage { final int radius, final PoiManager.Occupancy occupancy ) { @@ -29742,7 +29732,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public Optional findClosest( -@@ -172,22 +351,29 @@ public class PoiManager extends SectionStorage { +@@ -171,22 +350,29 @@ public class PoiManager extends SectionStorage { final int radius, final PoiManager.Occupancy occupancy ) { @@ -29783,7 +29773,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public Optional getRandom( -@@ -198,8 +384,21 @@ public class PoiManager extends SectionStorage { +@@ -197,8 +383,21 @@ public class PoiManager extends SectionStorage { final int radius, final RandomSource random ) { @@ -29807,7 +29797,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public boolean release(final BlockPos pos) { -@@ -222,8 +421,10 @@ public class PoiManager extends SectionStorage { +@@ -221,8 +420,10 @@ public class PoiManager extends SectionStorage { } public int sectionsToVillage(final SectionPos sectionPos) { @@ -29820,7 +29810,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } private boolean isVillageCenter(final long sectionPos) { -@@ -234,19 +435,26 @@ public class PoiManager extends SectionStorage { +@@ -233,19 +434,26 @@ public class PoiManager extends SectionStorage { @Override public void tick(final BooleanSupplier haveTime) { @@ -29853,7 +29843,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } public void checkConsistencyWithBlocks(final SectionPos sectionPos, final LevelChunkSection blockSection) { -@@ -285,7 +493,7 @@ public class PoiManager extends SectionStorage { +@@ -284,7 +492,7 @@ public class PoiManager extends SectionStorage { .map(pos -> Pair.of(pos, this.getOrLoad(pos.asLong()))) .filter(poiSection -> !poiSection.getSecond().map(PoiSection::isValid).orElse(false)) .map(p -> p.getFirst().chunk()) @@ -29863,7 +29853,7 @@ index a6f79e022af17de6e58e9a80805b607d674c6b85..ab92bb9a3c5c1900e5d77fd3885e2c9d } diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 9423fab0cefba9c1d48ab5e8f39fe91c1c3a2022..e9fd001d96ba9f80e5131a940c46562f896dac41 100644 +index cf03617840bf13c6045526eba14f71e0647ffec2..263c64f340417c0b49691a350b4bec592d58739d 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiSection.java @@ -25,13 +25,27 @@ import net.minecraft.util.debug.DebugPoiInfo; @@ -29897,7 +29887,7 @@ index 9423fab0cefba9c1d48ab5e8f39fe91c1c3a2022..e9fd001d96ba9f80e5131a940c46562f this(setDirty, true, ImmutableList.of()); } diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index b9cd4bdd48d3c9fc96838d051d18d1c264b25fee..fc4fce0b1d57a62c1e5c80a5b91c2b1a77d4bace 100644 +index 758b667530ba1e14e9a56fbe609a6438439dd8f2..f42fd10847a1dfbcbb2790aa90da4a49585e25a8 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -206,7 +206,7 @@ public class ArmorStand extends LivingEntity { @@ -29910,7 +29900,7 @@ index b9cd4bdd48d3c9fc96838d051d18d1c264b25fee..fc4fce0b1d57a62c1e5c80a5b91c2b1a entity.push(this); } diff --git a/net/minecraft/world/level/ClipContext.java b/net/minecraft/world/level/ClipContext.java -index 53dc55780adc88e4857cd1fe72c81535f5e0fd26..35cf8c2caf8b17d233d77b4baa1ea161f0bbfefa 100644 +index fbaefb396745cc985d4c25f3cbea17d646391948..fc7900fcb391b6fe61f7d6200f7d2656579b97a1 100644 --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java @@ -22,7 +22,7 @@ public class ClipContext { @@ -29923,7 +29913,7 @@ index 53dc55780adc88e4857cd1fe72c81535f5e0fd26..35cf8c2caf8b17d233d77b4baa1ea161 public ClipContext(final Vec3 from, final Vec3 to, final ClipContext.Block block, final ClipContext.Fluid fluid, final Entity entity) { diff --git a/net/minecraft/world/level/EntityGetter.java b/net/minecraft/world/level/EntityGetter.java -index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b7ef53424 100644 +index 892b338a2b0a185511c352ca2bb76ee3890836fd..f84e651e2a34e76a0a71993332e4be1b7ef53424 100644 --- a/net/minecraft/world/level/EntityGetter.java +++ b/net/minecraft/world/level/EntityGetter.java @@ -15,7 +15,7 @@ import net.minecraft.world.phys.shapes.Shapes; @@ -29950,15 +29940,14 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b + // Paper start - optimise collisions if (shape.isEmpty()) { return true; -- } else { -- for (Entity entity : this.getEntities(source, shape.bounds())) { -- if (!entity.isRemoved() -- && entity.blocksBuilding -- && (source == null || !entity.isPassengerOfSameVehicle(source)) -- && Shapes.joinIsNotEmpty(shape, Shapes.create(entity.getBoundingBox()), BooleanOp.AND)) { -- return false; -+ } -+ + } + +- for (Entity entity : this.getEntities(source, shape.bounds())) { +- if (!entity.isRemoved() +- && entity.blocksBuilding +- && (source == null || !entity.isPassengerOfSameVehicle(source)) +- && Shapes.joinIsNotEmpty(shape, Shapes.create(entity.getBoundingBox()), BooleanOp.AND)) { +- return false; + final AABB singleAABB = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape).moonrise$getSingleAABBRepresentation(); + final List entities = this.getEntities( + source, @@ -29976,14 +29965,13 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b + final AABB entityBB = otherEntity.getBoundingBox(); + if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isEmpty(entityBB) || !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.voxelShapeIntersectNoEmpty(shape, entityBB)) { + continue; - } ++ } } - -- return true; ++ + return false; } -+ -+ return true; + + return true; + // Paper end - optimise collisions } @@ -30000,8 +29988,12 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b + if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isEmpty(testArea)) { + // reduce indirection by always returning type with same class + return new java.util.ArrayList<>(); -+ } -+ + } + +- Predicate canCollide = source == null ? EntitySelector.CAN_BE_COLLIDED_WITH : EntitySelector.NO_SPECTATORS.and(source::canCollideWith); +- List collidingEntities = this.getEntities(source, testArea.inflate(1.0E-7), canCollide); +- if (collidingEntities.isEmpty()) { +- return List.of(); + // to comply with vanilla intersection rules, expand by -epsilon so that we only get stuff we definitely collide with. + // Vanilla for hard collisions has this backwards, and they expand by +epsilon but this causes terrible problems + // specifically with boat collisions. @@ -30010,42 +30002,35 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b + final List entities; + if (source != null && ((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)source).moonrise$isHardColliding()) { + entities = this.getEntities(source, testArea, null); - } else { -- Predicate canCollide = source == null ? EntitySelector.CAN_BE_COLLIDED_WITH : EntitySelector.NO_SPECTATORS.and(source::canCollideWith); -- List collidingEntities = this.getEntities(source, testArea.inflate(1.0E-7), canCollide); -- if (collidingEntities.isEmpty()) { -- return List.of(); -- } else { -- Builder shapes = ImmutableList.builderWithExpectedSize(collidingEntities.size()); -- -- for (Entity entity : collidingEntities) { -- shapes.add(Shapes.create(entity.getBoundingBox())); -- } ++ } else { + entities = ((ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter)this).moonrise$getHardCollidingEntities(source, testArea, null); -+ } + } -- return shapes.build(); +- Builder shapes = ImmutableList.builderWithExpectedSize(collidingEntities.size()); + final List ret = new java.util.ArrayList<>(Math.min(25, entities.size())); + + for (int i = 0, len = entities.size(); i < len; ++i) { + final Entity otherEntity = entities.get(i); -+ + +- for (Entity entity : collidingEntities) { +- shapes.add(Shapes.create(entity.getBoundingBox())); + if (otherEntity.isSpectator()) { + continue; + } + + if ((source == null && otherEntity.canBeCollidedWith(source)) || (source != null && source.canCollideWith(otherEntity))) { + ret.add(Shapes.create(otherEntity.getBoundingBox())); - } ++ } } -+ + +- return shapes.build(); + return ret; + // Paper end - optimise collisions } // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669b111f4c0 100644 +index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01646cf7b3 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -87,6 +87,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -30728,7 +30713,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 } // Paper start - Cancel hit for vanished players -@@ -512,7 +1146,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -514,7 +1148,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(pos, blockState, blockState1); } @@ -30737,7 +30722,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 this.sendBlockUpdated(pos, blockState, state, flags); } -@@ -846,6 +1480,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -848,6 +1482,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper - Fix MC-117075 use removeAll - remove iterator in favour of indexed for loop, ensuring compile error if something uses iter incorrectly boolean tickBlockEntities = this.tickRateManager().runsNormally(); @@ -30745,7 +30730,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 // Paper start - Fix MC-117075 use removeAll final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); toRemove.add(null); -@@ -856,6 +1491,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -858,6 +1493,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { toRemove.add(ticker); // Paper - Fix MC-117075 use removeAll } else if (tickBlockEntities && this.shouldTickBlocksAt(ticker.getPos())) { ticker.tick(); @@ -30757,7 +30742,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 } } -@@ -874,6 +1514,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -876,6 +1516,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -30765,7 +30750,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -881,7 +1522,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -883,7 +1524,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public boolean noCollision(@Nullable Entity entity, AABB box) { if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; @@ -30781,7 +30766,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -1026,7 +1674,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1028,7 +1676,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isInValidBounds(pos)) { return null; } else { @@ -30790,7 +30775,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1106,20 +1754,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1108,20 +1756,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(final @Nullable Entity except, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("getEntities"); @@ -30818,7 +30803,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 } @Override -@@ -1135,33 +1778,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1137,33 +1780,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(type, bb, selector, output, Integer.MAX_VALUE); } @@ -30933,7 +30918,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 public boolean hasEntities(final EntityTypeTest type, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("hasEntities"); -@@ -1466,13 +2170,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1472,13 +2176,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper start - allow patching this logic public final int getEntityCount() { @@ -30949,7 +30934,7 @@ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669 // Paper end - allow patching this logic } diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java -index 5ae72685665701905df6047ba76e39819d9af0c6..c0074df792f578a1fd828ace9f7a64caa25f3273 100644 +index 254a967292938a9ed6a0291bbc9cf6e971eeaf01..416646f15ceea04fbbb5a5b0044c2a4927a39ba2 100644 --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java @@ -23,7 +23,17 @@ import net.minecraft.world.level.levelgen.Heightmap; @@ -30972,7 +30957,7 @@ index 5ae72685665701905df6047ba76e39819d9af0c6..c0074df792f578a1fd828ace9f7a64ca @Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading) diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb2125bfff 100644 +index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9cbfcb43c 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -54,6 +54,249 @@ public class ServerExplosion implements Explosion { @@ -31225,7 +31210,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb public ServerExplosion( final ServerLevel level, -@@ -128,62 +371,102 @@ public class ServerExplosion implements Explosion { +@@ -128,64 +371,102 @@ public class ServerExplosion implements Explosion { } private List calculateExplodedPositions() { @@ -31247,8 +31232,9 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb - double xp = this.center.x; - double yp = this.center.y; - double zp = this.center.z; +- float stepSize = 0.3F; - -- for (float stepSize = 0.3F; remainingPower > 0.0F; remainingPower -= 0.22500001F) { +- while (remainingPower > 0.0F) { - BlockPos pos = BlockPos.containing(xp, yp, zp); - BlockState block = this.level.getBlockState(pos); - if (!block.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed @@ -31355,6 +31341,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb - xp += xd * 0.3F; - yp += yd * 0.3F; - zp += zd * 0.3F; +- remainingPower -= 0.22500001F; + // Paper end - prevent headless pistons from forming } } @@ -31374,7 +31361,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb } private void hurtEntities() { -@@ -340,6 +623,14 @@ public class ServerExplosion implements Explosion { +@@ -342,6 +623,14 @@ public class ServerExplosion implements Explosion { } public int explode() { @@ -31389,7 +31376,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List toBlow = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -354,6 +645,13 @@ public class ServerExplosion implements Explosion { +@@ -356,6 +645,13 @@ public class ServerExplosion implements Explosion { this.createFire(toBlow); } @@ -31403,7 +31390,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb return toBlow.size(); } -@@ -436,12 +734,12 @@ public class ServerExplosion implements Explosion { +@@ -438,12 +734,12 @@ public class ServerExplosion implements Explosion { // Paper start - Optimize explosions private float getBlockDensity(Vec3 vec3d, Entity entity) { if (!this.level.paperConfig().environment.optimizeExplosions) { @@ -31419,7 +31406,7 @@ index 0cf47956a699c679259a920572efd3bea2b19a61..0ef64fcf11d6cd0e25227fe6053ca8cb } diff --git a/net/minecraft/world/level/TicketStorage.java b/net/minecraft/world/level/TicketStorage.java -index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0fe712ca5 100644 +index 5d6e4e74483068bdf17ecf0623f0ae1dc9d2002c..d966a073ba74ff881941aba79d23d8135bac119b 100644 --- a/net/minecraft/world/level/TicketStorage.java +++ b/net/minecraft/world/level/TicketStorage.java @@ -30,7 +30,7 @@ import net.minecraft.world.level.saveddata.SavedDataType; @@ -31600,52 +31587,51 @@ index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0 - List tickets = this.tickets.get(key); - if (tickets == null) { - return false; -- } else { -- boolean found = false; -- Iterator iterator = tickets.iterator(); -- -- while (iterator.hasNext()) { -- Ticket t = iterator.next(); -- if (isTicketSameTypeAndLevel(ticket, t)) { -- iterator.remove(); -- if (SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { -- LOGGER.debug("RTI {} {}", ChunkPos.unpack(key), t); -- } -- -- found = true; -- break; -- } -- } -- -- if (!found) { -- return false; -- } else { -- if (tickets.isEmpty()) { -- this.tickets.remove(key); -- } +- } - -- if (ticket.getType().doesSimulate() && this.simulationChunkUpdatedListener != null) { -- this.simulationChunkUpdatedListener.update(key, getTicketLevelAt(tickets, true), false); -- } +- boolean found = false; +- Iterator iterator = tickets.iterator(); + // Paper start - rewrite chunk system + final boolean ret = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager + .removeTicketAtLevel(ticket.getType(), key, ticket.getTicketLevel(), ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket)ticket).moonrise$getIdentifier()); -- if (ticket.getType().doesLoad() && this.loadingChunkUpdatedListener != null) { -- this.loadingChunkUpdatedListener.update(key, getTicketLevelAt(tickets, false), false); -- } -- -- if (ticket.getType().equals(TicketType.FORCED)) { -- this.updateForcedChunks(); +- while (iterator.hasNext()) { +- Ticket t = iterator.next(); +- if (isTicketSameTypeAndLevel(ticket, t)) { +- iterator.remove(); +- if (SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { +- LOGGER.debug("RTI {} {}", ChunkPos.unpack(key), t); - } - -- this.setDirty(); -- return true; +- found = true; +- break; - } + if (ret) { + this.setDirty(); } -+ + +- if (!found) { +- return false; +- } +- +- if (tickets.isEmpty()) { +- this.tickets.remove(key); +- } +- +- if (ticket.getType().doesSimulate() && this.simulationChunkUpdatedListener != null) { +- this.simulationChunkUpdatedListener.update(key, getTicketLevelAt(tickets, true), false); +- } +- +- if (ticket.getType().doesLoad() && this.loadingChunkUpdatedListener != null) { +- this.loadingChunkUpdatedListener.update(key, getTicketLevelAt(tickets, false), false); +- } +- +- if (ticket.getType().equals(TicketType.FORCED)) { +- this.updateForcedChunks(); +- } +- +- this.setDirty(); +- return true; + return ret; + // Paper end - rewrite chunk system } @@ -31672,7 +31658,7 @@ index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0 this.setDirty(); } -@@ -300,82 +274,15 @@ public class TicketStorage extends SavedData { +@@ -302,82 +276,15 @@ public class TicketStorage extends SavedData { } public void deactivateTicketsOnClosing() { @@ -31749,28 +31735,28 @@ index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0 - - for (Pair pair : affectedTickets) { - Long key = pair.getSecond(); -- Ticket ticketx = pair.getFirst(); -- this.removeTicket(key, ticketx); -- TicketType type = ticketx.getType(); +- Ticket ticket = pair.getFirst(); +- this.removeTicket(key, ticket); +- TicketType type = ticket.getType(); - this.addTicket(key, new Ticket(type, newLevel)); - } + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } public boolean updateChunkForced(final ChunkPos chunkPos, final boolean forced) { -@@ -384,22 +291,29 @@ public class TicketStorage extends SavedData { +@@ -386,22 +293,29 @@ public class TicketStorage extends SavedData { } public LongSet getForceLoadedChunks() { - return this.chunksWithForcedTickets; - } +- +- private LongSet getAllChunksWithTicketThat(final Predicate ticketCheck) { +- LongOpenHashSet chunks = new LongOpenHashSet(); + // Paper start - rewrite chunk system + final ca.spottedleaf.concurrentutil.map.concurrent.longs.ConcurrentChainedLong2LongHashTable forced = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler() + .chunkHolderManager.getTicketCounters(ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType.COUNTER_TYPE_FORCED); -- private LongSet getAllChunksWithTicketThat(final Predicate ticketCheck) { -- LongOpenHashSet chunks = new LongOpenHashSet(); -- - for (Entry> entry : Long2ObjectMaps.fastIterable(this.tickets)) { - for (Ticket ticket : entry.getValue()) { - if (ticketCheck.test(ticket)) { @@ -31801,7 +31787,7 @@ index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0 } @FunctionalInterface -@@ -423,7 +337,7 @@ public class TicketStorage extends SavedData { +@@ -425,7 +339,7 @@ public class TicketStorage extends SavedData { } public void removeAllPluginRegionTickets(TicketType ticketType, int ticketLevel, org.bukkit.plugin.Plugin ticketIdentifier) { @@ -31811,10 +31797,10 @@ index 312d2eeda6b413d3b2d10ee58bd154bbddc88451..3d2fc3809ec8a1d8bda47da4fd631bb0 // Paper end } diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java -index 7645e677e331f6aea404fb5ae1264690ffb1d212..96f2e3359774460091177068302ff0faf4671373 100644 +index fbb3ad54acb170f3a4b8ec4ed931bd60ad0ab55d..afa97f1c8a0fcd49aec962eaa6f5c9cda0e0cefa 100644 --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -128,20 +128,7 @@ public final class Biome { +@@ -123,20 +123,7 @@ public final class Biome { @Deprecated public float getTemperature(final BlockPos pos, final int seaLevel) { @@ -31823,24 +31809,24 @@ index 7645e677e331f6aea404fb5ae1264690ffb1d212..96f2e3359774460091177068302ff0fa - float cached = cache.get(key); - if (!Float.isNaN(cached)) { - return cached; -- } else { -- float temp = this.getHeightAdjustedTemperature(pos, seaLevel); -- if (cache.size() == 1024) { -- cache.removeFirstFloat(); -- } +- } - -- cache.put(key, temp); -- return temp; +- float temp = this.getHeightAdjustedTemperature(pos, seaLevel); +- if (cache.size() == 1024) { +- cache.removeFirstFloat(); - } +- +- cache.put(key, temp); +- return temp; + return this.getHeightAdjustedTemperature(pos, seaLevel); // Paper - optimise random ticking } public boolean shouldFreeze(final LevelReader level, final BlockPos pos) { diff --git a/net/minecraft/world/level/biome/BiomeManager.java b/net/minecraft/world/level/biome/BiomeManager.java -index 9404f0b0b03dce54e2c9ad6ca2c36354888cc9f5..a0d7f6f8ecbc320267bdad27315fc2e2e1ff3702 100644 +index d9849dfbe792128390941403220110fe87eb9fe3..c139f70bf9ddd3f995c0524dad15487e632cd432 100644 --- a/net/minecraft/world/level/biome/BiomeManager.java +++ b/net/minecraft/world/level/biome/BiomeManager.java -@@ -100,8 +100,7 @@ public class BiomeManager { +@@ -101,8 +101,7 @@ public class BiomeManager { } private static double getFiddle(final long rval) { @@ -31851,10 +31837,10 @@ index 9404f0b0b03dce54e2c9ad6ca2c36354888cc9f5..a0d7f6f8ecbc320267bdad27315fc2e2 public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 7678701a578d2dc45b35da072a0bb2c027522043..41aab9a526be77b400bed7a74614eceec95345b5 100644 +index 991d6261fd8a19d1c367e518666acb298dbd7abe..a8625939a4220050990b09097d5e3bfd2d8473d5 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -366,7 +366,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -370,7 +370,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public static boolean isShapeFullBlock(final VoxelShape shape) { @@ -31864,7 +31850,7 @@ index 7678701a578d2dc45b35da072a0bb2c027522043..41aab9a526be77b400bed7a74614ecee public void animateTick(final BlockState state, final Level level, final BlockPos pos, final RandomSource random) { diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index e66b04c89c5155f660e3274ebb205cfb72190b1b..ca77680b645c352456744b148e0ff4ac31b05aa2 100644 +index 2004f5479f78f41c5af31f87f54c6529091f5cab..7093613a09a79d7ffce34f1cb54ec2605c5af384 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -435,7 +435,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -31953,7 +31939,7 @@ index e66b04c89c5155f660e3274ebb205cfb72190b1b..ca77680b645c352456744b148e0ff4ac protected BlockStateBase(final Block owner, final Property[] propertyKeys, final Comparable[] propertyValues) { super(owner, propertyKeys, propertyValues); BlockBehaviour.Properties properties = owner.properties; -@@ -547,6 +617,41 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -551,6 +621,41 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightDampening = this.owner.getLightDampening(this.asState()); @@ -31996,7 +31982,7 @@ index e66b04c89c5155f660e3274ebb205cfb72190b1b..ca77680b645c352456744b148e0ff4ac public Block getBlock() { diff --git a/net/minecraft/world/level/block/state/StateDefinition.java b/net/minecraft/world/level/block/state/StateDefinition.java -index 792f3016554dbb69ca1c67c03ea59fa2351e3db5..c9d21990d1506087b7f7dbbfcf4127c4c99d14d2 100644 +index e6953b5371aa94be4173857d5bae48c41cec6b7c..a93b55f5543d3624c39a4335c52e025e5675fa14 100644 --- a/net/minecraft/world/level/block/state/StateDefinition.java +++ b/net/minecraft/world/level/block/state/StateDefinition.java @@ -66,10 +66,19 @@ public class StateDefinition> { @@ -32020,7 +32006,7 @@ index 792f3016554dbb69ca1c67c03ea59fa2351e3db5..c9d21990d1506087b7f7dbbfcf4127c4 } private static > ImmutableList createSinglePropertyStates( -@@ -99,7 +108,7 @@ public class StateDefinition> { +@@ -97,7 +106,7 @@ public class StateDefinition> { blockState.initializeNeighbors(neighbours); } @@ -32029,7 +32015,7 @@ index 792f3016554dbb69ca1c67c03ea59fa2351e3db5..c9d21990d1506087b7f7dbbfcf4127c4 } private static > ImmutableList createMultiPropertyStates( -@@ -125,7 +134,7 @@ public class StateDefinition> { +@@ -123,7 +132,7 @@ public class StateDefinition> { StateDefinition.StateCollection stateCollection = new StateDefinition.StateCollection<>(statesByValues, new HashMap<>()); statesByValues.forEach((valuesx, state) -> state.initializeNeighbors(stateCollection.fillNeighborsForState(propertyKeys, valuesx))); @@ -32039,10 +32025,10 @@ index 792f3016554dbb69ca1c67c03ea59fa2351e3db5..c9d21990d1506087b7f7dbbfcf4127c4 private static > S[][] emptyNeighbors() { diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java -index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2c484f22d 100644 +index 747dd6f962fd42a08ed32ab23790477e0844592b..47a4aa4a45978dfec52ea995d197022f4fe32808 100644 --- a/net/minecraft/world/level/block/state/StateHolder.java +++ b/net/minecraft/world/level/block/state/StateHolder.java -@@ -13,21 +13,49 @@ import java.util.stream.Stream; +@@ -13,20 +13,48 @@ import java.util.stream.Stream; import net.minecraft.world.level.block.state.properties.Property; import org.jspecify.annotations.Nullable; @@ -32083,7 +32069,6 @@ index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2 + protected StateHolder(final O owner, final Property[] propertyKeys, final Comparable[] propertyValues) { assert propertyKeys.length == propertyValues.length; - this.owner = owner; this.propertyKeys = propertyKeys; this.propertyValues = propertyValues; @@ -32095,7 +32080,7 @@ index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2 } public > S cycle(final Property property) { -@@ -63,7 +91,7 @@ public abstract class StateHolder { +@@ -62,7 +90,7 @@ public abstract class StateHolder { } public Collection> getProperties() { @@ -32104,7 +32089,7 @@ index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2 } private int valueIndex(final Property property) { -@@ -77,21 +105,21 @@ public abstract class StateHolder { +@@ -76,21 +104,21 @@ public abstract class StateHolder { } public boolean hasProperty(final Property property) { @@ -32134,7 +32119,7 @@ index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2 } public > Optional getOptionalValue(final Property property) { -@@ -103,17 +131,26 @@ public abstract class StateHolder { +@@ -102,17 +130,26 @@ public abstract class StateHolder { } public , V extends T> S setValue(final Property property, final V value) { @@ -32168,7 +32153,7 @@ index 7d0d5e8e6c951be025183f7b1712d34aeb48b110..b72861c0164ebb13b6fc3e78cd7ce0a2 } private , V extends T> S setValueInternal(final Property property, final int propertyIndex, final V value) { -@@ -134,12 +171,15 @@ public abstract class StateHolder { +@@ -133,12 +170,15 @@ public abstract class StateHolder { } public boolean isSingletonState() { @@ -32217,7 +32202,7 @@ index 87b922c2aa4ef44a2a3469314f599dd63ee97baa..eac3775777060809b0e2ed118c12e647 @Override diff --git a/net/minecraft/world/level/block/state/properties/EnumProperty.java b/net/minecraft/world/level/block/state/properties/EnumProperty.java -index b718c4f81740b34e4321654d26e45f4c5bdb2450..09ccb96400aa25bd7fbcc1564fcc9b2b0e518bd6 100644 +index d00bb7c0e2dcfa75a2a62ad99bb843d9fc24e49c..665915290911a2a9390062c109103d9a1a6e4bde 100644 --- a/net/minecraft/world/level/block/state/properties/EnumProperty.java +++ b/net/minecraft/world/level/block/state/properties/EnumProperty.java @@ -10,11 +10,39 @@ import java.util.function.Predicate; @@ -32262,15 +32247,15 @@ index b718c4f81740b34e4321654d26e45f4c5bdb2450..09ccb96400aa25bd7fbcc1564fcc9b2b super(name, clazz); if (values.isEmpty()) { @@ -37,6 +65,7 @@ public final class EnumProperty & StringRepresentable> extends - - this.names = names.buildOrThrow(); } + + this.names = names.buildOrThrow(); + this.init(); // Paper - optimise blockstate property access } @Override diff --git a/net/minecraft/world/level/block/state/properties/IntegerProperty.java b/net/minecraft/world/level/block/state/properties/IntegerProperty.java -index f837d8029127e74f7181aa183e341a47ee8125a9..b0f90ce47b60cc775cece33ec7d2d30101574b16 100644 +index 1338213c0c918301a8fbc232b25d55804bda9cf9..954e61059e07bf4bc36270d64c6aa513ecbabc26 100644 --- a/net/minecraft/world/level/block/state/properties/IntegerProperty.java +++ b/net/minecraft/world/level/block/state/properties/IntegerProperty.java @@ -5,11 +5,33 @@ import java.util.List; @@ -32308,16 +32293,16 @@ index f837d8029127e74f7181aa183e341a47ee8125a9..b0f90ce47b60cc775cece33ec7d2d301 private IntegerProperty(final String name, final int min, final int max) { super(name, Integer.class); if (min < 0) { -@@ -21,6 +43,7 @@ public final class IntegerProperty extends Property { - this.max = max; - this.values = IntImmutableList.toList(IntStream.range(min, max + 1)); - } +@@ -23,6 +45,7 @@ public final class IntegerProperty extends Property { + this.min = min; + this.max = max; + this.values = IntImmutableList.toList(IntStream.range(min, max + 1)); + this.init(); // Paper - optimise blockstate property access } @Override diff --git a/net/minecraft/world/level/block/state/properties/Property.java b/net/minecraft/world/level/block/state/properties/Property.java -index 8970be0f45631e0710ccfbf45a25caf7717d0988..22d309410f5752a5f6b356e4f5cbda86444423f6 100644 +index b95665559d646ab8de313a19dadc197a1e8be02c..b82b935272efbc7a7518e148f665f4f24fa96814 100644 --- a/net/minecraft/world/level/block/state/properties/Property.java +++ b/net/minecraft/world/level/block/state/properties/Property.java @@ -10,7 +10,7 @@ import java.util.stream.Stream; @@ -32369,7 +32354,7 @@ index 8970be0f45631e0710ccfbf45a25caf7717d0988..22d309410f5752a5f6b356e4f5cbda86 public Property.Value value(final T value) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index 28a0f11af688c8bca4b1132b4de2977ee32e19db..c974b1c276d29610cb59566afaad19f5bcf0c602 100644 +index b23c29459a59c136ccd2f8d6bde5464c94206792..c974b1c276d29610cb59566afaad19f5bcf0c602 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -57,7 +57,7 @@ import net.minecraft.world.ticks.TickContainerAccess; @@ -32484,8 +32469,8 @@ index 28a0f11af688c8bca4b1132b4de2977ee32e19db..c974b1c276d29610cb59566afaad19f5 - int clampedQuartY = Mth.clamp(quartY, quartMinY, quartMaxY); - int sectionIndex = this.getSectionIndex(QuartPos.toBlock(clampedQuartY)); - return this.sections[sectionIndex].getNoiseBiome(quartX & 3, clampedQuartY & 3, quartZ & 3); -- } catch (Throwable var8) { -- CrashReport report = CrashReport.forThrowable(var8, "Getting biome"); +- } catch (Throwable t) { +- CrashReport report = CrashReport.forThrowable(t, "Getting biome"); - CrashReportCategory category = report.addCategory("Biome being got"); - category.setDetail("Location", () -> CrashReportCategory.formatLocation(this, quartX, quartY, quartZ)); - throw new ReportedException(report); @@ -32524,7 +32509,7 @@ index 28a0f11af688c8bca4b1132b4de2977ee32e19db..c974b1c276d29610cb59566afaad19f5 public static ProblemReporter.PathElement problemPath(final ChunkPos pos) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index 1b0eb74970c4d89ce8de4ca7bb86d420e396540d..a5d61f84dbf2937162abdfc1692f0848b971a4ce 100644 +index 36451b4c17d833b32c36383f8f2dfd2d267d6cc0..07b5bebadfe3eb6704a19cdd8093b40e613ea4c3 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -119,7 +119,7 @@ public abstract class ChunkGenerator { @@ -32536,7 +32521,7 @@ index 1b0eb74970c4d89ce8de4ca7bb86d420e396540d..a5d61f84dbf2937162abdfc1692f0848 } public abstract void applyCarvers( -@@ -316,7 +316,7 @@ public abstract class ChunkGenerator { +@@ -314,7 +314,7 @@ public abstract class ChunkGenerator { return Pair.of(config.getLocatePos(chunkTarget), structure); } @@ -32685,10 +32670,10 @@ index 54d57f80b1cca351cac2aa59477a0e57334816e7..94652b00e18ffcbe02f1ad0578d671e2 public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { return this.wrapped.getBlockEntity(pos); diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d40d82229e 100644 +index cd190763d1d0ee5ecb92a2aa614a0e550147cb4b..536c24ec46bdf571637376728aee06755a6256ef 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -64,7 +64,7 @@ import net.minecraft.world.ticks.TickContainerAccess; +@@ -63,7 +63,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -32697,7 +32682,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 private static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -103,6 +103,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -102,6 +102,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // Paper start boolean loadedTicketLevel; // Paper end @@ -32737,7 +32722,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 public LevelChunk(final Level level, final ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -132,6 +165,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -131,6 +164,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.postLoad = postLoad; this.blockTicks = blockTicks; this.fluidTicks = fluidTicks; @@ -32752,7 +32737,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 } public LevelChunk(final ServerLevel level, final ProtoChunk protoChunk, final LevelChunk.@Nullable PostLoadProcessor postLoad) { -@@ -169,13 +210,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -168,13 +209,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } } @@ -32773,16 +32758,16 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 } public void setUnsavedListener(final LevelChunk.UnsavedListener unsavedListener) { -@@ -346,7 +393,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { - if (LightEngine.hasDifferentLightProperties(oldState, state)) { - ProfilerFiller profiler = Profiler.get(); - profiler.push("updateSkyLightSources"); -- this.skyLightSources.update(this, localX, y, localZ); -+ // Paper - rewrite chunk system - profiler.popPush("queueCheckLight"); - this.level.getChunkSource().getLightEngine().checkBlock(pos); - profiler.pop(); -@@ -584,11 +631,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -347,7 +394,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { + if (LightEngine.hasDifferentLightProperties(oldState, state)) { + ProfilerFiller profiler = Profiler.get(); + profiler.push("updateSkyLightSources"); +- this.skyLightSources.update(this, localX, y, localZ); ++ // Paper - rewrite chunk system + profiler.popPush("queueCheckLight"); + this.level.getChunkSource().getLightEngine().checkBlock(pos); + profiler.pop(); +@@ -583,11 +630,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // CraftBukkit start public void loadCallback() { @@ -32796,7 +32781,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -597,6 +645,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -596,6 +644,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { */ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration)); @@ -32804,7 +32789,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 if (this.needsDecoration) { this.needsDecoration = false; -@@ -623,13 +672,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -622,13 +671,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } public void unloadCallback() { @@ -32822,7 +32807,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 // Paper start this.loadedTicketLevel = false; // Paper end -@@ -637,8 +688,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -636,8 +687,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { @Override public boolean isUnsaved() { @@ -32855,7 +32840,7 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 // CraftBukkit end public boolean isEmpty() { -@@ -721,6 +795,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -720,6 +794,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.pendingBlockEntities.clear(); this.upgradeData.upgrade(this); @@ -32864,10 +32849,10 @@ index d747e7058f78ac1fd02f3dc8e06670ed484cd42b..c0c212fd50cf97ae311035b370e8b4d4 private @Nullable BlockEntity promotePendingBlockEntity(final BlockPos pos, final CompoundTag tag) { diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf333a06de 100644 +index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e94469023d8b47b0 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -10,7 +10,7 @@ import net.minecraft.world.level.biome.Climate; +@@ -9,7 +9,7 @@ import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; @@ -32876,7 +32861,7 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf public static final int SECTION_WIDTH = 16; public static final int SECTION_HEIGHT = 16; public static final int SECTION_SIZE = 4096; -@@ -22,6 +22,30 @@ public class LevelChunkSection { +@@ -21,6 +21,30 @@ public class LevelChunkSection { public final PalettedContainer states; private PalettedContainer> biomes; // CraftBukkit - read/write @@ -32907,7 +32892,7 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf private LevelChunkSection(final LevelChunkSection source) { this.nonEmptyBlockCount = source.nonEmptyBlockCount; this.fluidCount = source.fluidCount; -@@ -62,6 +86,45 @@ public class LevelChunkSection { +@@ -61,6 +85,45 @@ public class LevelChunkSection { return this.setBlockState(sectionX, sectionY, sectionZ, state, true); } @@ -32953,7 +32938,7 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf public BlockState setBlockState(final int sectionX, final int sectionY, final int sectionZ, final BlockState state, final boolean checkThreading) { BlockState previous; if (checkThreading) { -@@ -100,6 +163,8 @@ public class LevelChunkSection { +@@ -99,6 +162,8 @@ public class LevelChunkSection { } } @@ -32962,7 +32947,7 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf return previous; } -@@ -124,42 +189,71 @@ public class LevelChunkSection { +@@ -123,37 +188,71 @@ public class LevelChunkSection { } public void recalcBlockCounts() { @@ -32972,9 +32957,12 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf - public int tickingBlockCount; - public int tickingFluidCount; - -- BlockCounter() { -- Objects.requireNonNull(LevelChunkSection.this); -- super(); +- @Override +- public void accept(final BlockState state, final int count) { +- if (!state.isAir()) { +- this.nonEmptyBlockCount += count; +- if (state.isRandomlyTicking()) { +- this.tickingBlockCount += count; + // Paper start - block counting + // reset, then recalculate + this.nonEmptyBlockCount = (short)0; @@ -32996,14 +32984,8 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf + counts.put(0, FULL_LIST); + } else { + counts = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingBitStorage)storage).moonrise$countEntries(); - } - -- @Override -- public void accept(final BlockState state, final int count) { -- if (!state.isAir()) { -- this.nonEmptyBlockCount += count; -- if (state.isRandomlyTicking()) { -- this.tickingBlockCount += count; ++ } ++ + for (final java.util.Iterator> iterator = counts.int2ObjectEntrySet().fastIterator(); iterator.hasNext();) { + final it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry entry = iterator.next(); + final int paletteIdx = entry.getIntKey(); @@ -33062,7 +33044,7 @@ index edfd4c7b089e69c1237db71fa0f13d6ed9565394..398018ad7037669a756f804403fd76cf } public PalettedContainer getStates() { -@@ -177,6 +271,11 @@ public class LevelChunkSection { +@@ -171,6 +270,11 @@ public class LevelChunkSection { PalettedContainer> biomes = this.biomes.recreate(); biomes.read(buffer); this.biomes = biomes; @@ -33099,7 +33081,7 @@ index 51761bba718b5bc58524454137d7e526c74ce5d3..58f03cf8b32b141dc7df72568ef902ee this.values = (T[])(new Object[1 << bits]); this.bits = bits; diff --git a/net/minecraft/world/level/chunk/Palette.java b/net/minecraft/world/level/chunk/Palette.java -index 89f2176747094340565e579d6106b3a702150b4b..2c53d464df5f141b83b3a589de597d82eeb42ddb 100644 +index 9b9119afd89f60cd88c3d1e6ec4857b92e95ff11..eec56782be6e6e2c483e7435ff136bf885011eaf 100644 --- a/net/minecraft/world/level/chunk/Palette.java +++ b/net/minecraft/world/level/chunk/Palette.java @@ -5,7 +5,7 @@ import java.util.function.Predicate; @@ -33112,7 +33094,7 @@ index 89f2176747094340565e579d6106b3a702150b4b..2c53d464df5f141b83b3a589de597d82 boolean maybeHas(Predicate predicate); diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d2506efc5 100644 +index a04bc4efcb68c049bb9ac47ad378ecb6fec2c370..4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -24,7 +24,7 @@ import org.jspecify.annotations.Nullable; @@ -33183,7 +33165,7 @@ index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d return newData.palette.idFor(lastAddedValue, PaletteResize.noResizeExpected()); } -@@ -120,9 +151,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -117,9 +148,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } private T getAndSet(final int index, final T value) { @@ -33199,7 +33181,7 @@ index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d } public synchronized void set(final int x, final int y, final int z, final T value) { // Paper - synchronize -@@ -145,9 +179,11 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -142,9 +176,11 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return this.get(this.strategy.getIndex(x, y, z)); } @@ -33214,7 +33196,7 @@ index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d } @Override -@@ -167,6 +203,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -164,6 +200,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer newData.palette.read(buffer, this.strategy.globalMap()); buffer.readFixedSizeLongArray(newData.storage.getRaw()); this.data = newData; @@ -33222,7 +33204,7 @@ index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d } finally { this.release(); } -@@ -316,7 +353,44 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -310,7 +347,44 @@ public class PalettedContainer implements PaletteResize, PalettedContainer void accept(final T entry, final int count); } @@ -33269,20 +33251,20 @@ index 7337cbd5ee2cba2cd0cf21f2b9628e9f8e1e70fc..edf2990bfbe3d6b64eed85446eef207d PaletteResize dummyResizer = PaletteResize.noResizeExpected(); diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index e2208bc7b58b0241192b1b79e3ac1aa0bb35f354..d3bde6eb0edd24d5e5352388788d30938712a9c7 100644 +index 26c8a51c94b51a1ef8f5a3392f9c85a62af7f7f4..50fe95f472f143ef381557f8675e427f20aa9d09 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -154,7 +154,7 @@ public class ProtoChunk extends ChunkAccess { - } +@@ -156,7 +156,7 @@ public class ProtoChunk extends ChunkAccess { + } - if (LightEngine.hasDifferentLightProperties(oldState, state)) { -- this.skyLightSources.update(this, localX, y, localZ); -+ // Paper - rewrite chunk system - this.lightEngine.checkBlock(pos); - } - } + if (LightEngine.hasDifferentLightProperties(oldState, state)) { +- this.skyLightSources.update(this, localX, y, localZ); ++ // Paper - rewrite chunk system + this.lightEngine.checkBlock(pos); + } + } diff --git a/net/minecraft/world/level/chunk/SingleValuePalette.java b/net/minecraft/world/level/chunk/SingleValuePalette.java -index 7a9f737d03b5bf61c857e28539d7e09cb36be46f..c180673b37b07282419e315e8449e2ab73bbbc98 100644 +index 1e3ae1ae9dac0c98f6840658d690f63deac5c406..06a7f795739df3ccb7cae0aa00c88eb8ceea8073 100644 --- a/net/minecraft/world/level/chunk/SingleValuePalette.java +++ b/net/minecraft/world/level/chunk/SingleValuePalette.java @@ -8,9 +8,21 @@ import net.minecraft.network.VarInt; @@ -33307,19 +33289,19 @@ index 7a9f737d03b5bf61c857e28539d7e09cb36be46f..c180673b37b07282419e315e8449e2ab + public SingleValuePalette(final List paletteEntries) { if (!paletteEntries.isEmpty()) { - Validate.isTrue(paletteEntries.size() <= 1, "Can't initialize SingleValuePalette with %d values.", (long)paletteEntries.size()); -@@ -28,6 +40,11 @@ public class SingleValuePalette implements Palette { - return resizeHandler.onResize(1, value); - } else { - this.value = value; -+ // Paper start - optimise palette reads -+ if (this.rawPalette != null) { -+ this.rawPalette[0] = value; -+ } -+ // Paper end - optimise palette reads - return 0; + Validate.isTrue(paletteEntries.size() <= 1, "Can't initialize SingleValuePalette with %d values.", paletteEntries.size()); +@@ -29,6 +41,11 @@ public class SingleValuePalette implements Palette { } + + this.value = value; ++ // Paper start - optimise palette reads ++ if (this.rawPalette != null) { ++ this.rawPalette[0] = value; ++ } ++ // Paper end - optimise palette reads + return 0; } + @@ -53,6 +70,11 @@ public class SingleValuePalette implements Palette { @Override public void read(final FriendlyByteBuf buffer, final IdMap globalMap) { @@ -33458,7 +33440,7 @@ index 8d3eb23eb607c862e15fb9e2e7f71a2019b02d04..6eb1a3a83c5bae8935c042396d676f7a } } diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java -index 3e381c26fe9a646c73704515f57ba09d9533f37e..554faa6ebfc7c7db11634fc9a8cac846df9b92fb 100644 +index 81837925c0a0fac18ea9d477e82ace10e32e932c..9208924f54d5024bc50ad4501fbff9eb2a289181 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStep.java +++ b/net/minecraft/world/level/chunk/status/ChunkStep.java @@ -11,9 +11,50 @@ import net.minecraft.world.level.chunk.ChunkAccess; @@ -33572,7 +33554,7 @@ index 3e381c26fe9a646c73704515f57ba09d9533f37e..554faa6ebfc7c7db11634fc9a8cac846 private final ChunkStatus status; private final @Nullable ChunkStep parent; diff --git a/net/minecraft/world/level/chunk/storage/IOWorker.java b/net/minecraft/world/level/chunk/storage/IOWorker.java -index cc5d366f7b485f98901572b1aaf57d8b650d521f..7adb4be57bd9fdc9980b5b7e91e9d9ca4d24a726 100644 +index ecc3d06a3e61b1de001e77ac35fa282e61e4d517..cd2ac98e1910c8c6222db084a1d2dffc6f9519c9 100644 --- a/net/minecraft/world/level/chunk/storage/IOWorker.java +++ b/net/minecraft/world/level/chunk/storage/IOWorker.java @@ -31,7 +31,7 @@ public class IOWorker implements AutoCloseable, ChunkScanAccess { @@ -33585,10 +33567,10 @@ index cc5d366f7b485f98901572b1aaf57d8b650d521f..7adb4be57bd9fdc9980b5b7e91e9d9ca private final Long2ObjectLinkedOpenHashMap> regionCacheForBlender = new Long2ObjectLinkedOpenHashMap<>(); private static final int REGION_CACHE_SIZE = 1024; diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070396adc03 100644 +index 0113fdf0b346f1dbea3856690ca8c389a2bae0a9..026b1f31d5041786e90ba372a228732aee094c16 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -23,7 +23,7 @@ import net.minecraft.world.level.ChunkPos; +@@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -33597,7 +33579,7 @@ index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070 private static final Logger LOGGER = LogUtils.getLogger(); private static final int SECTOR_BYTES = 4096; @VisibleForTesting -@@ -46,6 +46,21 @@ public class RegionFile implements AutoCloseable { +@@ -45,6 +45,21 @@ public class RegionFile implements AutoCloseable { @VisibleForTesting protected final RegionBitmap usedSectors = new RegionBitmap(); @@ -33619,7 +33601,7 @@ index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070 public RegionFile(final RegionStorageInfo info, final Path path, final Path externalFileDir, final boolean sync) throws IOException { this(info, path, externalFileDir, RegionFileVersion.getSelected(), sync); } -@@ -201,6 +216,15 @@ public class RegionFile implements AutoCloseable { +@@ -200,6 +215,15 @@ public class RegionFile implements AutoCloseable { } private @Nullable DataInputStream createExternalChunkInputStream(final ChunkPos pos, final byte versionId) throws IOException { @@ -33635,7 +33617,7 @@ index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070 Path externalFile = this.getExternalChunkPath(pos); if (!Files.isRegularFile(externalFile)) { LOGGER.error("External chunk path {} is not file", externalFile); -@@ -395,9 +419,28 @@ public class RegionFile implements AutoCloseable { +@@ -394,9 +418,28 @@ public class RegionFile implements AutoCloseable { } } @@ -33663,9 +33645,9 @@ index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070 + // Paper end - rewrite chunk system + public ChunkBuffer(final ChunkPos pos) { - Objects.requireNonNull(RegionFile.this); super(8096); -@@ -415,7 +458,7 @@ public class RegionFile implements AutoCloseable { + super.write(0); +@@ -413,7 +456,7 @@ public class RegionFile implements AutoCloseable { int streamLength = this.count - 5 + 1; JvmProfiler.INSTANCE.onRegionFileWrite(RegionFile.this.info, this.pos, RegionFile.this.version, streamLength); result.putInt(0, streamLength); @@ -33675,7 +33657,7 @@ index 9409cc5c8dbd12ce6bdf34843da70170ebce41bd..c9acbdce97cb605a45124bb9d3944070 } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 4473503da2459016859b2d72ecd7825df23f4be4..e9316cc08fe4cb4af28583a8cb1ec658243bffd0 100644 +index f2f1b9132754b3e04fbaae4fc6499a7119540b90..694689c5e0ca65b1b8724b689f3817753dd74834 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -15,7 +15,7 @@ import net.minecraft.util.FileUtil; @@ -33881,49 +33863,51 @@ index 4473503da2459016859b2d72ecd7825df23f4be4..e9316cc08fe4cb4af28583a8cb1ec658 - RegionFile region = this.regionCache.getAndMoveToFirst(key); - if (region != null) { - return region; -- } else { -- int cacheSize = io.papermc.paper.configuration.GlobalConfiguration.get() == null ? 256 : io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize; // Paper - Sanitise RegionFileCache and make configurable - Config not available during initial FileFixerUpper run -- if (this.regionCache.size() >= cacheSize) { // Paper - Sanitise RegionFileCache and make configurable + // Paper start - rewrite chunk system + if (existingOnly) { + return this.moonrise$getRegionFileIfExists(pos.x(), pos.z()); -+ } + } + synchronized (this) { + final long key = ChunkPos.pack(pos.x() >> REGION_SHIFT, pos.z() >> REGION_SHIFT); -+ + +- int cacheSize = io.papermc.paper.configuration.GlobalConfiguration.get() == null ? 256 : io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize; // Paper - Sanitise RegionFileCache and make configurable - Config not available during initial FileFixerUpper run +- if (this.regionCache.size() >= cacheSize) { // Paper - Sanitise RegionFileCache and make configurable +- this.regionCache.removeLast().close(); +- } + RegionFile ret = this.regionCache.getAndMoveToFirst(key); + if (ret != null) { + return ret; + } -+ + +- FileUtil.createDirectoriesSafe(this.folder); +- Path file = this.folder.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); +- if (existingOnly && !java.nio.file.Files.exists(file)) return null; // CraftBukkit +- RegionFile newRegion = new RegionFile(this.info, file, this.folder, this.sync); +- this.regionCache.putAndMoveToFirst(key, newRegion); +- return newRegion; + final int cacheSize = io.papermc.paper.configuration.GlobalConfiguration.get() == null ? 256 : io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize; // Paper - Sanitise RegionFileCache and make configurable - Config not available during initial FileFixerUpper run + + if (this.regionCache.size() >= cacheSize) { - this.regionCache.removeLast().close(); - } - ++ this.regionCache.removeLast().close(); ++ } ++ + final Path regionPath = this.folder.resolve(getRegionFileName(pos.x(), pos.z())); + + this.createRegionFile(key); + - FileUtil.createDirectoriesSafe(this.folder); -- Path file = this.folder.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); -- if (existingOnly && !java.nio.file.Files.exists(file)) return null; // CraftBukkit -- RegionFile newRegion = new RegionFile(this.info, file, this.folder, this.sync); -- this.regionCache.putAndMoveToFirst(key, newRegion); -- return newRegion; ++ FileUtil.createDirectoriesSafe(this.folder); + + ret = new RegionFile(this.info, regionPath, this.folder, this.sync); + + this.regionCache.putAndMoveToFirst(key, ret); + + return ret; - } ++ } + // Paper end - rewrite chunk system } public @Nullable CompoundTag read(final ChunkPos pos) throws IOException { -@@ -84,9 +276,15 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -77,9 +269,15 @@ public final class RegionFileStorage implements AutoCloseable { } } @@ -33941,7 +33925,7 @@ index 4473503da2459016859b2d72ecd7825df23f4be4..e9316cc08fe4cb4af28583a8cb1ec658 if (value == null) { region.clear(pos); } else { -@@ -99,23 +297,36 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -92,23 +290,36 @@ public final class RegionFileStorage implements AutoCloseable { @Override public void close() throws IOException { @@ -33950,8 +33934,8 @@ index 4473503da2459016859b2d72ecd7825df23f4be4..e9316cc08fe4cb4af28583a8cb1ec658 - for (RegionFile regionFile : this.regionCache.values()) { - try { - regionFile.close(); -- } catch (IOException var5) { -- exception.add(var5); +- } catch (IOException e) { +- exception.add(e); + // Paper start - rewrite chunk system + synchronized (this) { + final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); @@ -33990,7 +33974,7 @@ index 4473503da2459016859b2d72ecd7825df23f4be4..e9316cc08fe4cb4af28583a8cb1ec658 public RegionStorageInfo info() { diff --git a/net/minecraft/world/level/chunk/storage/SectionStorage.java b/net/minecraft/world/level/chunk/storage/SectionStorage.java -index b0b7af7e541eef20063c11ee94d7a6ceaec1626a..18be8647455dee182622f3bbefa9122547fe86ca 100644 +index 2412c31426bbf0a4f8102bf7ce307a4a93935f52..4bc70852449459037d293d2813c1c73345149b4e 100644 --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java @@ -40,10 +40,10 @@ import net.minecraft.world.level.LevelHeightAccessor; @@ -34148,39 +34132,39 @@ index b0b7af7e541eef20063c11ee94d7a6ceaec1626a..18be8647455dee182622f3bbefa91225 private record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 480623c30777fd230bf8428b16364db09806562b..1e0afa9590de7fe492cf29aded96be3db498c51e 100644 +index 760eda9e45a3f31a68a3b2b2dc13479c7db0d3cc..2d326c3090a5d7621350347e131ee31d4715d3a7 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -145,7 +145,7 @@ public record SerializableChunkData( - long inhabitedTime = chunkData.getLongOr("InhabitedTime", 0L); - ChunkStatus status = chunkData.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); - UpgradeData upgradeData = chunkData.getCompound("UpgradeData").map(tag -> new UpgradeData(tag, levelHeight)).orElse(UpgradeData.EMPTY); -- boolean lightCorrect = chunkData.getBooleanOr("isLightOn", false); -+ boolean lightCorrect = status.isOrAfter(ChunkStatus.LIGHT) && (chunkData.get("isLightOn") != null && chunkData.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_VERSION_TAG, -1) == ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_LIGHT_VERSION); // Paper - starlight - BlendingData.Packed blendingData = chunkData.read("blending_data", BlendingData.Packed.CODEC).orElse(null); - BelowZeroRetrogen belowZeroRetrogen = chunkData.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); - long[] carvingMask = chunkData.getLongArray("carving_mask").orElse(null); -@@ -210,7 +210,17 @@ public record SerializableChunkData( - - DataLayer blockLight = sectionTag.getByteArray("BlockLight").map(DataLayer::new).orElse(null); - DataLayer skyLight = sectionTag.getByteArray("SkyLight").map(DataLayer::new).orElse(null); -- sectionData.add(new SerializableChunkData.SectionData(y, section, blockLight, skyLight)); -+ // Paper start - starlight -+ SerializableChunkData.SectionData serializableChunkData = new SerializableChunkData.SectionData(y, section, blockLight, skyLight); -+ if (sectionTag.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG)) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setBlockLightState(sectionTag.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG, 0)); -+ } -+ -+ if (sectionTag.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG)) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setSkyLightState(sectionTag.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG, 0)); -+ } -+ sectionData.add(serializableChunkData); -+ // Paper end - starlight - } +@@ -146,7 +146,7 @@ public record SerializableChunkData( + long inhabitedTime = chunkData.getLongOr("InhabitedTime", 0L); + ChunkStatus status = chunkData.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); + UpgradeData upgradeData = chunkData.getCompound("UpgradeData").map(tag -> new UpgradeData(tag, levelHeight)).orElse(UpgradeData.EMPTY); +- boolean lightCorrect = chunkData.getBooleanOr("isLightOn", false); ++ boolean lightCorrect = status.isOrAfter(ChunkStatus.LIGHT) && (chunkData.get("isLightOn") != null && chunkData.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_VERSION_TAG, -1) == ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_LIGHT_VERSION); // Paper - starlight + BlendingData.Packed blendingData = chunkData.read("blending_data", BlendingData.Packed.CODEC).orElse(null); + BelowZeroRetrogen belowZeroRetrogen = chunkData.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); + long[] carvingMask = chunkData.getLongArray("carving_mask").orElse(null); +@@ -211,7 +211,17 @@ public record SerializableChunkData( + + DataLayer blockLight = sectionTag.getByteArray("BlockLight").map(DataLayer::new).orElse(null); + DataLayer skyLight = sectionTag.getByteArray("SkyLight").map(DataLayer::new).orElse(null); +- sectionData.add(new SerializableChunkData.SectionData(y, section, blockLight, skyLight)); ++ // Paper start - starlight ++ SerializableChunkData.SectionData serializableChunkData = new SerializableChunkData.SectionData(y, section, blockLight, skyLight); ++ if (sectionTag.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG)) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setBlockLightState(sectionTag.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG, 0)); ++ } ++ ++ if (sectionTag.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG)) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setSkyLightState(sectionTag.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG, 0)); ++ } ++ sectionData.add(serializableChunkData); ++ // Paper end - starlight } + } @@ -238,6 +248,59 @@ public record SerializableChunkData( - } + ); } + // Paper start - starlight @@ -34254,77 +34238,77 @@ index 480623c30777fd230bf8428b16364db09806562b..1e0afa9590de7fe492cf29aded96be3d if (chunkType == ChunkType.LEVELCHUNK) { - return new ImposterProtoChunk((LevelChunk)chunk, false); + return this.loadStarlightLightData(level, new ImposterProtoChunk((LevelChunk)chunk, false)); // Paper - starlight - } else { - ProtoChunk protoChunkx = (ProtoChunk)chunk; - -@@ -357,7 +420,7 @@ public record SerializableChunkData( - protoChunkx.setCarvingMask(new CarvingMask(this.carvingMask, chunk.getMinY())); - } + } -- return protoChunkx; -+ return this.loadStarlightLightData(level, protoChunkx); // Paper - starlight + ProtoChunk protoChunk = (ProtoChunk)chunk; +@@ -358,7 +421,7 @@ public record SerializableChunkData( + protoChunk.setCarvingMask(new CarvingMask(this.carvingMask, chunk.getMinY())); } + +- return protoChunk; ++ return this.loadStarlightLightData(level, protoChunk); // Paper - starlight } -@@ -371,21 +434,44 @@ public record SerializableChunkData( - } else { - ChunkPos pos = chunk.getPos(); - List sectionData = new ArrayList<>(); -- LevelChunkSection[] chunkSections = chunk.getSections(); -- LevelLightEngine lightEngine = level.getChunkSource().getLightEngine(); + private static void logErrors(final ChunkPos pos, final int sectionY, final String message) { +@@ -372,21 +435,44 @@ public record SerializableChunkData( + + ChunkPos pos = chunk.getPos(); + List sectionData = new ArrayList<>(); +- LevelChunkSection[] chunkSections = chunk.getSections(); +- LevelLightEngine lightEngine = level.getChunkSource().getLightEngine(); - -- for (int sectionY = lightEngine.getMinLightSection(); sectionY < lightEngine.getMaxLightSection(); sectionY++) { -- int sectionIndex = chunk.getSectionIndexFromSectionY(sectionY); -- boolean hasSection = sectionIndex >= 0 && sectionIndex < chunkSections.length; -- DataLayer sourceBlockLight = lightEngine.getLayerListener(LightLayer.BLOCK).getDataLayerData(SectionPos.of(pos, sectionY)); -- DataLayer sourceSkyLight = lightEngine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(pos, sectionY)); -- DataLayer blockLight = sourceBlockLight != null && !sourceBlockLight.isEmpty() ? sourceBlockLight.copy() : null; -- DataLayer skyLight = sourceSkyLight != null && !sourceSkyLight.isEmpty() ? sourceSkyLight.copy() : null; -- if (hasSection || blockLight != null || skyLight != null) { -- LevelChunkSection section = hasSection ? chunkSections[sectionIndex].copy() : null; -- sectionData.add(new SerializableChunkData.SectionData(sectionY, section, blockLight, skyLight)); -+ // Paper start - starlight -+ final int minLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinLightSection(level); -+ final int maxLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxLightSection(level); -+ final int minBlockSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(level); -+ -+ final LevelChunkSection[] chunkSections = chunk.getSections(); -+ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getBlockNibbles(); -+ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] skyNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getSkyNibbles(); +- for (int sectionY = lightEngine.getMinLightSection(); sectionY < lightEngine.getMaxLightSection(); sectionY++) { +- int sectionIndex = chunk.getSectionIndexFromSectionY(sectionY); +- boolean hasSection = sectionIndex >= 0 && sectionIndex < chunkSections.length; +- DataLayer sourceBlockLight = lightEngine.getLayerListener(LightLayer.BLOCK).getDataLayerData(SectionPos.of(pos, sectionY)); +- DataLayer sourceSkyLight = lightEngine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(pos, sectionY)); +- DataLayer blockLight = sourceBlockLight != null && !sourceBlockLight.isEmpty() ? sourceBlockLight.copy() : null; +- DataLayer skyLight = sourceSkyLight != null && !sourceSkyLight.isEmpty() ? sourceSkyLight.copy() : null; +- if (hasSection || blockLight != null || skyLight != null) { +- LevelChunkSection section = hasSection ? chunkSections[sectionIndex].copy() : null; +- sectionData.add(new SerializableChunkData.SectionData(sectionY, section, blockLight, skyLight)); ++ // Paper start - starlight ++ final int minLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinLightSection(level); ++ final int maxLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxLightSection(level); ++ final int minBlockSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(level); + -+ for (int lightSection = minLightSection; lightSection <= maxLightSection; ++lightSection) { -+ final int lightSectionIdx = lightSection - minLightSection; -+ final int blockSectionIdx = lightSection - minBlockSection; ++ final LevelChunkSection[] chunkSections = chunk.getSections(); ++ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getBlockNibbles(); ++ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] skyNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getSkyNibbles(); + -+ final LevelChunkSection chunkSection = (blockSectionIdx >= 0 && blockSectionIdx < chunkSections.length) ? chunkSections[blockSectionIdx].copy() : null; -+ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray.SaveState blockNibble = blockNibbles[lightSectionIdx].getSaveState(); -+ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray.SaveState skyNibble = skyNibbles[lightSectionIdx].getSaveState(); ++ for (int lightSection = minLightSection; lightSection <= maxLightSection; ++lightSection) { ++ final int lightSectionIdx = lightSection - minLightSection; ++ final int blockSectionIdx = lightSection - minBlockSection; + -+ if (chunkSection == null && blockNibble == null && skyNibble == null) { -+ continue; - } ++ final LevelChunkSection chunkSection = (blockSectionIdx >= 0 && blockSectionIdx < chunkSections.length) ? chunkSections[blockSectionIdx].copy() : null; ++ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray.SaveState blockNibble = blockNibbles[lightSectionIdx].getSaveState(); ++ final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray.SaveState skyNibble = skyNibbles[lightSectionIdx].getSaveState(); + -+ final SerializableChunkData.SectionData section = new SerializableChunkData.SectionData( -+ lightSection, chunkSection, -+ blockNibble == null ? null : (blockNibble.data == null ? null : new DataLayer(blockNibble.data)), -+ skyNibble == null ? null : (skyNibble.data == null ? null : new DataLayer(skyNibble.data)) -+ ); ++ if (chunkSection == null && blockNibble == null && skyNibble == null) { ++ continue; ++ } + -+ if (blockNibble != null) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)section).starlight$setBlockLightState(blockNibble.state); -+ } ++ final SerializableChunkData.SectionData section = new SerializableChunkData.SectionData( ++ lightSection, chunkSection, ++ blockNibble == null ? null : (blockNibble.data == null ? null : new DataLayer(blockNibble.data)), ++ skyNibble == null ? null : (skyNibble.data == null ? null : new DataLayer(skyNibble.data)) ++ ); + -+ if (skyNibble != null) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)section).starlight$setSkyLightState(skyNibble.state); -+ } ++ if (blockNibble != null) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)section).starlight$setBlockLightState(blockNibble.state); ++ } + -+ sectionData.add(section); ++ if (skyNibble != null) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)section).starlight$setSkyLightState(skyNibble.state); } -+ // Paper end - starlight ++ ++ sectionData.add(section); + } ++ // Paper end - starlight - List blockEntities = new ArrayList<>(chunk.getBlockEntitiesPos().size()); + List blockEntities = new ArrayList<>(chunk.getBlockEntitiesPos().size()); -@@ -487,6 +573,19 @@ public record SerializableChunkData( +@@ -485,6 +571,19 @@ public record SerializableChunkData( sectionTag.putByteArray("SkyLight", section.skyLight.getData()); } @@ -34344,7 +34328,7 @@ index 480623c30777fd230bf8428b16364db09806562b..1e0afa9590de7fe492cf29aded96be3d if (!sectionTag.isEmpty()) { sectionTag.putByte("Y", (byte)section.y); sectionTags.add(sectionTag); -@@ -521,6 +620,14 @@ public record SerializableChunkData( +@@ -519,6 +618,14 @@ public record SerializableChunkData( tag.put("ChunkBukkitValues", this.persistentDataContainer); } // CraftBukkit end @@ -34359,7 +34343,7 @@ index 480623c30777fd230bf8428b16364db09806562b..1e0afa9590de7fe492cf29aded96be3d return tag; } -@@ -668,6 +775,60 @@ public record SerializableChunkData( +@@ -666,6 +773,60 @@ public record SerializableChunkData( } } @@ -34422,7 +34406,7 @@ index 480623c30777fd230bf8428b16364db09806562b..1e0afa9590de7fe492cf29aded96be3d } } diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index c5ac299e4a23d51a7777a678a0e1735bfb194f09..79ed9b6e8c6cb0029f25bb4b83a5d9e1bab13919 100644 +index ebb94d87e3b659e9049cbe5a3d5375274773fe57..4346f3bace176e09d9ffb02e9af29a1281071e2a 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java @@ -18,25 +18,39 @@ import net.minecraft.util.datafix.DataFixTypes; @@ -34529,7 +34513,7 @@ index c5ac299e4a23d51a7777a678a0e1735bfb194f09..79ed9b6e8c6cb0029f25bb4b83a5d9e1 } } diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java -index b857b705d919c529f8ea62c3cece22fff9f832ae..a30409eddfaded878a3ac54bb526fd2e4b887c57 100644 +index 1fe402ed7e273063e32ed4d164c4098ee764703a..a30409eddfaded878a3ac54bb526fd2e4b887c57 100644 --- a/net/minecraft/world/level/entity/EntityTickList.java +++ b/net/minecraft/world/level/entity/EntityTickList.java @@ -9,51 +9,38 @@ import net.minecraft.world.entity.Entity; @@ -34576,24 +34560,22 @@ index b857b705d919c529f8ea62c3cece22fff9f832ae..a30409eddfaded878a3ac54bb526fd2e public void forEach(final Consumer output) { - if (this.iterated != null) { - throw new UnsupportedOperationException("Only one concurrent iteration supported"); -- } else { -- this.iterated = this.active; +- } +- +- this.iterated = this.active; - -- try { -- for (Entity entity : this.active.values()) { -- output.accept(entity); -- } -- } finally { -- this.iterated = null; + // Paper start - rewrite chunk system + // To ensure nothing weird happens with dimension travelling, do not iterate over new entries... + // (by dfl iterator() is configured to not iterate over new entries) + final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.Iterator iterator = this.entities.iterator(); -+ try { + try { +- for (Entity entity : this.active.values()) { +- output.accept(entity); + while (iterator.hasNext()) { + output.accept(iterator.next()); } -+ } finally { + } finally { +- this.iterated = null; + iterator.finishedIterating(); } + // Paper end - rewrite chunk system @@ -34619,7 +34601,7 @@ index c31f66710036cb68500ed936b8a4b89a2cf57574..4d5e3cf76b64e57c22e2717ca395e23a public void move(final ServerLevel level) { diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index d74c887d2fdc39e09233eba47464868dfa846b64..39e9a1c39b5312aaa2ca6d2a1ffd8ed17b9933e6 100644 +index db190b3b2bcc386d6e01c9b8d694efe4ac5e54af..83bc0f6fa7624a0df546726fa8ccc9744173ff88 100644 --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java @@ -87,7 +87,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { @@ -34631,17 +34613,17 @@ index d74c887d2fdc39e09233eba47464868dfa846b64..39e9a1c39b5312aaa2ca6d2a1ffd8ed1 } private void doCreateBiomes(final Blender blender, final RandomState randomState, final StructureManager structureManager, final ChunkAccess protoChunk) { -@@ -376,7 +376,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -373,7 +373,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { + section.release(); + } } - - return var20; - }, Util.backgroundExecutor().forName("wgen_fill_noise")); + }, Runnable::run); // Paper - rewrite chunk system } private ChunkAccess doFill( diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 469fb7695b46420b5817928b8f905c4df3aa9bfe..2ab055d5cdfb1e2e7cfb6f8a769c3d571acb2861 100644 +index d7d98399cddb2d78eda492ab177ad770e1e083a4..0d4c26d8a086e54f84413dab9595e210e52a43bf 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java @@ -50,8 +50,13 @@ public class StructureCheck { @@ -34668,23 +34650,23 @@ index 469fb7695b46420b5817928b8f905c4df3aa9bfe..2ab055d5cdfb1e2e7cfb6f8a769c3d57 + Object2IntMap cachedResult = this.loadedChunksSafe.get(posKey); // Paper - rewrite chunk system if (cachedResult != null) { return this.checkStructureInfo(cachedResult, structure, requireUnreferenced); - } else { -@@ -103,9 +108,11 @@ public class StructureCheck { - } else if (!placement.applyAdditionalChunkRestrictions(pos.x(), pos.z(), this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs - return StructureCheckResult.START_NOT_PRESENT; - } else { -- boolean isFeatureChunk = this.featureChecks -- .computeIfAbsent(structure, k -> new Long2BooleanOpenHashMap()) -- .computeIfAbsent(posKey, k -> this.canCreateStructure(pos, structure)); -+ // Paper start - rewrite chunk system -+ boolean isFeatureChunk = this.featureChecksSafe -+ .computeIfAbsent(structure, structure1 -> new ca.spottedleaf.moonrise.common.map.SynchronisedLong2BooleanMap(PER_FEATURE_CHECK_LIMIT)) -+ .getOrCompute(posKey, l -> this.canCreateStructure(pos, structure)); -+ // Paper end - rewrite chunk system - return !isFeatureChunk ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; - } } -@@ -222,15 +229,25 @@ public class StructureCheck { +@@ -107,9 +112,11 @@ public class StructureCheck { + return StructureCheckResult.START_NOT_PRESENT; + } + +- boolean isFeatureChunk = this.featureChecks +- .computeIfAbsent(structure, k -> new Long2BooleanOpenHashMap()) +- .computeIfAbsent(posKey, k -> this.canCreateStructure(pos, structure)); ++ // Paper start - rewrite chunk system ++ boolean isFeatureChunk = this.featureChecksSafe ++ .computeIfAbsent(structure, structure1 -> new ca.spottedleaf.moonrise.common.map.SynchronisedLong2BooleanMap(PER_FEATURE_CHECK_LIMIT)) ++ .getOrCompute(posKey, l -> this.canCreateStructure(pos, structure)); ++ // Paper end - rewrite chunk system + return !isFeatureChunk ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; + } + +@@ -224,15 +231,25 @@ public class StructureCheck { } private void storeFullResults(final long posKey, final Object2IntMap starts) { @@ -34715,7 +34697,7 @@ index 469fb7695b46420b5817928b8f905c4df3aa9bfe..2ab055d5cdfb1e2e7cfb6f8a769c3d57 counts.computeInt(structure, (k, value) -> value == null ? 1 : value + 1); return counts; diff --git a/net/minecraft/world/level/lighting/LevelLightEngine.java b/net/minecraft/world/level/lighting/LevelLightEngine.java -index de10c0bb009fdbd6f24d1db5c9266270027e8863..c6825283ad1787fcf4bfb93b32ca8396ac44f503 100644 +index 64194984fa30038b5bd53140511faf2b5784ead5..c6825283ad1787fcf4bfb93b32ca8396ac44f503 100644 --- a/net/minecraft/world/level/lighting/LevelLightEngine.java +++ b/net/minecraft/world/level/lighting/LevelLightEngine.java @@ -9,149 +9,113 @@ import net.minecraft.world.level.chunk.DataLayer; @@ -34851,9 +34833,9 @@ index de10c0bb009fdbd6f24d1db5c9266270027e8863..c6825283ad1787fcf4bfb93b32ca8396 public LayerLightEventListener getLayerListener(final LightLayer layer) { - if (layer == LightLayer.BLOCK) { -- return (LayerLightEventListener)(this.blockEngine == null ? LayerLightEventListener.DummyLightLayerEventListener.INSTANCE : this.blockEngine); +- return this.blockEngine == null ? LayerLightEventListener.DummyLightLayerEventListener.INSTANCE : this.blockEngine; - } else { -- return (LayerLightEventListener)(this.skyEngine == null ? LayerLightEventListener.DummyLightLayerEventListener.INSTANCE : this.skyEngine); +- return this.skyEngine == null ? LayerLightEventListener.DummyLightLayerEventListener.INSTANCE : this.skyEngine; - } + return layer == LightLayer.BLOCK ? this.lightEngine.getBlockReader() : this.lightEngine.getSkyReader(); // Paper - rewrite chunk system } @@ -34921,10 +34903,10 @@ index de10c0bb009fdbd6f24d1db5c9266270027e8863..c6825283ad1787fcf4bfb93b32ca8396 public int getLightSectionCount() { diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java -index 27aa4e640ee29d96a854846bb906c30ebf4854f6..d7270de83fa13618d8f94de6eff63ffa37b823cc 100644 +index ee960c0b1e7f510b77949db2a57a53357a00f62d..e93c900385994d391242def7d022d06e6ef23861 100644 --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -47,6 +47,48 @@ public abstract class FlowingFluid extends Fluid { +@@ -46,6 +46,48 @@ public abstract class FlowingFluid extends Fluid { }); private final Map shapes = Maps.newIdentityHashMap(); @@ -34973,8 +34955,8 @@ index 27aa4e640ee29d96a854846bb906c30ebf4854f6..d7270de83fa13618d8f94de6eff63ffa @Override protected void createFluidStateDefinition(final StateDefinition.Builder builder) { builder.add(FALLING); -@@ -212,70 +254,70 @@ public abstract class FlowingFluid extends Fluid { - } +@@ -211,72 +253,70 @@ public abstract class FlowingFluid extends Fluid { + return amount <= 0 ? Fluids.EMPTY.defaultFluidState() : this.getFlowing(amount, false); } - private static boolean canPassThroughWall( @@ -34989,19 +34971,7 @@ index 27aa4e640ee29d96a854846bb906c30ebf4854f6..d7270de83fa13618d8f94de6eff63ffa - VoxelShape targetShape = targetState.getCollisionShape(level, targetPos); - if (targetShape == Shapes.block()) { - return false; -- } else { -- VoxelShape sourceShape = sourceState.getCollisionShape(level, sourcePos); -- if (sourceShape == Shapes.block()) { -- return false; -- } else if (sourceShape == Shapes.empty() && targetShape == Shapes.empty()) { -- return true; -- } else { -- Object2ByteLinkedOpenHashMap cache; -- if (!sourceState.getBlock().hasDynamicShape() && !targetState.getBlock().hasDynamicShape()) { -- cache = OCCLUSION_CACHE.get(); -- } else { -- cache = null; -- } +- } + // Paper start - fluid method optimisations + private static boolean canPassThroughWall(final Direction direction, final BlockGetter level, + final BlockPos fromPos, final BlockState fromState, @@ -35011,55 +34981,66 @@ index 27aa4e640ee29d96a854846bb906c30ebf4854f6..d7270de83fa13618d8f94de6eff63ffa + return true; + } -- FlowingFluid.BlockStatePairKey key; -- if (cache != null) { -- key = new FlowingFluid.BlockStatePairKey(sourceState, targetState, direction); -- byte cached = cache.getAndMoveToFirst(key); -- if (cached != 127) { -- return cached != 0; -- } -- } else { -- key = null; -- } +- VoxelShape sourceShape = sourceState.getCollisionShape(level, sourcePos); +- if (sourceShape == Shapes.block()) { +- return false; +- } + if (((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)fromState).moonrise$occludesFullBlock() | ((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)toState).moonrise$occludesFullBlock()) { + // don't even try to cache simple cases + return false; + } -- boolean result = !Shapes.mergedFaceOccludes(sourceShape, targetShape, direction); -- if (cache != null) { -- if (cache.size() == 200) { -- cache.removeLastByte(); -- } +- if (sourceShape == Shapes.empty() && targetShape == Shapes.empty()) { +- return true; +- } + final ca.spottedleaf.moonrise.patches.collisions.util.FluidOcclusionCacheKey[] cache = ((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)fromState).moonrise$hasCache() & ((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)toState).moonrise$hasCache() ? + COLLISION_OCCLUSION_CACHE.get() : null; -- cache.putAndMoveToFirst(key, (byte)(result ? 1 : 0)); -- } +- Object2ByteLinkedOpenHashMap cache; +- if (!sourceState.getBlock().hasDynamicShape() && !targetState.getBlock().hasDynamicShape()) { +- cache = OCCLUSION_CACHE.get(); +- } else { +- cache = null; +- } + final int keyIndex + = (((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)fromState).moonrise$uniqueId1() ^ ((ca.spottedleaf.moonrise.patches.collisions.block.CollisionBlockState)toState).moonrise$uniqueId2() ^ ((ca.spottedleaf.moonrise.patches.collisions.util.CollisionDirection)(Object)direction).moonrise$uniqueId()) + & (COLLISION_OCCLUSION_CACHE_SIZE - 1); -- return result; +- FlowingFluid.BlockStatePairKey key; +- if (cache != null) { +- key = new FlowingFluid.BlockStatePairKey(sourceState, targetState, direction); +- byte cached = cache.getAndMoveToFirst(key); +- if (cached != 127) { +- return cached != 0; - } +- } else { +- key = null; + if (cache != null) { + final ca.spottedleaf.moonrise.patches.collisions.util.FluidOcclusionCacheKey cached = cache[keyIndex]; + if (cached != null && cached.first() == fromState && cached.second() == toState && cached.direction() == direction) { + return cached.result(); } -- } else { -- return false; - } -+ ++ } + +- boolean result = !Shapes.mergedFaceOccludes(sourceShape, targetShape, direction); +- if (cache != null) { +- if (cache.size() == 200) { +- cache.removeLastByte(); +- } + final VoxelShape shape1 = fromState.getCollisionShape(level, fromPos); + final VoxelShape shape2 = toState.getCollisionShape(level, toPos); -+ + +- cache.putAndMoveToFirst(key, (byte)(result ? 1 : 0)); +- } + final boolean result = !Shapes.mergedFaceOccludes(shape1, shape2, direction); -+ + +- return result; +- } else { +- return false; + if (cache != null) { + // we can afford to replace in-use keys more often due to the excessive caching the collision patch does in mergedFaceOccludes + cache[keyIndex] = new ca.spottedleaf.moonrise.patches.collisions.util.FluidOcclusionCacheKey(fromState, toState, direction, result); -+ } + } + + return result; } @@ -35184,7 +35165,7 @@ index 2e10d9d3850c18cf1bf625aac1dcacab1792e162..c835ae31a965b92780b7130a24c63ac2 public @Nullable ParticleOptions getDripParticle() { diff --git a/net/minecraft/world/level/portal/PortalForcer.java b/net/minecraft/world/level/portal/PortalForcer.java -index 08ac4ce3f34f2dc955ef2bfb2401f469f7a500a3..4e4903d38d705dca6ff16418e54a7a367074aa08 100644 +index 924a14caaef153a68afaced26b613d47f5fd5453..a468a1013058089115d023e8957f976ae34935ad 100644 --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java @@ -49,13 +49,46 @@ public class PortalForcer { @@ -35242,11 +35223,11 @@ index 08ac4ce3f34f2dc955ef2bfb2401f469f7a500a3..4e4903d38d705dca6ff16418e54a7a36 public Optional createPortal(final BlockPos origin, final Direction.Axis portalAxis) { diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java -index 1a1b775b4675603a9f5d492d6c9977af2ebbb72c..259a19cbcf9a42c5f48e5d03448729283baf36a7 100644 +index 8a1524836e2573f879108b6708ca307fba756d3e..efb79617cebe7234d85721da7b7f1fd6ef1a6a73 100644 --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java @@ -319,7 +319,7 @@ public class AABB { - } + return new BlockHitResult(from.add(scale * dx, scale * dy, scale * dz), direction, pos, false); } - private static @Nullable Direction getDirection( @@ -35438,7 +35419,7 @@ index 73364066033aa722db0e8ab6c7e6cc0d93f7ecfd..f229a9247f9887dd8b01116f135e1db1 private boolean isZStripFull(final int startZ, final int endZ, final int x, final int y) { return x < this.xSize && y < this.ySize && this.storage.nextClearBit(this.getIndex(x, y, startZ)) >= this.getIndex(x, y, endZ); diff --git a/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/net/minecraft/world/phys/shapes/CubeVoxelShape.java -index fa27f840cc9f17563701934cc504e40865e1670b..f6f2417ae6549802559e2307c293a1310ff1515f 100644 +index 77acd78861cceacd52cdcd3b5db94624b993d848..cdd7af6ed50567934763e666f9a7b0c82ffe1a1f 100644 --- a/net/minecraft/world/phys/shapes/CubeVoxelShape.java +++ b/net/minecraft/world/phys/shapes/CubeVoxelShape.java @@ -7,6 +7,7 @@ import net.minecraft.util.Mth; @@ -35450,7 +35431,7 @@ index fa27f840cc9f17563701934cc504e40865e1670b..f6f2417ae6549802559e2307c293a131 @Override diff --git a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -index 4631e6e8397676b30a7a9b04786e8abfdcc4549d..cdeff630372a998982f485424f0d3348f30c5291 100644 +index f5789f45091410beffc69d0de47d381c51c7fa85..34536dee9576d35e15145ccbadb81192fe1646c3 100644 --- a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java +++ b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java @@ -5,12 +5,79 @@ import net.minecraft.core.AxisCycle; @@ -35550,7 +35531,7 @@ index 66085f0e57fd2e2fae3967aab7f6835d23fced07..7c1e93123371d0d1b371243c132b54d4 public OffsetDoubleList(final DoubleList delegate, final double offset) { this.delegate = delegate; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a8feedf8d 100644 +index 6978aa31d0901d8126cd9c19f8171275fe922584..ccdaf6043f667b6983e4492cf570947ed5179df1 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java @@ -21,9 +21,15 @@ public final class Shapes { @@ -35620,7 +35601,7 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a public static VoxelShape box(final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ) { if (!(minX > maxX) && !(minY > maxY) && !(minZ > maxZ)) { return create(minX, minY, minZ, maxX, maxY, maxZ); -@@ -58,39 +106,42 @@ public final class Shapes { +@@ -58,41 +106,42 @@ public final class Shapes { } public static VoxelShape create(final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ) { @@ -35662,25 +35643,27 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a + minY == 0.0 && maxY == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minY, maxY }), + minZ == 0.0 && maxZ == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minZ, maxZ }) ); -- } else if (xBits == 0 && yBits == 0 && zBits == 0) { -- return block(); -- } else { -- int xSize = 1 << xBits; -- int ySize = 1 << yBits; -- int zSize = 1 << zBits; -- BitSetDiscreteVoxelShape voxelShape = BitSetDiscreteVoxelShape.withFilledBounds( -- xSize, -- ySize, -- zSize, -- (int)Math.round(minX * xSize), -- (int)Math.round(minY * ySize), -- (int)Math.round(minZ * zSize), -- (int)Math.round(maxX * xSize), -- (int)Math.round(maxY * ySize), -- (int)Math.round(maxZ * zSize) -- ); -- return new CubeVoxelShape(voxelShape); } +- +- if (xBits == 0 && yBits == 0 && zBits == 0) { +- return block(); +- } +- +- int xSize = 1 << xBits; +- int ySize = 1 << yBits; +- int zSize = 1 << zBits; +- BitSetDiscreteVoxelShape voxelShape = BitSetDiscreteVoxelShape.withFilledBounds( +- xSize, +- ySize, +- zSize, +- (int)Math.round(minX * xSize), +- (int)Math.round(minY * ySize), +- (int)Math.round(minZ * zSize), +- (int)Math.round(maxX * xSize), +- (int)Math.round(maxY * ySize), +- (int)Math.round(maxZ * zSize) +- ); +- return new CubeVoxelShape(voxelShape); } else { - return empty(); + return EMPTY; @@ -35689,19 +35672,30 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a } public static VoxelShape create(final AABB aabb) { -@@ -125,90 +176,54 @@ public final class Shapes { +@@ -127,92 +176,54 @@ public final class Shapes { return join(first, second, BooleanOp.OR); } - public static VoxelShape or(final VoxelShape first, final VoxelShape... tail) { - return Arrays.stream(tail).reduce(first, Shapes::or); +- } +- +- public static VoxelShape join(final VoxelShape first, final VoxelShape second, final BooleanOp op) { +- return joinUnoptimized(first, second, op).optimize(); +- } +- +- public static VoxelShape joinUnoptimized(final VoxelShape first, final VoxelShape second, final BooleanOp op) { +- if (op.apply(false, false)) { +- throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException()); + // Paper start - optimise collisions + public static VoxelShape or(final VoxelShape shape1, final VoxelShape... others) { + int size = others.length; + if (size == 0) { + return shape1; -+ } -+ + } + +- if (first == second) { +- return op.apply(true, true) ? first : empty(); + // reduce complexity of joins by splitting the merges + + // add extra slot for first shape @@ -35727,99 +35721,90 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a + } + } + size = newSize; -+ } -+ + } + +- boolean firstOnlyMatters = op.apply(true, false); +- boolean secondOnlyMatters = op.apply(false, true); +- if (first.isEmpty()) { +- return secondOnlyMatters ? second : empty(); +- } + return tmp[0].optimize(); + // Paper end - optimise collisions - } ++ } - public static VoxelShape join(final VoxelShape first, final VoxelShape second, final BooleanOp op) { -- return joinUnoptimized(first, second, op).optimize(); +- if (second.isEmpty()) { +- return firstOnlyMatters ? first : empty(); +- } ++ public static VoxelShape join(final VoxelShape first, final VoxelShape second, final BooleanOp op) { + return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.joinOptimized(first, second, op); // Paper - optimise collisions - } ++ } - public static VoxelShape joinUnoptimized(final VoxelShape first, final VoxelShape second, final BooleanOp op) { -- if (op.apply(false, false)) { -- throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException()); -- } else if (first == second) { -- return op.apply(true, true) ? first : empty(); -- } else { -- boolean firstOnlyMatters = op.apply(true, false); -- boolean secondOnlyMatters = op.apply(false, true); -- if (first.isEmpty()) { -- return secondOnlyMatters ? second : empty(); -- } else if (second.isEmpty()) { -- return firstOnlyMatters ? first : empty(); -- } else { -- IndexMerger xMerger = createIndexMerger( -- 1, first.getCoords(Direction.Axis.X), second.getCoords(Direction.Axis.X), firstOnlyMatters, secondOnlyMatters -- ); -- IndexMerger yMerger = createIndexMerger( -- xMerger.size() - 1, first.getCoords(Direction.Axis.Y), second.getCoords(Direction.Axis.Y), firstOnlyMatters, secondOnlyMatters -- ); -- IndexMerger zMerger = createIndexMerger( -- (xMerger.size() - 1) * (yMerger.size() - 1), -- first.getCoords(Direction.Axis.Z), -- second.getCoords(Direction.Axis.Z), -- firstOnlyMatters, -- secondOnlyMatters -- ); -- BitSetDiscreteVoxelShape voxelShape = BitSetDiscreteVoxelShape.join(first.shape, second.shape, xMerger, yMerger, zMerger, op); -- return (VoxelShape)(xMerger instanceof DiscreteCubeMerger && yMerger instanceof DiscreteCubeMerger && zMerger instanceof DiscreteCubeMerger -- ? new CubeVoxelShape(voxelShape) -- : new ArrayVoxelShape(voxelShape, xMerger.getList(), yMerger.getList(), zMerger.getList())); -- } -- } +- IndexMerger xMerger = createIndexMerger(1, first.getCoords(Direction.Axis.X), second.getCoords(Direction.Axis.X), firstOnlyMatters, secondOnlyMatters); +- IndexMerger yMerger = createIndexMerger( +- xMerger.size() - 1, first.getCoords(Direction.Axis.Y), second.getCoords(Direction.Axis.Y), firstOnlyMatters, secondOnlyMatters +- ); +- IndexMerger zMerger = createIndexMerger( +- (xMerger.size() - 1) * (yMerger.size() - 1), +- first.getCoords(Direction.Axis.Z), +- second.getCoords(Direction.Axis.Z), +- firstOnlyMatters, +- secondOnlyMatters +- ); +- BitSetDiscreteVoxelShape voxelShape = BitSetDiscreteVoxelShape.join(first.shape, second.shape, xMerger, yMerger, zMerger, op); +- return xMerger instanceof DiscreteCubeMerger && yMerger instanceof DiscreteCubeMerger && zMerger instanceof DiscreteCubeMerger +- ? new CubeVoxelShape(voxelShape) +- : new ArrayVoxelShape(voxelShape, xMerger.getList(), yMerger.getList(), zMerger.getList()); ++ public static VoxelShape joinUnoptimized(final VoxelShape first, final VoxelShape second, final BooleanOp op) { + return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.joinUnoptimized(first, second, op); // Paper - optimise collisions } public static boolean joinIsNotEmpty(final VoxelShape first, final VoxelShape second, final BooleanOp op) { - if (op.apply(false, false)) { - throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException()); -- } else { -- boolean firstEmpty = first.isEmpty(); -- boolean secondEmpty = second.isEmpty(); -- if (!firstEmpty && !secondEmpty) { -- if (first == second) { -- return op.apply(true, true); -- } else { -- boolean firstOnlyMatters = op.apply(true, false); -- boolean secondOnlyMatters = op.apply(false, true); +- } - -- for (Direction.Axis axis : AxisCycle.AXIS_VALUES) { -- if (first.max(axis) < second.min(axis) - 1.0E-7) { -- return firstOnlyMatters || secondOnlyMatters; -- } +- boolean firstEmpty = first.isEmpty(); +- boolean secondEmpty = second.isEmpty(); +- if (!firstEmpty && !secondEmpty) { +- if (first == second) { +- return op.apply(true, true); +- } - -- if (second.max(axis) < first.min(axis) - 1.0E-7) { -- return firstOnlyMatters || secondOnlyMatters; -- } -- } +- boolean firstOnlyMatters = op.apply(true, false); +- boolean secondOnlyMatters = op.apply(false, true); - -- IndexMerger xMerger = createIndexMerger( -- 1, first.getCoords(Direction.Axis.X), second.getCoords(Direction.Axis.X), firstOnlyMatters, secondOnlyMatters -- ); -- IndexMerger yMerger = createIndexMerger( -- xMerger.size() - 1, first.getCoords(Direction.Axis.Y), second.getCoords(Direction.Axis.Y), firstOnlyMatters, secondOnlyMatters -- ); -- IndexMerger zMerger = createIndexMerger( -- (xMerger.size() - 1) * (yMerger.size() - 1), -- first.getCoords(Direction.Axis.Z), -- second.getCoords(Direction.Axis.Z), -- firstOnlyMatters, -- secondOnlyMatters -- ); -- return joinIsNotEmpty(xMerger, yMerger, zMerger, first.shape, second.shape, op); +- for (Direction.Axis axis : AxisCycle.AXIS_VALUES) { +- if (first.max(axis) < second.min(axis) - 1.0E-7) { +- return firstOnlyMatters || secondOnlyMatters; +- } +- +- if (second.max(axis) < first.min(axis) - 1.0E-7) { +- return firstOnlyMatters || secondOnlyMatters; - } -- } else { -- return op.apply(!firstEmpty, !secondEmpty); - } +- +- IndexMerger xMerger = createIndexMerger( +- 1, first.getCoords(Direction.Axis.X), second.getCoords(Direction.Axis.X), firstOnlyMatters, secondOnlyMatters +- ); +- IndexMerger yMerger = createIndexMerger( +- xMerger.size() - 1, first.getCoords(Direction.Axis.Y), second.getCoords(Direction.Axis.Y), firstOnlyMatters, secondOnlyMatters +- ); +- IndexMerger zMerger = createIndexMerger( +- (xMerger.size() - 1) * (yMerger.size() - 1), +- first.getCoords(Direction.Axis.Z), +- second.getCoords(Direction.Axis.Z), +- firstOnlyMatters, +- secondOnlyMatters +- ); +- return joinIsNotEmpty(xMerger, yMerger, zMerger, first.shape, second.shape, op); +- } else { +- return op.apply(!firstEmpty, !secondEmpty); - } + return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isJoinNonEmpty(first, second, op); // Paper - optimise collisions } private static boolean joinIsNotEmpty( -@@ -238,51 +253,93 @@ public final class Shapes { +@@ -242,53 +253,93 @@ public final class Shapes { return distance; } @@ -35829,37 +35814,23 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a + public static boolean blockOccludes(final VoxelShape first, final VoxelShape second, final Direction direction) { + if (first == BLOCK & second == BLOCK) { return true; -- } else if (occluder.isEmpty()) { -+ } -+ + } + +- if (occluder.isEmpty()) { + if (first.isEmpty() | second.isEmpty()) { -+ return false; -+ } -+ -+ // we optimise getOpposite, so we can use it -+ // secondly, use our cache to retrieve sliced shape -+ final VoxelShape newFirst = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$getFaceShapeClamped(direction); -+ if (newFirst.isEmpty()) { return false; -- } else { -- Direction.Axis axis = direction.getAxis(); -- Direction.AxisDirection sign = direction.getAxisDirection(); -- VoxelShape first = sign == Direction.AxisDirection.POSITIVE ? shape : occluder; -- VoxelShape second = sign == Direction.AxisDirection.POSITIVE ? occluder : shape; -- BooleanOp op = sign == Direction.AxisDirection.POSITIVE ? BooleanOp.ONLY_FIRST : BooleanOp.ONLY_SECOND; -- return DoubleMath.fuzzyEquals(first.max(axis), 1.0, 1.0E-7) -- && DoubleMath.fuzzyEquals(second.min(axis), 0.0, 1.0E-7) -- && !joinIsNotEmpty(new SliceShape(first, axis, first.shape.getSize(axis) - 1), new SliceShape(second, axis, 0), op); } -+ final VoxelShape newSecond = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$getFaceShapeClamped(direction.getOpposite()); -+ if (newSecond.isEmpty()) { -+ return false; -+ } -+ -+ return !joinIsNotEmpty(newFirst, newSecond, BooleanOp.ONLY_FIRST); -+ // Paper end - optimise collisions - } +- Direction.Axis axis = direction.getAxis(); +- Direction.AxisDirection sign = direction.getAxisDirection(); +- VoxelShape first = sign == Direction.AxisDirection.POSITIVE ? shape : occluder; +- VoxelShape second = sign == Direction.AxisDirection.POSITIVE ? occluder : shape; +- BooleanOp op = sign == Direction.AxisDirection.POSITIVE ? BooleanOp.ONLY_FIRST : BooleanOp.ONLY_SECOND; +- return DoubleMath.fuzzyEquals(first.max(axis), 1.0, 1.0E-7) +- && DoubleMath.fuzzyEquals(second.min(axis), 0.0, 1.0E-7) +- && !joinIsNotEmpty(new SliceShape(first, axis, first.shape.getSize(axis) - 1), new SliceShape(second, axis, 0), op); +- } +- - public static boolean mergedFaceOccludes(final VoxelShape shape, final VoxelShape occluder, final Direction direction) { - if (shape != block() && occluder != block()) { - Direction.Axis axis = direction.getAxis(); @@ -35869,19 +35840,23 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a - if (!DoubleMath.fuzzyEquals(first.max(axis), 1.0, 1.0E-7)) { - first = empty(); - } -+ // Paper start - optimise collisions -+ public static boolean mergedFaceOccludes(final VoxelShape first, final VoxelShape second, final Direction direction) { -+ // see if any of the shapes on their own occludes, only if cached -+ if (((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$occludesFullBlockIfCached() || ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$occludesFullBlockIfCached()) { -+ return true; ++ // we optimise getOpposite, so we can use it ++ // secondly, use our cache to retrieve sliced shape ++ final VoxelShape newFirst = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$getFaceShapeClamped(direction); ++ if (newFirst.isEmpty()) { ++ return false; ++ } ++ final VoxelShape newSecond = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$getFaceShapeClamped(direction.getOpposite()); ++ if (newSecond.isEmpty()) { ++ return false; + } - if (!DoubleMath.fuzzyEquals(second.min(axis), 0.0, 1.0E-7)) { - second = empty(); - } -+ if (first.isEmpty() & second.isEmpty()) { -+ return false; -+ } ++ return !joinIsNotEmpty(newFirst, newSecond, BooleanOp.ONLY_FIRST); ++ // Paper end - optimise collisions ++ } - return !joinIsNotEmpty( - block(), @@ -35889,6 +35864,17 @@ index b9ed92ee991727efd0e8f9ed6cf302eb364788f2..de10ce3faa86d6ed6d528575a083722a - BooleanOp.ONLY_FIRST - ); - } else { ++ // Paper start - optimise collisions ++ public static boolean mergedFaceOccludes(final VoxelShape first, final VoxelShape second, final Direction direction) { ++ // see if any of the shapes on their own occludes, only if cached ++ if (((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$occludesFullBlockIfCached() || ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$occludesFullBlockIfCached()) { ++ return true; ++ } ++ ++ if (first.isEmpty() & second.isEmpty()) { ++ return false; ++ } ++ + // we optimise getOpposite, so we can use it + // secondly, use our cache to retrieve sliced shape + final VoxelShape newFirst = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$getFaceShapeClamped(direction); @@ -35960,7 +35946,7 @@ index ec7834b53788f95ab7956c22bddfa38c4ee4e2f2..a612ace0b4e128c05196400b125a12a8 private static DiscreteVoxelShape makeSlice(final DiscreteVoxelShape delegate, final Direction.Axis axis, final int point) { diff --git a/net/minecraft/world/phys/shapes/VoxelShape.java b/net/minecraft/world/phys/shapes/VoxelShape.java -index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa58996968edb7 100644 +index 9b210edf1f28285fc206644c5d81c7d05ea5a578..ddc562fbdeb2070212019bb23962538795d05ff6 100644 --- a/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/net/minecraft/world/phys/shapes/VoxelShape.java @@ -18,60 +18,545 @@ import net.minecraft.world.phys.Vec3; @@ -36458,11 +36444,11 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 + // Paper start - optimise collisions + if (this.isEmpty) { + throw Util.pauseInIde(new UnsupportedOperationException("No bounds for empty shape.")); - } ++ } + AABB cached = this.cachedBounds; + if (cached != null) { + return cached; -+ } + } + + final ca.spottedleaf.moonrise.patches.collisions.shape.CachedShapeData shapeData = this.cachedShapeData; + @@ -36542,14 +36528,14 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 } public VoxelShape move(final double dx, final double dy, final double dz) { -- return (VoxelShape)(this.isEmpty() +- return this.isEmpty() - ? Shapes.empty() - : new ArrayVoxelShape( - this.shape, - new OffsetDoubleList(this.getCoords(Direction.Axis.X), dx), - new OffsetDoubleList(this.getCoords(Direction.Axis.Y), dy), - new OffsetDoubleList(this.getCoords(Direction.Axis.Z), dz) -- )); +- ); + // Paper start - optimise collisions + if (this.isEmpty) { + return Shapes.empty(); @@ -36712,27 +36698,24 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 + // Paper start - optimise collisions + if (this.isEmpty) { return null; -- } else { -- Vec3 diff = to.subtract(from); -- if (diff.lengthSqr() < 1.0E-7) { -- return null; -- } else { -- Vec3 testPoint = from.add(diff.scale(0.001)); -- return this.shape -- .isFullWide( -- this.findIndex(Direction.Axis.X, testPoint.x - pos.getX()), -- this.findIndex(Direction.Axis.Y, testPoint.y - pos.getY()), -- this.findIndex(Direction.Axis.Z, testPoint.z - pos.getZ()) -- ) -- ? new BlockHitResult(testPoint, Direction.getApproximateNearest(diff.x, diff.y, diff.z).getOpposite(), pos, true) -- : AABB.clip(this.toAabbs(), from, to, pos); -+ } -+ + } + +- Vec3 diff = to.subtract(from); +- if (diff.lengthSqr() < 1.0E-7) { + final Vec3 directionOpposite = to.subtract(from); + if (directionOpposite.lengthSqr() < ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON) { -+ return null; -+ } -+ + return null; + } + +- Vec3 testPoint = from.add(diff.scale(0.001)); +- return this.shape +- .isFullWide( +- this.findIndex(Direction.Axis.X, testPoint.x - pos.getX()), +- this.findIndex(Direction.Axis.Y, testPoint.y - pos.getY()), +- this.findIndex(Direction.Axis.Z, testPoint.z - pos.getZ()) +- ) +- ? new BlockHitResult(testPoint, Direction.getApproximateNearest(diff.x, diff.y, diff.z).getOpposite(), pos, true) +- : AABB.clip(this.toAabbs(), from, to, pos); + final Vec3 fromBehind = from.add(directionOpposite.scale(0.001)); + final double fromBehindOffsetX = fromBehind.x - (double) pos.getX(); + final double fromBehindOffsetY = fromBehind.y - (double) pos.getY(); @@ -36742,13 +36725,13 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 + if (singleAABB != null) { + if (singleAABB.contains(fromBehindOffsetX, fromBehindOffsetY, fromBehindOffsetZ)) { + return new BlockHitResult(fromBehind, Direction.getApproximateNearest(directionOpposite.x, directionOpposite.y, directionOpposite.z).getOpposite(), pos, true); - } ++ } + return clip(singleAABB, from, to, pos); + } + + if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.strictlyContains((VoxelShape) (Object) this, fromBehindOffsetX, fromBehindOffsetY, fromBehindOffsetZ)) { + return new BlockHitResult(fromBehind, Direction.getApproximateNearest(directionOpposite.x, directionOpposite.y, directionOpposite.z).getOpposite(), pos, true); - } ++ } + + return AABB.clip(((VoxelShape) (Object) this).toAabbs(), from, to, pos); + // Paper end - optimise collisions @@ -36759,20 +36742,16 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 + // Paper start - optimise collisions + if (this.isEmpty) { return Optional.empty(); -- } else { -- MutableObject closest = new MutableObject<>(); -- this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { -- double x = Mth.clamp(point.x(), x1, x2); -- double y = Mth.clamp(point.y(), y1, y2); -- double z = Mth.clamp(point.z(), z1, z2); -- Vec3 currentClosest = closest.get(); -- if (currentClosest == null || point.distanceToSqr(x, y, z) < point.distanceToSqr(currentClosest)) { -- closest.setValue(new Vec3(x, y, z)); -- } -- }); -- return Optional.of(Objects.requireNonNull(closest.get())); } -+ + +- MutableObject closest = new MutableObject<>(); +- this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { +- double x = Mth.clamp(point.x(), x1, x2); +- double y = Mth.clamp(point.y(), y1, y2); +- double z = Mth.clamp(point.z(), z1, z2); +- Vec3 currentClosest = closest.get(); +- if (currentClosest == null || point.distanceToSqr(x, y, z) < point.distanceToSqr(currentClosest)) { +- closest.setValue(new Vec3(x, y, z)); + Vec3 ret = null; + double retDistance = Double.MAX_VALUE; + @@ -36787,7 +36766,9 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 + if (dist < retDistance) { + ret = new Vec3(x, y, z); + retDistance = dist; -+ } + } +- }); +- return Optional.of(Objects.requireNonNull(closest.get())); + } + + return Optional.ofNullable(ret); @@ -36809,7 +36790,7 @@ index 60a64339cd3b378f6f04cf5fe29a3ea8c18ec480..26619ecad88175cf76a62a5794aa5899 - if (slice.isEmpty()) { - return Shapes.empty(); - } else { -- return (VoxelShape)(slice.isCubeLike() ? Shapes.block() : slice); +- return slice.isCubeLike() ? Shapes.block() : slice; + // Paper start - optimise collisions + final Direction.Axis axis = direction.getAxis(); + switch (axis) { @@ -36949,7 +36930,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a for (SavedTick pendingTick : this.pendingTicks) { diff --git a/net/minecraft/world/waypoints/WaypointTransmitter.java b/net/minecraft/world/waypoints/WaypointTransmitter.java -index d785e9a69a109d1d7ce7a7e182c215f3d6a35b64..d6f842cbd2060eb56a1e4384b3ea97feea3e73ba 100644 +index e822b8429e8ea2b113ef83310223bc7edb12aad9..2866b750a28cc32c2913d3c1afee95f05956982c 100644 --- a/net/minecraft/world/waypoints/WaypointTransmitter.java +++ b/net/minecraft/world/waypoints/WaypointTransmitter.java @@ -34,7 +34,10 @@ public interface WaypointTransmitter extends Waypoint { diff --git a/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch b/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch index 603941224410..9d8dd84ddc02 100644 --- a/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch +++ b/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch @@ -33491,7 +33491,7 @@ index 109d7b563ee799d998a5773c5a36e61ca3607d46..747755082639436731989d3ee4b3c30a return structureTemplate.save(new CompoundTag()); } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index e11862c7e0617acfb36212cfe349bdade3a5164b..7ae2d491a3b2f379df99ccc649b8bb8cbf2304b9 100644 +index 5bdb7d130cc2e47c9b55f85acae64e83d6ee2546..c3b14d51240b5f6edfc3ecdea04f50774615b98c 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -299,6 +299,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop serverReference.get().runServer(), "Server thread"); thread.setUncaughtExceptionHandler((t, e) -> LOGGER.error("Uncaught exception in server thread", e)); diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index c206c74acc80c281d06a669eb668239dc61018eb..884fa9545a93008fa92863c845aef8f18d88e25a 100644 +index 4346f3bace176e09d9ffb02e9af29a1281071e2a..df4f03f3a346e0ab0074757b3a077b2407135ac3 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -@@ -99,7 +99,7 @@ public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chun - } - // Spigot end - injectDatafixingContext(chunkTag, dataFixContextTag); -- chunkTag = this.dataFixType.update(this.fixerUpper, chunkTag, version, targetVersion); -+ chunkTag = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(this.getDataConverterType(), chunkTag, version, targetVersion); // Paper - rewrite dataconverter system - // Spigot start - if (stopBelowZero) { - chunkTag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); +@@ -100,7 +100,7 @@ public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chun + } + // Spigot end + injectDatafixingContext(chunkTag, dataFixContextTag); +- chunkTag = this.dataFixType.update(this.fixerUpper, chunkTag, version, targetVersion); ++ chunkTag = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(this.getDataConverterType(), chunkTag, version, targetVersion); // Paper - rewrite dataconverter system + // Spigot start + if (stopBelowZero) { + chunkTag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); @@ -118,6 +118,20 @@ public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chun } } @@ -33537,23 +33537,23 @@ index c206c74acc80c281d06a669eb668239dc61018eb..884fa9545a93008fa92863c845aef8f1 return this.upgradeChunkTag(chunkTag, defaultVersion, null, SharedConstants.getCurrentVersion().dataVersion().version()); } diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 2ab055d5cdfb1e2e7cfb6f8a769c3d571acb2861..a45da98735045d55d3da14271c9bbb7a37f3151c 100644 +index 0d4c26d8a086e54f84413dab9595e210e52a43bf..a725a769f865e9f4506394b2fe57f560837720df 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -161,7 +161,7 @@ public class StructureCheck { +@@ -163,7 +163,7 @@ public class StructureCheck { CompoundTag fixedChunkTag; try { - fixedChunkTag = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, chunkTag, version); -+ fixedChunkTag = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, chunkTag, version, ca.spottedleaf.dataconverter.minecraft.util.Version.getCurrentVersion()); // Paper - replace chunk converter - } catch (Exception var12) { - LOGGER.warn("Failed to partially datafix chunk {}", pos, var12); ++ fixedChunkTag = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, chunkTag, version, ca.spottedleaf.dataconverter.minecraft.util.Version.getCurrentVersion()); // Paper - replace chunk converter + } catch (Exception e) { + LOGGER.warn("Failed to partially datafix chunk {}", pos, e); return StructureCheckResult.CHUNK_LOAD_NEEDED; diff --git a/net/minecraft/world/level/levelgen/structure/templatesystem/loader/TemplateSource.java b/net/minecraft/world/level/levelgen/structure/templatesystem/loader/TemplateSource.java -index 780a3eb08b7fb2c385c8e75e2e5f02a9d67297f4..2c7e4a6288f0c7101755de4be8f14449cdc4e01e 100644 +index e61076a9ff3d9bce5c44e548158716db105db3ee..fe1500ebbfb09bef18989c891a19608ec9d4661c 100644 --- a/net/minecraft/world/level/levelgen/structure/templatesystem/loader/TemplateSource.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/loader/TemplateSource.java -@@ -79,7 +79,7 @@ public abstract class TemplateSource { +@@ -71,7 +71,7 @@ public abstract class TemplateSource { public StructureTemplate readStructure(final CompoundTag tag) { StructureTemplate structureTemplate = new StructureTemplate(); int version = NbtUtils.getDataVersion(tag, 500); @@ -33563,7 +33563,7 @@ index 780a3eb08b7fb2c385c8e75e2e5f02a9d67297f4..2c7e4a6288f0c7101755de4be8f14449 } } diff --git a/net/minecraft/world/level/storage/PlayerDataStorage.java b/net/minecraft/world/level/storage/PlayerDataStorage.java -index 41cbb27861f33ad8d7523f3b2fef9a30a69693a9..c5898bfb8b4f075b08090cba2e9f980174e0a326 100644 +index 8eda63e1f07f7998875713447c5f39eea3f85ca4..eddb6ebe3fa50a818e54079b73ba117be0abd195 100644 --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java @@ -98,7 +98,7 @@ public class PlayerDataStorage { diff --git a/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch b/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch index 93dd0dcfb222..224216985f3e 100644 --- a/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch +++ b/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch @@ -28,10 +28,10 @@ and then catch exceptions and close if they fire. Part of this commit was authored by: Spottedleaf, sandtechnology diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c647b1cde27 100644 +index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e7e150804 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -65,7 +65,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -64,7 +64,7 @@ public class Connection extends SimpleChannelInboundHandler> { private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; private final PacketFlow receiving; private volatile boolean sendLoginDisconnect = true; @@ -40,7 +40,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 public Channel channel; public SocketAddress address; // Spigot start -@@ -124,6 +124,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -123,6 +123,10 @@ public class Connection extends SimpleChannelInboundHandler> { public boolean handledLegacyLoginEvent; // Paper - playerloginevent public net.minecraft.server.level.@Nullable ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent public org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status resourcePackStatus; // Paper @@ -51,7 +51,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 public Connection(final PacketFlow receiving) { this.receiving = receiving; -@@ -394,11 +398,38 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -392,11 +396,38 @@ public class Connection extends SimpleChannelInboundHandler> { } public void send(final Packet packet, final @Nullable ChannelFutureListener listener, final boolean flush) { @@ -93,7 +93,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 } } -@@ -407,7 +438,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -405,7 +436,7 @@ public class Connection extends SimpleChannelInboundHandler> { this.flushQueue(); action.accept(this); } else { @@ -102,7 +102,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 } } -@@ -421,21 +452,42 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -419,21 +450,42 @@ public class Connection extends SimpleChannelInboundHandler> { } private void doSendPacket(final Packet packet, final @Nullable ChannelFutureListener listener, final boolean flush) { @@ -149,7 +149,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 } } -@@ -447,16 +499,57 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -445,16 +497,57 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -212,7 +212,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world private static int joinAttemptsThisTick; // Paper - Buffer joins to world -@@ -526,6 +619,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -524,6 +617,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void disconnect(final DisconnectionDetails details) { this.preparing = false; // Spigot @@ -220,7 +220,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 if (this.channel == null) { this.delayedDisconnect = details; } -@@ -715,7 +809,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -705,7 +799,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { if (this.disconnectionHandled) { @@ -229,7 +229,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 } else { this.disconnectionHandled = true; PacketListener packetListener = this.getPacketListener(); -@@ -726,7 +820,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -716,7 +810,7 @@ public class Connection extends SimpleChannelInboundHandler> { ); disconnectListener.onDisconnect(details); } @@ -238,7 +238,7 @@ index 1511cbd2e6123a00d22694353ee4989d539fe0f0..104976b3eb04d80e5be5bd020cf16c64 // Paper start - Add PlayerConnectionCloseEvent if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { /* Player was logged in, either game listener or configuration listener */ -@@ -761,4 +855,96 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -751,4 +845,96 @@ public class Connection extends SimpleChannelInboundHandler> { public void setBandwidthLogger(final LocalSampleLogger bandwidthLogger) { this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwidthLogger); } @@ -372,10 +372,10 @@ index 1480d0db90f5797e3dee19503e52d1e783493ac3..bd76e55ea56dd7c1e232806d1d13a747 + // Paper end } diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index 387ac8a4e67ef07df73ce98d0add0937314ee497..9ae7c79e5088d9e1e3fb7e0dca00bb15fee118b6 100644 +index 77e1c02b74c1f6597fbb5a457bf463fe52de019e..6d506004583b2415ab356e34e2f8d6ac0e39cca2 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -52,11 +52,13 @@ public class ServerConnectionListener { +@@ -51,11 +51,13 @@ public class ServerConnectionListener { // Paper start - prevent blocking on adding a new connection while the server is ticking private final java.util.Queue pending = new java.util.concurrent.ConcurrentLinkedQueue<>(); @@ -389,7 +389,7 @@ index 387ac8a4e67ef07df73ce98d0add0937314ee497..9ae7c79e5088d9e1e3fb7e0dca00bb15 } } // Paper end - prevent blocking on adding a new connection while the server is ticking -@@ -92,6 +94,7 @@ public class ServerConnectionListener { +@@ -87,6 +89,7 @@ public class ServerConnectionListener { } catch (ChannelException var5) { } diff --git a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch index 2aea52bcb239..c54d9031b901 100644 --- a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch @@ -31,18 +31,18 @@ this fix, as the data will remain in the oversized file. Once the server returns to a jar with this fix, the data will be restored. diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 5149635679ec03d881e63effbd79fc193d7e52c8..d628e06a8dbf11b491b323c10a512fde22e72a12 100644 +index 026b1f31d5041786e90ba372a228732aee094c16..dd05d166a3f995e40a16c11c8cfbf86776157fa4 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -69,6 +69,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -68,6 +68,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche this.info = info; this.path = path; this.version = version; + this.initOversizedState(); // Paper if (!Files.isDirectory(externalFileDir)) { throw new IllegalArgumentException("Expected directory, got " + externalFileDir.toAbsolutePath()); - } else { -@@ -465,4 +466,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + } +@@ -463,4 +464,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche private interface CommitOp { void run() throws IOException; } @@ -119,7 +119,7 @@ index 5149635679ec03d881e63effbd79fc193d7e52c8..d628e06a8dbf11b491b323c10a512fde + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index e9316cc08fe4cb4af28583a8cb1ec658243bffd0..aa36e241d49725eb13f00e57d020d4da24add53d 100644 +index 694689c5e0ca65b1b8724b689f3817753dd74834..54e6c67ca05ef1f1350873196dede122f5c911c5 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -241,6 +241,43 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -177,9 +177,9 @@ index e9316cc08fe4cb4af28583a8cb1ec658243bffd0..aa36e241d49725eb13f00e57d020d4da + } + // Paper end - CompoundTag var4; try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { -@@ -290,6 +333,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + return regionChunkInputStream == null ? null : NbtIo.read(regionChunkInputStream); +@@ -283,6 +326,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } else { try (DataOutputStream output = region.getChunkDataOutputStream(pos)) { NbtIo.write(value, output); diff --git a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch index 84c65b9c31ec..565f83bbc7d2 100644 --- a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch @@ -354,7 +354,7 @@ index 0000000000000000000000000000000000000000..ce6b57eeeeb1bd652f4bb53c19dcfbc0 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 91d27b90a9c9c348d3f93624ff8dbff8a70f522c..f4bbccee849ee3711a3b838884e4bcf4e24da039 100644 +index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee102886cbb6fd 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -864,6 +864,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -462,7 +462,7 @@ index 0df8332933203a904bd9ef9efb3c9bce21e65441..1a502cbd8acea9420fa6dd8d716018b5 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index e087d5596979044fe7fbcf7f2cccdae4e81a3d3a..fea6c3b48c4eb162fbdc099fa775bc3161a4dd4e 100644 +index 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8ec54a5473 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -382,6 +382,15 @@ public abstract class Entity @@ -521,10 +521,10 @@ index e087d5596979044fe7fbcf7f2cccdae4e81a3d3a..fea6c3b48c4eb162fbdc099fa775bc31 delta = this.maybeBackOffFromEdge(delta, moverType); Vec3 movement = this.collide(delta); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 8b0abe9c7a3907419f6e4d55ea22fb9bc749f28b..36c0081e3e8f8776293ae619156cd0828fe5b21d 100644 +index f62e535b62d249dd3be19d7c1b02fae8dad31c10..6eb95b979ffe37d78fd68eb57ebe71891beb0d28 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3372,6 +3372,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3380,6 +3380,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void playAttackSound() { } @@ -540,7 +540,7 @@ index 8b0abe9c7a3907419f6e4d55ea22fb9bc749f28b..36c0081e3e8f8776293ae619156cd082 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index c7c53ef16e104ebc48aeb8719783fb4c45d39fc2..5bbb5cbb51953399c7bce547cd6968eb3c6bd130 100644 +index e63ac861b785cf3dccac25404454289c44b7ec9d..8b036640be655c65852e0862e30962e443d3024d 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -211,6 +211,20 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs @@ -565,7 +565,7 @@ index c7c53ef16e104ebc48aeb8719783fb4c45d39fc2..5bbb5cbb51953399c7bce547cd6968eb return this.getControlledVehicle() instanceof Mob riding ? riding.getMoveControl() : this.moveControl; } diff --git a/net/minecraft/world/entity/PathfinderMob.java b/net/minecraft/world/entity/PathfinderMob.java -index c4b4a135f61955c2b87801772a2b31eeeb77bf45..9d12cc2d169f243ba23485e2782bca7064282a36 100644 +index a19d8d4c0075340e8d187d5f8b6ce989567d3163..c661311dfdc1e21e3d6ec65e1e8b953637149675 100644 --- a/net/minecraft/world/entity/PathfinderMob.java +++ b/net/minecraft/world/entity/PathfinderMob.java @@ -17,6 +17,8 @@ public abstract class PathfinderMob extends Mob { @@ -578,7 +578,7 @@ index c4b4a135f61955c2b87801772a2b31eeeb77bf45..9d12cc2d169f243ba23485e2782bca70 return this.getWalkTargetValue(pos, this.level()); } diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 6bc2d38fb990628784deb5ee615e34a0fc320a47..844ced7a271ffb557f3c8f2fcd6a4c6ad499aeae 100644 +index c918154444a05917a3622947d0ddbc29bdb9bead..b13bdc2852504903fa054c42f89299a5d33dfbd3 100644 --- a/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -24,6 +24,7 @@ public class GoalSelector { @@ -640,7 +640,7 @@ index d46e0e3a4a7fc3bb3f1dd695d4cc563778b99db0..c6e9b155c2341c13d569f28f54f0c1d2 } } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index c482c3348267ca2b88109e34291aa860e0cde916..b11b59d80e37d272770ab51a63028fdddfe800d6 100644 +index ca0b7ce4ab535d7112b315a7de1dc5130797ea2d..974d1d7b283aace71f0ea8ef07ba68a17b75af8a 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java @@ -124,6 +124,29 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -674,7 +674,7 @@ index c482c3348267ca2b88109e34291aa860e0cde916..b11b59d80e37d272770ab51a63028fdd public void tick() { if (this.getItem().isEmpty()) { diff --git a/net/minecraft/world/entity/npc/villager/Villager.java b/net/minecraft/world/entity/npc/villager/Villager.java -index a80e6a23cf29cb44943339101f15565dbc19af1f..26108ac0543c7b4195f149c07d8348b5b15b8bdb 100644 +index 084a4a945d4fc6a76878da00e5015c79fc88b47f..e4ba6e200e85f4e226d6a3e68db734f277b89226 100644 --- a/net/minecraft/world/entity/npc/villager/Villager.java +++ b/net/minecraft/world/entity/npc/villager/Villager.java @@ -244,11 +244,35 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re @@ -779,7 +779,7 @@ index f3861c936855a0d9c9170585f4da4ce1cd77b854..3b4cbbc4c8ca1cd3110d1d6ba9e35312 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java -index 3a590d4dc980a2912e9cc043d8c8db4cf9d60803..06ab7c48b18c03af494ab10fc2b584cefc776749 100644 +index f46cca0467bb4da5511bc953ce5b43fa606bf978..445c5cafad71028171c1f261939661775dd7f2bd 100644 --- a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +++ b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java @@ -50,6 +50,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper @@ -790,20 +790,21 @@ index 3a590d4dc980a2912e9cc043d8c8db4cf9d60803..06ab7c48b18c03af494ab10fc2b584ce } public boolean isEnabled() { -@@ -103,11 +104,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -103,12 +104,14 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public boolean suckInItems() { if (HopperBlockEntity.suckInItems(this.level(), this)) { + this.immunize(); // Paper return true; - } else { - for (ItemEntity entity : this.level() - .getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.25, 0.0, 0.25), EntitySelector.ENTITY_STILL_ALIVE)) { - if (HopperBlockEntity.addItem(this, entity)) { -+ this.immunize(); // Paper - return true; - } + } + + for (ItemEntity entity : this.level() + .getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.25, 0.0, 0.25), EntitySelector.ENTITY_STILL_ALIVE)) { + if (HopperBlockEntity.addItem(this, entity)) { ++ this.immunize(); // Paper + return true; } + } @@ -142,4 +145,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public AbstractContainerMenu createMenu(final int containerId, final Inventory inventory) { return new HopperMenu(containerId, inventory, this); @@ -817,7 +818,7 @@ index 3a590d4dc980a2912e9cc043d8c8db4cf9d60803..06ab7c48b18c03af494ab10fc2b584ce + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index c0f901c4ac61a0aa2b480f102feb3669b111f4c0..07c301ba02c7f2c032a29a0ae3bdf95fc522c03b 100644 +index cc492445307ddc08446484d272866f01646cf7b3..a5d46832d4f8a13b0bf67b523c21d5c3b44209a9 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -155,6 +155,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -834,7 +835,7 @@ index c0f901c4ac61a0aa2b480f102feb3669b111f4c0..07c301ba02c7f2c032a29a0ae3bdf95f public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot // Paper start - add paper world config diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index ec01093094f1d4de2708791ae6a5545268a021ae..f904c587fafe7395473450f766354d874e36ebac 100644 +index ef78f286ca14512c3dfccdb8fb06ebe9affa1589..c5c0b01c41055a82e49c1546d4525da0acce13a4 100644 --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java @@ -159,6 +159,10 @@ public class PistonMovingBlockEntity extends BlockEntity { diff --git a/paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch index 29e36520b431..c927369ad44c 100644 --- a/paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch @@ -30,7 +30,7 @@ Additionally, this lets us avoid even allocating new objects for this too, furth reducing memory usage. diff --git a/net/minecraft/world/phys/shapes/IndirectMerger.java b/net/minecraft/world/phys/shapes/IndirectMerger.java -index 7e525297aaca8c18cf1669ab80040475029ff652..b342e4c0260fc5a64e5943e6342de0703233a99b 100644 +index 6c637af546a411d5790ceba9936aa9128d05d97e..e18f24a3941e1102648bac841851a8749f2d9438 100644 --- a/net/minecraft/world/phys/shapes/IndirectMerger.java +++ b/net/minecraft/world/phys/shapes/IndirectMerger.java @@ -10,12 +10,32 @@ public class IndirectMerger implements IndexMerger { @@ -67,7 +67,7 @@ index 7e525297aaca8c18cf1669ab80040475029ff652..b342e4c0260fc5a64e5943e6342de070 this.firstIndices = new int[capacity]; this.secondIndices = new int[capacity]; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index de10ce3faa86d6ed6d528575a083722a8feedf8d..7574443bc098c1a0958b64f1f54e76322e48a2e7 100644 +index ccdaf6043f667b6983e4492cf570947ed5179df1..5c552f618d09fa9456195bbfa643ce4a1a03bd84 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java @@ -343,11 +343,26 @@ public final class Shapes { @@ -117,9 +117,9 @@ index de10ce3faa86d6ed6d528575a083722a8feedf8d..7574443bc098c1a0958b64f1f54e7632 } else if (second.getDouble(secondSize) < first.getDouble(0) - 1.0E-7) { return new NonOverlappingMerger(second, first, true); } else { -- return (IndexMerger)(firstSize == secondSize && Objects.equals(first, second) +- return firstSize == secondSize && Objects.equals(first, second) - ? new IdenticalMerger(first) -- : new IndirectMerger(first, second, firstOnlyMatters, secondOnlyMatters)); +- : new IndirectMerger(first, second, firstOnlyMatters, secondOnlyMatters); + return new IndirectMerger(first, second, firstOnlyMatters, secondOnlyMatters); // Paper - Identical happens more often than Disjoint } } diff --git a/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch b/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch index c09fba8774d1..8605b4256514 100644 --- a/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch +++ b/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize dirt and snow spreading diff --git a/net/minecraft/world/level/block/SpreadingSnowyBlock.java b/net/minecraft/world/level/block/SpreadingSnowyBlock.java -index 6695d7f76daf45ed3e73c4984326b8b59e5a76cc..f868b1ccfa0e373c47344d000f26fbe8507c3510 100644 +index 85666946f8cb23255360bca8efde2ce13abcbc0a..839bfdda7f54e6aabe401db6da1856544b032bf8 100644 --- a/net/minecraft/world/level/block/SpreadingSnowyBlock.java +++ b/net/minecraft/world/level/block/SpreadingSnowyBlock.java @@ -27,8 +27,13 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { @@ -22,8 +22,8 @@ index 6695d7f76daf45ed3e73c4984326b8b59e5a76cc..f868b1ccfa0e373c47344d000f26fbe8 + BlockState aboveState = chunk.getBlockState(above); // Paper - Perf: optimize dirt and snow spreading if (aboveState.is(Blocks.SNOW) && aboveState.getValue(SnowLayerBlock.LAYERS) == 1) { return true; - } else if (aboveState.getFluidState().isFull()) { -@@ -40,8 +45,14 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { + } +@@ -42,8 +47,14 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { } private static boolean canPropagate(final BlockState state, final LevelReader level, final BlockPos pos) { @@ -39,7 +39,7 @@ index 6695d7f76daf45ed3e73c4984326b8b59e5a76cc..f868b1ccfa0e373c47344d000f26fbe8 } @Override -@@ -50,7 +61,14 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { +@@ -52,7 +63,14 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { Registry blocks = level.registryAccess().lookupOrThrow(Registries.BLOCK); Optional baseBlock = blocks.getOptional(this.baseBlock); if (!baseBlock.isEmpty()) { @@ -55,7 +55,7 @@ index 6695d7f76daf45ed3e73c4984326b8b59e5a76cc..f868b1ccfa0e373c47344d000f26fbe8 // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, baseBlock.get().defaultBlockState()).isCancelled()) { return; -@@ -63,8 +81,20 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { +@@ -65,8 +83,20 @@ public abstract class SpreadingSnowyBlock extends SnowyBlock { for (int i = 0; i < 4; i++) { BlockPos testPos = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); diff --git a/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch index 717e499cd9b0..fdb6b9a8c8d8 100644 --- a/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch @@ -86,7 +86,7 @@ index 0003a548fe4a48ecfe3534f3de309a920568b773..fae764ffd6858c920cafd2fba4444793 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/CompressionDecoder.java b/net/minecraft/network/CompressionDecoder.java -index 2f660186f00414b37fa5c01d00c048173feaef13..fe3f0b59561e7b7236aba9cca2a13cee8955a933 100644 +index 8497561d90bf6165d1e56a044b3b409c234e1ef8..ddd5daf92d03dd343e6164d55fff638509175e6d 100644 --- a/net/minecraft/network/CompressionDecoder.java +++ b/net/minecraft/network/CompressionDecoder.java @@ -12,14 +12,22 @@ import java.util.zip.Inflater; @@ -169,7 +169,7 @@ index 2f660186f00414b37fa5c01d00c048173feaef13..fe3f0b59561e7b7236aba9cca2a13cee this.validateDecompressed = validateDecompressed; } diff --git a/net/minecraft/network/CompressionEncoder.java b/net/minecraft/network/CompressionEncoder.java -index 319325e741cc314b84844bb49ea569aaf014f319..20b5cfe1ce36d74cd6b2f95566a1bc34fc0aaa7f 100644 +index 595db570b0ade9cad7de77d2ab7b10d9e68699df..ac095f59d9f17d8239d6493d1c1e3942139b039f 100644 --- a/net/minecraft/network/CompressionEncoder.java +++ b/net/minecraft/network/CompressionEncoder.java @@ -6,17 +6,30 @@ import io.netty.handler.codec.MessageToByteEncoder; @@ -207,33 +207,34 @@ index 319325e741cc314b84844bb49ea569aaf014f319..20b5cfe1ce36d74cd6b2f95566a1bc34 int uncompressedLength = uncompressed.readableBytes(); if (uncompressedLength > 8388608) { throw new IllegalArgumentException("Packet too big (is " + uncompressedLength + ", should be less than 8388608)"); -@@ -25,6 +38,7 @@ public class CompressionEncoder extends MessageToByteEncoder { - VarInt.write(out, 0); - out.writeBytes(uncompressed); - } else { -+ if (this.deflater != null) { // Paper - Use Velocity cipher - byte[] input = new byte[uncompressedLength]; - uncompressed.readBytes(input); - VarInt.write(out, input.length); -@@ -37,6 +51,17 @@ public class CompressionEncoder extends MessageToByteEncoder { - } +@@ -26,6 +39,7 @@ public class CompressionEncoder extends MessageToByteEncoder { + VarInt.write(out, 0); + out.writeBytes(uncompressed); + } else { ++ if (this.deflater != null) { // Paper - Use Velocity cipher + byte[] input = new byte[uncompressedLength]; + uncompressed.readBytes(input); + VarInt.write(out, input.length); +@@ -38,6 +52,18 @@ public class CompressionEncoder extends MessageToByteEncoder { + } - this.deflater.reset(); -+ // Paper start - Use Velocity cipher -+ return; -+ } + this.deflater.reset(); ++ // Paper start - Use Velocity cipher ++ return; ++ } + -+ VarInt.write(out, uncompressedLength); -+ final ByteBuf compatibleIn = com.velocitypowered.natives.util.MoreByteBufUtils.ensureCompatible(ctx.alloc(), this.compressor, uncompressed); -+ try { -+ this.compressor.deflate(compatibleIn, out); -+ } finally { -+ compatibleIn.release(); -+ } - } ++ VarInt.write(out, uncompressedLength); ++ final ByteBuf compatibleIn = com.velocitypowered.natives.util.MoreByteBufUtils.ensureCompatible(ctx.alloc(), this.compressor, uncompressed); ++ try { ++ this.compressor.deflate(compatibleIn, out); ++ } finally { ++ compatibleIn.release(); ++ } ++ // Paper end - Use Velocity cipher } } -@@ -48,4 +73,31 @@ public class CompressionEncoder extends MessageToByteEncoder { + +@@ -48,4 +74,31 @@ public class CompressionEncoder extends MessageToByteEncoder { public void setThreshold(final int threshold) { this.threshold = threshold; } @@ -266,10 +267,10 @@ index 319325e741cc314b84844bb49ea569aaf014f319..20b5cfe1ce36d74cd6b2f95566a1bc34 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 104976b3eb04d80e5be5bd020cf16c647b1cde27..5a23f95aff982ecc58d2e2bc994f4e495285069c 100644 +index d14aea970ce98edfe3dc3692e707334e7e150804..0f06d509125e72ec11d263d0d5c2179d65f6d8dd 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -740,11 +740,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -730,11 +730,22 @@ public class Connection extends SimpleChannelInboundHandler> { return connection; } @@ -296,7 +297,7 @@ index 104976b3eb04d80e5be5bd020cf16c647b1cde27..5a23f95aff982ecc58d2e2bc994f4e49 public boolean isEncrypted() { return this.encrypted; -@@ -782,16 +793,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -772,16 +783,17 @@ public class Connection extends SimpleChannelInboundHandler> { public void setupCompression(final int threshold, final boolean validateDecompressed) { if (threshold >= 0) { @@ -318,10 +319,10 @@ index 104976b3eb04d80e5be5bd020cf16c647b1cde27..5a23f95aff982ecc58d2e2bc994f4e49 this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_THRESHOLD_SET); // Paper - Add Channel initialization listeners } else { diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index 391435cf3d279c8f5a889702b50f57626864c7bb..19a77c8269c3f1998985d533d9099c7e6cf76af4 100644 +index 6d506004583b2415ab356e34e2f8d6ac0e39cca2..474b7f06223514d95bad3d91356dfaa5435b77f5 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -77,6 +77,10 @@ public class ServerConnectionListener { +@@ -76,6 +76,10 @@ public class ServerConnectionListener { LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled."); } // Paper end - Warn people with console access that HAProxy is in use. @@ -333,7 +334,7 @@ index 391435cf3d279c8f5a889702b50f57626864c7bb..19a77c8269c3f1998985d533d9099c7e .add( new ServerBootstrap() diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index c1edad046cbdd1627edba58bc06aef5c058e79eb..3a0d47a716ce5c5345640ed67ac306101791892b 100644 +index 50e4f4037702875fe7755b169947abd800b06e7b..722c832ce18fd930d9fdb4f718dc13bfc962e5dd 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -251,11 +251,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -346,6 +347,6 @@ index c1edad046cbdd1627edba58bc06aef5c058e79eb..3a0d47a716ce5c5345640ed67ac30610 this.state = ServerLoginPacketListenerImpl.State.AUTHENTICATING; - this.connection.setEncryptionKey(decryptCipher, encryptCipher); + this.connection.setEncryptionKey(secretKey); // Paper - Use Velocity cipher - } catch (CryptException var7) { - throw new IllegalStateException("Protocol error", var7); + } catch (CryptException e) { + throw new IllegalStateException("Protocol error", e); } diff --git a/paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch index 21a8d5e24dda..e4da422f54ff 100644 --- a/paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -7,7 +7,7 @@ Optimise the stream.anyMatch statement to move to a bitset where we can replace the call with a single bitwise operation. diff --git a/net/minecraft/world/entity/ai/goal/Goal.java b/net/minecraft/world/entity/ai/goal/Goal.java -index 5746eefd9e8fa851e74ccf6b5d889a9f8e6fc1e0..81fa892212f586e8cd7938556eeaa9f9dc2654aa 100644 +index aa5f0e00daf26650b943a24676638581e494a112..60e0d618c603caef5e3516c9fdfc63ff45a7cdff 100644 --- a/net/minecraft/world/entity/ai/goal/Goal.java +++ b/net/minecraft/world/entity/ai/goal/Goal.java @@ -7,7 +7,15 @@ import net.minecraft.world.entity.Entity; @@ -69,7 +69,7 @@ index 5746eefd9e8fa851e74ccf6b5d889a9f8e6fc1e0..81fa892212f586e8cd7938556eeaa9f9 // Paper end - Mob Goal API diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 844ced7a271ffb557f3c8f2fcd6a4c6ad499aeae..75d8953845b2e9acb62b19a859d0e39fd63533eb 100644 +index b13bdc2852504903fa054c42f89299a5d33dfbd3..1ddf8796d14d472bec48546f25ac4583d483c8e9 100644 --- a/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -23,7 +23,8 @@ public class GoalSelector { @@ -119,27 +119,24 @@ index 844ced7a271ffb557f3c8f2fcd6a4c6ad499aeae..75d8953845b2e9acb62b19a859d0e39f goal.stop(); } } -@@ -95,11 +96,14 @@ public class GoalSelector { +@@ -95,8 +96,14 @@ public class GoalSelector { profiler.push("goalUpdate"); - for (WrappedGoal goalx : this.availableGoals) { -- if (!goalx.isRunning() -- && !goalContainsAnyFlags(goalx, this.disabledFlags) -- && goalCanBeReplacedForAllFlags(goalx, this.lockedFlags) -- && goalx.canUse()) { -- for (Goal.Flag flag : goalx.getFlags()) { + for (WrappedGoal goal : this.availableGoals) { +- if (!goal.isRunning() && !goalContainsAnyFlags(goal, this.disabledFlags) && goalCanBeReplacedForAllFlags(goal, this.lockedFlags) && goal.canUse()) { +- for (Goal.Flag flag : goal.getFlags()) { + // Paper start -+ if (!goalx.isRunning() && !goalContainsAnyFlags(goalx, this.goalTypes) && goalCanBeReplacedForAllFlags(goalx, this.lockedFlags) && goalx.canUse()) { -+ long flagIterator = goalx.getFlags().getBackingSet(); -+ int wrappedGoalSize = goalx.getFlags().size(); ++ if (!goal.isRunning() && !goalContainsAnyFlags(goal, this.goalTypes) && goalCanBeReplacedForAllFlags(goal, this.lockedFlags) && goal.canUse()) { ++ long flagIterator = goal.getFlags().getBackingSet(); ++ int wrappedGoalSize = goal.getFlags().size(); + for (int i = 0; i < wrappedGoalSize; ++i) { + final Goal.Flag flag = GOAL_FLAG_VALUES[Long.numberOfTrailingZeros(flagIterator)]; + flagIterator ^= ca.spottedleaf.concurrentutil.util.IntegerUtil.getTrailingBit(flagIterator); + // Paper end WrappedGoal currentGoal = this.lockedFlags.getOrDefault(flag, NO_GOAL); currentGoal.stop(); - this.lockedFlags.put(flag, goalx); -@@ -131,11 +135,11 @@ public class GoalSelector { + this.lockedFlags.put(flag, goal); +@@ -128,11 +135,11 @@ public class GoalSelector { } public void disableControlFlag(final Goal.Flag flag) { diff --git a/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch b/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch index 1676c4705eaf..74fba9a629e2 100644 --- a/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch +++ b/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch @@ -7,7 +7,7 @@ Co-authored-by: Bjarne Koll Co-authored-by: Spottedleaf diff --git a/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/net/minecraft/world/entity/ai/behavior/GateBehavior.java -index 135d932a31a557ff06643fb563262423d48cd540..9fb025b05cacc901d72d93c16cf2b7e48d4dd9a6 100644 +index c16463febcf74e20e8e984bc19e3179a0f5f4ed1..3adfb334068d3722329f91011c41d5e59b1956c9 100644 --- a/net/minecraft/world/entity/ai/behavior/GateBehavior.java +++ b/net/minecraft/world/entity/ai/behavior/GateBehavior.java @@ -69,7 +69,7 @@ public class GateBehavior implements BehaviorControl @@ -57,7 +57,7 @@ index 135d932a31a557ff06643fb563262423d48cd540..9fb025b05cacc901d72d93c16cf2b7e4 @Override @@ -118,24 +132,36 @@ public class GateBehavior implements BehaviorControl - public static enum RunningPolicy { + public enum RunningPolicy { RUN_ONE { + // Paper start - Perf: Remove streams from hot code @Override @@ -98,7 +98,7 @@ index 135d932a31a557ff06643fb563262423d48cd540..9fb025b05cacc901d72d93c16cf2b7e4 } } diff --git a/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index 75233df622242db6c23f7a1a5812bf25942bca41..133aab614b102419ec731e901858c0347076bae9 100644 +index 600633670eb269ab1f4f50865942c46ed4c66fc6..9008b12745628fdcc225415e20e740192185bdd8 100644 --- a/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/net/minecraft/world/entity/ai/gossip/GossipContainer.java @@ -28,7 +28,7 @@ import net.minecraft.util.VisibleForDebug; @@ -133,7 +133,7 @@ index 75233df622242db6c23f7a1a5812bf25942bca41..133aab614b102419ec731e901858c034 + List entries = this.decompress(); // Paper - Perf: Remove streams from hot code if (entries.isEmpty()) { return Collections.emptyList(); - } else { + } @@ -176,7 +190,23 @@ public class GossipContainer { private final Object2IntMap entries = new Object2IntOpenHashMap<>(); diff --git a/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch index b1512ccfe900..bfbab45f3293 100644 --- a/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch +++ b/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch @@ -16,25 +16,24 @@ This lets us get faster foreach iteration, as well as avoids map lookups on the values when needed. diff --git a/net/minecraft/world/level/pathfinder/PathFinder.java b/net/minecraft/world/level/pathfinder/PathFinder.java -index bb36ebf3a57cf1de98506a6391d3273b0f8e0f76..7564a67d2d63c3a7f95e1d6008e7308620653774 100644 +index 53aa6995d18cae5663d392e606c049e2e9138a99..2809bf033f37559ea66f9d6d61130926679d75cc 100644 --- a/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -54,8 +54,12 @@ public class PathFinder { - if (from == null) { +@@ -55,20 +55,24 @@ public class PathFinder { return null; - } else { -- Map tos = targets.stream() -- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), Function.identity())); -+ // Paper start - Perf: remove streams and optimize collection -+ List> tos = Lists.newArrayList(); -+ for (BlockPos pos : targets) { -+ tos.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); -+ } -+ // Paper end - Perf: remove streams and optimize collection - Path path = this.findPath(from, tos, maxPathLength, reachRange, maxVisitedNodesMultiplier); - this.nodeEvaluator.done(); - return path; -@@ -63,12 +67,12 @@ public class PathFinder { + } + +- Map tos = targets.stream() +- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), Function.identity())); ++ // Paper start - Perf: remove streams and optimize collection ++ List> tos = Lists.newArrayList(); ++ for (BlockPos pos : targets) { ++ tos.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); ++ } ++ // Paper end - Perf: remove streams and optimize collection + Path path = this.findPath(from, tos, maxPathLength, reachRange, maxVisitedNodesMultiplier); + this.nodeEvaluator.done(); + return path; } private @Nullable Path findPath( @@ -81,11 +80,14 @@ index bb36ebf3a57cf1de98506a6391d3273b0f8e0f76..7564a67d2d63c3a7f95e1d6008e73086 - Optional optPath = !reachedTargets.isEmpty() - ? reachedTargets.stream() -- .map(targetx -> this.reconstructPath(targetx.getBestNode(), targetMap.get(targetx), true)) +- .map(target -> this.reconstructPath(target.getBestNode(), targetMap.get(target), true)) - .min(Comparator.comparingInt(Path::getNodeCount)) - : targets.stream() -- .map(targetx -> this.reconstructPath(targetx.getBestNode(), targetMap.get(targetx), false)) +- .map(target -> this.reconstructPath(target.getBestNode(), targetMap.get(target), false)) - .min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount)); +- profiler.pop(); +- if (optPath.isEmpty()) { +- return null; + Path best = null; + boolean entryListIsEmpty = reachedTargets.isEmpty(); + Comparator comparator = entryListIsEmpty @@ -96,23 +98,21 @@ index bb36ebf3a57cf1de98506a6391d3273b0f8e0f76..7564a67d2d63c3a7f95e1d6008e73086 + if (best == null || comparator.compare(path, best) < 0) { + best = path; + } -+ } - profiler.pop(); -- if (optPath.isEmpty()) { -- return null; -- } else { -- Path path = optPath.get(); -- if (captureDebug) { -- path.setDebug(this.openSet.getHeap(), closedSet.toArray(Node[]::new), targets); + } +- +- Path path = optPath.get(); +- if (captureDebug) { +- path.setDebug(this.openSet.getHeap(), closedSet.toArray(Node[]::new), targets); ++ profiler.pop(); + if (captureDebug && best != null) { + Set set = Sets.newHashSet(); + for(Map.Entry entry : targets) { + set.add(entry.getKey()); - } -- -- return path; ++ } + best.setDebug(this.openSet.getHeap(), closedSet.toArray(Node[]::new), set); } +- +- return path; + return best; + // Paper end - Perf: remove streams and optimize collection } diff --git a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch index cee2bb03b86a..944b36731026 100644 --- a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ b/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch @@ -48,10 +48,10 @@ index cff05f64af7f425b77cbbd7680c5cc592faa798c..0ab4080c8e30d5ee14ce5fcbac64b031 serverEntity.getLastSentYRot(), entity.getType(), diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 23ae1694c3d5fffdb2277316f66c5fd59157f5ca..be28a41084d656c44b611cf3a01ba89de610d5b2 100644 +index 7f879bc44354c9fac0238208db12b55a948982fb..55cfe38c0daa3ca71a71bf8c7d88fd613fabd82d 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1361,6 +1361,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1357,6 +1357,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ChunkMap.this.level.debugSynchronizers().startTrackingEntity(player, this.entity); } // Paper end - entity tracking events @@ -60,7 +60,7 @@ index 23ae1694c3d5fffdb2277316f66c5fd59157f5ca..be28a41084d656c44b611cf3a01ba89d } else { this.removePlayer(player); diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 6774d12d04fa848624fb8bf7a3c2b8bcb88f6e8f..19bb751d3e9c347fe2446412f85c9f28ec8212e6 100644 +index a62ec41b1319857f0d6cd223d013a92b1e2c2b0d..5fad52157fc22755196ce9eaddaa2bc23c5bb86b 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -89,6 +89,13 @@ public class ServerEntity { diff --git a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch index 721b1748e12f..0589e5cb51f9 100644 --- a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch @@ -2321,7 +2321,7 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index f4bbccee849ee3711a3b838884e4bcf4e24da039..0b9fbf0ae658f0b3e9c6106a42fb70948b6fb9be 100644 +index b5d63d7b848c11ed322d512adeee102886cbb6fd..a30d47d935439896602078c51ba13d13d2109fc2 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -233,6 +233,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -2347,10 +2347,10 @@ index f4bbccee849ee3711a3b838884e4bcf4e24da039..0b9fbf0ae658f0b3e9c6106a42fb7094 return toLevel.dimension() != Level.NETHER || this.getGameRules().get(GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS); } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 07c301ba02c7f2c032a29a0ae3bdf95fc522c03b..7e4cf8a13e0ff2198cb7b6d80fb3fa343339943b 100644 +index a5d46832d4f8a13b0bf67b523c21d5c3b44209a9..7e72b8c9ba54ce93dcf27c0ff984ab618e470cba 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2153,6 +2153,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2159,6 +2159,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } @@ -2365,11 +2365,11 @@ index 07c301ba02c7f2c032a29a0ae3bdf95fc522c03b..7e4cf8a13e0ff2198cb7b6d80fb3fa34 + } + // Paper end - optimize redstone (Alternate Current) + - public static enum ExplosionInteraction implements StringRepresentable { + public enum ExplosionInteraction implements StringRepresentable { NONE("none"), BLOCK("block"), diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index a00002774755eb90a0b772fe742b30a5e09452cf..1e863e97bd1dc99ed6e2c0602f78f457ac618965 100644 +index 5bdeaa9ae20de9f42e760d2207219d5f22d95e9b..0e285f38d282b29f625c5578ee1871a6c2b8585d 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -269,7 +269,7 @@ public class RedStoneWireBlock extends Block { diff --git a/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index e8d5af42de9b..596b1934c9ab 100644 --- a/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -8,10 +8,10 @@ This ensures at least a valid version of the chunk exists on disk, even if outdated diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index d628e06a8dbf11b491b323c10a512fde22e72a12..fc712f9dbc893a6dee8ccecc54d0af07659dee62 100644 +index dd05d166a3f995e40a16c11c8cfbf86776157fa4..9cbf5b9b2ebedb9e33cd84a8237708df2829a94d 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -25,6 +25,7 @@ import org.slf4j.Logger; +@@ -24,6 +24,7 @@ import org.slf4j.Logger; public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system private static final Logger LOGGER = LogUtils.getLogger(); @@ -19,7 +19,7 @@ index d628e06a8dbf11b491b323c10a512fde22e72a12..fc712f9dbc893a6dee8ccecc54d0af07 private static final int SECTOR_BYTES = 4096; @VisibleForTesting protected static final int SECTOR_INTS = 1024; -@@ -453,6 +454,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -451,6 +452,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche this.pos = pos; } @@ -45,7 +45,7 @@ index d628e06a8dbf11b491b323c10a512fde22e72a12..fc712f9dbc893a6dee8ccecc54d0af07 public void close() throws IOException { ByteBuffer result = ByteBuffer.wrap(this.buf, 0, this.count); diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index aa36e241d49725eb13f00e57d020d4da24add53d..5fa64ff30b8252f139ca7f77c14352c384c8c0e5 100644 +index 54e6c67ca05ef1f1350873196dede122f5c911c5..6875c3728544bd3b5172c9a3c3f01d033f158d50 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -16,6 +16,7 @@ import net.minecraft.world.level.ChunkPos; @@ -81,7 +81,7 @@ index aa36e241d49725eb13f00e57d020d4da24add53d..5fa64ff30b8252f139ca7f77c14352c3 return writeData; } -@@ -331,9 +345,18 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -324,9 +338,18 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise if (value == null) { region.clear(pos); } else { @@ -101,7 +101,7 @@ index aa36e241d49725eb13f00e57d020d4da24add53d..5fa64ff30b8252f139ca7f77c14352c3 } } } -@@ -376,4 +399,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -369,4 +392,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public RegionStorageInfo info() { return this.info; } diff --git a/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch index 8aad6f7a88e2..f33ad87facea 100644 --- a/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch +++ b/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch @@ -33,10 +33,10 @@ index 0cfdbdee091f43ca011bc68f7479eb7b84801b09..8d9ce3d301d5f7e4106587ae00adb8dd scopedCollector.forChild(entity.problemPath()), entity.registryAccess() ); diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 2cdbb5f9bace96a8c4ad7fc4de17678ec0db8a6c..6b19f8cd8655cc52a0d8deadb9ca9f24473637a4 100644 +index a1ee86c18c17e14ebf98f0e72680543addc4c7fa..1ee78f52205cbb0b254a28999f3707ccccbe998e 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1647,7 +1647,18 @@ public class EntityType implements EntityTypeTest, +@@ -1641,7 +1641,18 @@ public class EntityType implements EntityTypeTest, } public static Stream loadEntitiesRecursive(final ValueInput.ValueInputList entities, final Level level, final EntitySpawnReason reason) { @@ -56,10 +56,10 @@ index 2cdbb5f9bace96a8c4ad7fc4de17678ec0db8a6c..6b19f8cd8655cc52a0d8deadb9ca9f24 return entity; })); diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java -index 04045397dff89870316d0d374b9e472540c3298d..b1cd822c114b99a25fad2e649ca44596109aa0e5 100644 +index 0326b79fea3f563c3cdfa8f7cf1a3af0e4f08d38..4bd083ecdea207ee5689760fccc9ce8a5a958d57 100644 --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -95,7 +95,18 @@ public class EntityStorage implements EntityPersistentStorage { +@@ -92,7 +92,18 @@ public class EntityStorage implements EntityPersistentStorage { } else { try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(ChunkAccess.problemPath(pos), LOGGER)) { ListTag entities = new ListTag(); diff --git a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 7e2c6bbe7598..7f6dca4d88cb 100644 --- a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -55,10 +55,10 @@ index a6f9435a8e2a6c8cc05bd3873cb6fc0ec98973b8..d44fd9eea0ccb09c894d6431ede8a4c2 this.used.set(position, position + size); } diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 5e77906d77da82b23fbd6e8d16fbd0847c83f4da..e077797cefffcb9db627cab12c7d88245e5baa69 100644 +index 9cbf5b9b2ebedb9e33cd84a8237708df2829a94d..a4030f8306843eb4a0feb79776ce505faa099b8d 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -47,6 +47,363 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -46,6 +46,363 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @VisibleForTesting protected final RegionBitmap usedSectors = new RegionBitmap(); @@ -423,75 +423,58 @@ index 5e77906d77da82b23fbd6e8d16fbd0847c83f4da..e077797cefffcb9db627cab12c7d8824 @Override public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(final net.minecraft.nbt.CompoundTag data, final ChunkPos pos) throws IOException { @@ -75,6 +432,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche - throw new IllegalArgumentException("Expected directory, got " + externalFileDir.toAbsolutePath()); - } else { - this.externalFileDir = externalFileDir; -+ this.canRecalcHeader = info.dfuType()[0] == net.minecraft.util.datafix.DataFixTypes.CHUNK; // Paper - add can recalc flag - this.offsets = this.header.asIntBuffer(); - this.offsets.limit(1024); - this.header.position(4096); + } + + this.externalFileDir = externalFileDir; ++ this.canRecalcHeader = info.dfuType()[0] == net.minecraft.util.datafix.DataFixTypes.CHUNK; // Paper - add can recalc flag + this.offsets = this.header.asIntBuffer(); + this.offsets.limit(1024); + this.header.position(4096); @@ -95,11 +453,13 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche - long size = Files.size(path); + long size = Files.size(path); -- for (int i = 0; i < 1024; i++) { -+ boolean needsHeaderRecalc = false; // Paper - recalculate header on header corruption -+ boolean hasBackedUp = false; // Paper - recalculate header on header corruption -+ for (int i = 0; i < 1024; i++) { final int headerLocation = i; // Paper - we expect this to be the header location - int offset = this.offsets.get(i); - if (offset != 0) { -- int sectorNumber = getSectorNumber(offset); -- int numSectors = getNumSectors(offset); -+ int sectorNumber = getSectorNumber(offset); // Paper - we expect this to be offset in file in sectors -+ int numSectors = getNumSectors(offset); // Paper - diff on change, we expect this to be sector length of region - watch out for reassignments - // Spigot start - if (numSectors == 255) { - // We're maxed out, so we need to read the proper length from the section +- for (int i = 0; i < 1024; i++) { ++ boolean needsHeaderRecalc = false; // Paper - recalculate header on header corruption ++ boolean hasBackedUp = false; // Paper - recalculate header on header corruption ++ for (int i = 0; i < 1024; i++) { final int headerLocation = i; // Paper - we expect this to be the header location + int offset = this.offsets.get(i); + if (offset != 0) { +- int sectorNumber = getSectorNumber(offset); +- int numSectors = getNumSectors(offset); ++ int sectorNumber = getSectorNumber(offset); // Paper - we expect this to be offset in file in sectors ++ int numSectors = getNumSectors(offset); // Paper - diff on change, we expect this to be sector length of region - watch out for reassignments + // Spigot start + if (numSectors == 255) { + // We're maxed out, so we need to read the proper length from the section @@ -110,18 +470,62 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche - // Spigot end - if (sectorNumber < 2) { - LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i, sectorNumber); -- this.offsets.put(i, 0); -+ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change - } else if (numSectors == 0) { - LOGGER.warn("Region file {} has an invalid sector at index: {}; size has to be > 0", path, i); -- this.offsets.put(i, 0); -+ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change - } else if (sectorNumber * 4096L > size) { - LOGGER.warn("Region file {} has an invalid sector at index: {}; sector {} is out of bounds", path, i, sectorNumber); -- this.offsets.put(i, 0); -+ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change - } else { -- this.usedSectors.force(sectorNumber, numSectors); -+ //this.usedSectors.force(sectorNumber, numSectors); // Paper - move this down so we can check if it fails to allocate -+ } -+ // Paper start - recalculate header on header corruption -+ if (sectorNumber < 2 || numSectors <= 0 || ((long)sectorNumber * 4096L) > size) { -+ if (this.canRecalcHeader) { -+ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + "! Recalculating header..."); -+ needsHeaderRecalc = true; -+ break; -+ } else { -+ // location = chunkX | (chunkZ << 5); -+ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + -+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header"); -+ if (!hasBackedUp) { -+ hasBackedUp = true; -+ this.backupRegionFile(); -+ } -+ this.timestamps.put(headerLocation, 0); // be consistent, delete the timestamp too -+ this.offsets.put(headerLocation, 0); // delete the entry from header -+ continue; -+ } - } -+ boolean failedToAllocate = !this.usedSectors.tryAllocate(sectorNumber, numSectors); -+ if (failedToAllocate) { -+ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.path.toAbsolutePath()); -+ } -+ if (failedToAllocate & !this.canRecalcHeader) { + // Spigot end + if (sectorNumber < 2) { + LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i, sectorNumber); +- this.offsets.put(i, 0); ++ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change + } else if (numSectors == 0) { + LOGGER.warn("Region file {} has an invalid sector at index: {}; size has to be > 0", path, i); +- this.offsets.put(i, 0); ++ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change + } else if (sectorNumber * 4096L > size) { + LOGGER.warn("Region file {} has an invalid sector at index: {}; sector {} is out of bounds", path, i, sectorNumber); +- this.offsets.put(i, 0); ++ //this.offsets.put(i, 0); // Paper - we catch this, but need it in the header for the summary change + } else { +- this.usedSectors.force(sectorNumber, numSectors); ++ //this.usedSectors.force(sectorNumber, numSectors); // Paper - move this down so we can check if it fails to allocate ++ } ++ // Paper start - recalculate header on header corruption ++ if (sectorNumber < 2 || numSectors <= 0 || ((long)sectorNumber * 4096L) > size) { ++ if (this.canRecalcHeader) { ++ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + "! Recalculating header..."); ++ needsHeaderRecalc = true; ++ break; ++ } else { + // location = chunkX | (chunkZ << 5); + LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + -+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header"); ++ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header"); + if (!hasBackedUp) { + hasBackedUp = true; + this.backupRegionFile(); @@ -500,21 +483,38 @@ index 5e77906d77da82b23fbd6e8d16fbd0847c83f4da..e077797cefffcb9db627cab12c7d8824 + this.offsets.put(headerLocation, 0); // delete the entry from header + continue; + } -+ needsHeaderRecalc |= failedToAllocate; -+ // Paper end - recalculate header on header corruption ++ } ++ boolean failedToAllocate = !this.usedSectors.tryAllocate(sectorNumber, numSectors); ++ if (failedToAllocate) { ++ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.path.toAbsolutePath()); } ++ if (failedToAllocate & !this.canRecalcHeader) { ++ // location = chunkX | (chunkZ << 5); ++ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + ++ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header"); ++ if (!hasBackedUp) { ++ hasBackedUp = true; ++ this.backupRegionFile(); ++ } ++ this.timestamps.put(headerLocation, 0); // be consistent, delete the timestamp too ++ this.offsets.put(headerLocation, 0); // delete the entry from header ++ continue; ++ } ++ needsHeaderRecalc |= failedToAllocate; ++ // Paper end - recalculate header on header corruption } -+ // Paper start - recalculate header on header corruption -+ // we move the recalc here so comparison to old header is correct when logging to console -+ if (needsHeaderRecalc) { // true if header gave us overlapping allocations or had other issues -+ LOGGER.error("Recalculating regionfile " + this.path.toAbsolutePath() + ", header gave erroneous offsets & locations"); -+ this.recalculateHeader(); -+ } -+ // Paper end } ++ // Paper start - recalculate header on header corruption ++ // we move the recalc here so comparison to old header is correct when logging to console ++ if (needsHeaderRecalc) { // true if header gave us overlapping allocations or had other issues ++ LOGGER.error("Recalculating regionfile " + this.path.toAbsolutePath() + ", header gave erroneous offsets & locations"); ++ this.recalculateHeader(); ++ } ++ // Paper end } } -@@ -131,10 +535,34 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + +@@ -130,10 +534,34 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } private Path getExternalChunkPath(final ChunkPos pos) { @@ -550,77 +550,79 @@ index 5e77906d77da82b23fbd6e8d16fbd0847c83f4da..e077797cefffcb9db627cab12c7d8824 public synchronized @Nullable DataInputStream getChunkDataInputStream(final ChunkPos pos) throws IOException { int offset = this.getOffset(pos); if (offset == 0) { -@@ -155,30 +583,67 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche - buffer.flip(); - if (buffer.remaining() < 5) { - LOGGER.error("Chunk {} header is truncated: expected {} but read {}", pos, sectorsLength, buffer.remaining()); +@@ -155,6 +583,11 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + buffer.flip(); + if (buffer.remaining() < 5) { + LOGGER.error("Chunk {} header is truncated: expected {} but read {}", pos, sectorsLength, buffer.remaining()); ++ // Paper start - recalculate header on regionfile corruption ++ if (this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ // Paper end - recalculate header on regionfile corruption + return null; + } + +@@ -162,6 +595,11 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + byte versionId = buffer.get(); + if (length == 0) { + LOGGER.warn("Chunk {} is allocated, but stream is missing", pos); ++ // Paper start - recalculate header on regionfile corruption ++ if (this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ // Paper end - recalculate header on regionfile corruption + return null; + } + +@@ -169,18 +607,45 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + if (isExternalStreamChunk(versionId)) { + if (streamLength != 0) { + LOGGER.warn("Chunk has both internal and external streams"); + // Paper start - recalculate header on regionfile corruption + if (this.canRecalcHeader && this.recalculateHeader()) { + return this.getChunkDataInputStream(pos); + } + // Paper end - recalculate header on regionfile corruption - return null; - } else { - int length = buffer.getInt(); - byte versionId = buffer.get(); - if (length == 0) { - LOGGER.warn("Chunk {} is allocated, but stream is missing", pos); -+ // Paper start - recalculate header on regionfile corruption -+ if (this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ // Paper end - recalculate header on regionfile corruption - return null; - } else { - int streamLength = length - 1; - if (isExternalStreamChunk(versionId)) { - if (streamLength != 0) { - LOGGER.warn("Chunk has both internal and external streams"); -+ // Paper start - recalculate header on regionfile corruption -+ if (this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ // Paper end - recalculate header on regionfile corruption - } - -- return this.createExternalChunkInputStream(pos, getExternalChunkVersion(versionId)); -+ // Paper start - recalculate header on regionfile corruption -+ final DataInputStream ret = this.createExternalChunkInputStream(pos, getExternalChunkVersion(versionId)); -+ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ return ret; -+ // Paper end - recalculate header on regionfile corruption - } else if (streamLength > buffer.remaining()) { - LOGGER.error("Chunk {} stream is truncated: expected {} but read {}", pos, streamLength, buffer.remaining()); -+ // Paper start - recalculate header on regionfile corruption -+ if (this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ // Paper end - recalculate header on regionfile corruption - return null; - } else if (streamLength < 0) { - LOGGER.error("Declared size {} of chunk {} is negative", length, pos); -+ // Paper start - recalculate header on regionfile corruption -+ if (this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ // Paper end - recalculate header on regionfile corruption - return null; - } else { - JvmProfiler.INSTANCE.onRegionFileRead(this.info, pos, this.version, streamLength); -- return this.createChunkInputStream(pos, versionId, createStream(buffer, streamLength)); -+ // Paper start - recalculate header on regionfile corruption -+ final DataInputStream ret = this.createChunkInputStream(pos, versionId, createStream(buffer, streamLength)); -+ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) { -+ return this.getChunkDataInputStream(pos); -+ } -+ return ret; -+ // Paper end - recalculate header on regionfile corruption - } - } } -@@ -358,9 +823,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + +- return this.createExternalChunkInputStream(pos, getExternalChunkVersion(versionId)); ++ // Paper start - recalculate header on regionfile corruption ++ final DataInputStream ret = this.createExternalChunkInputStream(pos, getExternalChunkVersion(versionId)); ++ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ return ret; ++ // Paper end - recalculate header on regionfile corruption + } else if (streamLength > buffer.remaining()) { + LOGGER.error("Chunk {} stream is truncated: expected {} but read {}", pos, streamLength, buffer.remaining()); ++ // Paper start - recalculate header on regionfile corruption ++ if (this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ // Paper end - recalculate header on regionfile corruption + return null; + } else if (streamLength < 0) { + LOGGER.error("Declared size {} of chunk {} is negative", length, pos); ++ // Paper start - recalculate header on regionfile corruption ++ if (this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ // Paper end - recalculate header on regionfile corruption + return null; + } else { + JvmProfiler.INSTANCE.onRegionFileRead(this.info, pos, this.version, streamLength); +- return this.createChunkInputStream(pos, versionId, createStream(buffer, streamLength)); ++ // Paper start - recalculate header on regionfile corruption ++ final DataInputStream ret = this.createChunkInputStream(pos, versionId, createStream(buffer, streamLength)); ++ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) { ++ return this.getChunkDataInputStream(pos); ++ } ++ return ret; ++ // Paper end - recalculate header on regionfile corruption + } + } + +@@ -357,9 +822,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } private ByteBuffer createExternalStub() { @@ -637,7 +639,7 @@ index 5e77906d77da82b23fbd6e8d16fbd0847c83f4da..e077797cefffcb9db627cab12c7d8824 return stub; } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 5fa64ff30b8252f139ca7f77c14352c384c8c0e5..eae4963b6d18c5f92871477b93f81c2c79331cd9 100644 +index 6875c3728544bd3b5172c9a3c3f01d033f158d50..9fd2fa679842ef851a15ea2bc48504757988619e 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -24,6 +24,32 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -739,13 +741,19 @@ index 5fa64ff30b8252f139ca7f77c14352c384c8c0e5..eae4963b6d18c5f92871477b93f81c2c } @org.jetbrains.annotations.Contract("_, false -> !null") private @Nullable RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit -@@ -313,6 +365,19 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise - } +@@ -307,7 +359,25 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + // Paper end - var4 = NbtIo.read(regionChunkInputStream); + try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) { +- return regionChunkInputStream == null ? null : NbtIo.read(regionChunkInputStream); + // Paper start - recover from corrupt regionfile header ++ if (regionChunkInputStream == null) { ++ return null; ++ } ++ ++ final CompoundTag serialisedChunkData = NbtIo.read(regionChunkInputStream); + if (this.isChunkData) { -+ ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(var4); ++ ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(serialisedChunkData); + if (!headerChunkPos.equals(pos)) { + net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + headerChunkPos + " instead! Attempting regionfile recalculation for regionfile " + region.getPath().toAbsolutePath()); + if (region.recalculateHeader()) { @@ -755,10 +763,11 @@ index 5fa64ff30b8252f139ca7f77c14352c384c8c0e5..eae4963b6d18c5f92871477b93f81c2c + return null; + } + } ++ return serialisedChunkData; + // Paper end - recover from corrupt regionfile header } + } - return var4; diff --git a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java index ea229f63f81c5638ded74c28e1e13d8948f2e5e0..d991fccfc3d2cc51611f802a6d40429024e21d9a 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java @@ -791,7 +800,7 @@ index 590bd1ca60956e5c5be58481f97401e55f9e1aeb..4e0c9fa1eecfa9f21285b7911e25830b return new RegionStorageInfo(this.level, this.dimension, this.type + suffix); } diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 1e0afa9590de7fe492cf29aded96be3db498c51e..df0bb06176ad5cce3ed8785d22d68b2dcbf5a8ca 100644 +index 2d326c3090a5d7621350347e131ee31d4715d3a7..98fb7a282a33f4391de124ed9be9bcf069178516 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -120,6 +120,18 @@ public record SerializableChunkData( @@ -813,7 +822,7 @@ index 1e0afa9590de7fe492cf29aded96be3db498c51e..df0bb06176ad5cce3ed8785d22d68b2d // Paper start - Do not let the server load chunks from newer versions private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().dataVersion().version(); -@@ -544,7 +556,7 @@ public record SerializableChunkData( +@@ -542,7 +554,7 @@ public record SerializableChunkData( tag.putInt("xPos", this.chunkPos.x()); tag.putInt("yPos", this.minSectionY); tag.putInt("zPos", this.chunkPos.z()); @@ -823,7 +832,7 @@ index 1e0afa9590de7fe492cf29aded96be3db498c51e..df0bb06176ad5cce3ed8785d22d68b2d tag.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(this.chunkStatus).toString()); tag.storeNullable("blending_data", BlendingData.Packed.CODEC, this.blendingData); diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index 6e55cb304fd9a5a01bbe7666dddb882e684cdcf1..6d954064f409ddd2cb7cfd0d0c428ac186f5ca4d 100644 +index df4f03f3a346e0ab0074757b3a077b2407135ac3..0b0265c8d4cb70aef758c1b443d007ef8d6c282b 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java @@ -34,6 +34,7 @@ public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chun diff --git a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch index 906d95d99e0b..fd72f11fde2a 100644 --- a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 248a01f06ec822737a741873166aa4e502a7ba07..c4eb56fc227afd7e9631624537dd8e67ae3a8bea 100644 +index c3b14d51240b5f6edfc3ecdea04f50774615b98c..7a194a39aca231d376550bf7196ac27fd2def30f 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -968,7 +968,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 15000L) { // use vanilla's 15000L between keep alive packets - if (this.keepAlivePending) { -- if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected +- if (elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected - this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, io.papermc.paper.connection.DisconnectionReason.TIMEOUT); // Paper - kick event cause - } - // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings @@ -230,7 +230,7 @@ index abeca4714053fd0a4fa489d496e2e0b844de40a8..7ed50fc00c58c7781c958df1d828a67a + if (oldest != null && (currTime - oldest.txTimeNS()) > java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(KEEPALIVE_LIMIT)) { + LOGGER.info("{} was kicked due to keepalive timeout!", this.playerProfile().name()); + this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, io.papermc.paper.connection.DisconnectionReason.TIMEOUT); // Paper - kick event cause -+ // Paper end - improve keepalives ++ // Paper end - improve keepalives } } diff --git a/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch index c929667c8ef8..8e03ce08fd1a 100644 --- a/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch @@ -20,11 +20,11 @@ index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf387 @Override diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 8c4b40362f77cdea6e57315a6639006ac7ab27c7..a5217deb236ee922d020a7a6a03141a5f67acd77 100644 +index 7a194a39aca231d376550bf7196ac27fd2def30f..a04792c6762958ed7522b19787dcf1594fc3fc08 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1794,32 +1794,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop collisionsBB = new java.util.ArrayList<>(); final List collisionsVoxel = new java.util.ArrayList<>(); @@ -62,10 +62,10 @@ index 06132bde0aed9dd9088c884ee31056b9176b6f90..08374da2d9b84e8ff13c670d7f45867f ); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index fa3809be5c0488c5a1d2639579d68619b0a55de9..c332d48f5cac2f3be93201c66f4f7cdba916cbac 100644 +index 7e72b8c9ba54ce93dcf27c0ff984ab618e470cba..5a5f7cbc0217ab7aa034698802f634d149662da1 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1529,7 +1529,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1531,7 +1531,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; // Paper start - optimise collisions diff --git a/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch b/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch index 16ec01667327..b14e4733d769 100644 --- a/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch +++ b/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Optional per player mob spawns diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index be28a41084d656c44b611cf3a01ba89de610d5b2..15d9c2d601a48d2288d5110f9991280129f43087 100644 +index 55cfe38c0daa3ca71a71bf8c7d88fd613fabd82d..2afc89ab4404cf04ba1da813f1c4a05baa4f44e3 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -238,11 +238,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @@ -42,10 +42,10 @@ index be28a41084d656c44b611cf3a01ba89de610d5b2..15d9c2d601a48d2288d5110f99912801 protected ChunkGenerator generator() { return this.worldGenContext.generator(); diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index fcb23814c2539f4e31ed5191e03cc28f4e7f9c2d..0edfb9866ee2d0ff71394bc74f139fe3b4550c42 100644 +index a5685e0b50610cc8213f34c5db62b475bd54789b..a5023f6f7d912560f3488b1823ee22a1dc639203 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -537,9 +537,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -535,9 +535,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon private void tickChunks(final ProfilerFiller profiler, final long timeDiff) { profiler.push("naturalSpawnCount"); int chunkCount = this.distanceManager.getNaturalSpawnChunkCount(); @@ -67,7 +67,7 @@ index fcb23814c2539f4e31ed5191e03cc28f4e7f9c2d..0edfb9866ee2d0ff71394bc74f139fe3 this.lastSpawnState = spawnCookie; boolean doMobSpawning = this.level.getGameRules().get(GameRules.SPAWN_MOBS) && !this.level.players().isEmpty(); // CraftBukkit int tickSpeed = this.level.getGameRules().get(GameRules.RANDOM_TICK_SPEED); -@@ -567,7 +576,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -565,7 +574,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon profiler.popPush("shuffleSpawningChunks"); // Paper start - chunk tick iteration optimisation this.shuffleRandom.setSeed(this.level.getRandom().nextLong()); @@ -77,10 +77,10 @@ index fcb23814c2539f4e31ed5191e03cc28f4e7f9c2d..0edfb9866ee2d0ff71394bc74f139fe3 profiler.popPush("tickSpawningChunks"); diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 82e87270d1ad89ad7aa56e028ced6b998ea0eca5..558abe7248725a58b5aa1a36c7e372824c0fbe2e 100644 +index c8dd908ea52305d7ae1235ea430a26c88306f183..85d22ea2e0fb7c59c387df056ace9ef556f489a2 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -430,6 +430,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -411,6 +411,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean queueHealthUpdatePacket; public net.minecraft.network.protocol.game.@Nullable ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end - cancellable death event @@ -92,7 +92,7 @@ index 82e87270d1ad89ad7aa56e028ced6b998ea0eca5..558abe7248725a58b5aa1a36c7e37282 public @Nullable String lastKnownName; // Better rename detection public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 8ab7bdd487de7dbc5ea19d1f361ec52e367f8251..d9c1a04e53bec4a268ab58bfc8025c00bd3fa8ce 100644 +index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1eed669db08 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -70,6 +70,18 @@ public final class NaturalSpawner { diff --git a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index 115453902f6e..b3eb7c1ad2ce 100644 --- a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 15d9c2d601a48d2288d5110f9991280129f43087..01cbebd70223389c6d952be23e5d739579b96ead 100644 +index 2afc89ab4404cf04ba1da813f1c4a05baa4f44e3..42ec67c53c35189838ce4767c2be620e05108159 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -257,8 +257,25 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @@ -37,10 +37,10 @@ index 15d9c2d601a48d2288d5110f9991280129f43087..01cbebd70223389c6d952be23e5d7395 // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 0edfb9866ee2d0ff71394bc74f139fe3b4550c42..5a309dcf3c357f6b3a12d74aca2e9592f952318c 100644 +index a5023f6f7d912560f3488b1823ee22a1dc639203..0609c4e7ac7d027ed01684ab4fec2a7838f1f30f 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -542,7 +542,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -540,7 +540,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts for (ServerPlayer player : this.level.players()) { @@ -60,10 +60,10 @@ index 0edfb9866ee2d0ff71394bc74f139fe3b4550c42..5a309dcf3c357f6b3a12d74aca2e9592 spawnCookie = NaturalSpawner.createState(chunkCount, this.level.getAllEntities(), this::getFullChunk, null, true); } else { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 558abe7248725a58b5aa1a36c7e372824c0fbe2e..06b938013f9dbee4fb3b86979d5a42f28a0ea33e 100644 +index 85d22ea2e0fb7c59c387df056ace9ef556f489a2..d354517cbfdcee0648daa8f3eb035b2024d5ce72 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -434,6 +434,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -415,6 +415,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper end - Optional per player mob spawns @@ -72,7 +72,7 @@ index 558abe7248725a58b5aa1a36c7e372824c0fbe2e..06b938013f9dbee4fb3b86979d5a42f2 public @Nullable String lastKnownName; // Better rename detection public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index d9c1a04e53bec4a268ab58bfc8025c00bd3fa8ce..427573fc142c107d3fcc2be9000316221039ba4c 100644 +index b1ecbc50ea908c6c11e9e1ae2f73d1eed669db08..9764163a32b0389afa50ba093d0647de04d5119e 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -307,6 +307,11 @@ public final class NaturalSpawner { diff --git a/paper-server/patches/features/0029-Optimize-Hoppers.patch b/paper-server/patches/features/0029-Optimize-Hoppers.patch index 7b033ec6c836..59d59b3bab1f 100644 --- a/paper-server/patches/features/0029-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0029-Optimize-Hoppers.patch @@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index af1f5e83bd24e671399af2a9aadc8e11959ec5f4..b9efed1df74651c894a416f1d3db320d4ab20401 100644 +index a04792c6762958ed7522b19787dcf1594fc3fc08..1206e3382db8a8c24284621a68b606df5186792d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1850,6 +1850,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent level.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent level.updateLagCompensationTick(); // Paper - lag compensation @@ -60,10 +60,10 @@ index af1f5e83bd24e671399af2a9aadc8e11959ec5f4..b9efed1df74651c894a416f1d3db320d profiler.push("tick"); diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index ee0fde839f06b6b900053b792617f3738b8000e8..54d67c847c1de9ee216cedb0527136f50223ea2d 100644 +index 95e0fb32457f2113de8d3e78fc18398bec83eccf..1d08ac66271a441811a157ed6619b14bf58c403f 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -807,10 +807,16 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -807,11 +807,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public ItemStack copy() { @@ -76,17 +76,18 @@ index ee0fde839f06b6b900053b792617f3738b8000e8..54d67c847c1de9ee216cedb0527136f5 + if (!originalItem && this.isEmpty()) { + // Paper end - Perf: Optimize Hoppers return EMPTY; - } else { -- ItemStack copy = new ItemStack(this.typeHolder(), this.count, this.components.copy()); -+ ItemStack copy = new ItemStack(originalItem ? this.item : this.typeHolder(), this.count, this.components.copy()); // Paper - Perf: Optimize Hoppers - copy.setPopTime(this.getPopTime()); - return copy; } + +- ItemStack copy = new ItemStack(this.typeHolder(), this.count, this.components.copy()); ++ ItemStack copy = new ItemStack(originalItem ? this.item : this.typeHolder(), this.count, this.components.copy()); // Paper - Perf: Optimize Hoppers + copy.setPopTime(this.getPopTime()); + return copy; + } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 04cfd03f29b319225011b86d459626a6872a5e87..865f08c92946010a36947b7766b957f4c0517285 100644 +index 0e2b537ff5230e6bdb55e9e99d6b2202479b8fd2..2c9fb60cae8065b1cd70d6ec53122cec9cf7f2a7 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -40,6 +40,7 @@ import org.jspecify.annotations.Nullable; +@@ -39,6 +39,7 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public abstract class BlockEntity implements DebugValueSource, TypedInstance> { @@ -94,7 +95,7 @@ index 04cfd03f29b319225011b86d459626a6872a5e87..865f08c92946010a36947b7766b957f4 // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; -@@ -229,6 +230,7 @@ public abstract class BlockEntity implements DebugValueSource, TypedInstance test) { + if (container instanceof WorldlyContainer) { + for (int slot : ((WorldlyContainer) container).getSlotsForFace(direction)) { @@ -362,78 +410,32 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 + for (int slot = 0; slot < size; slot++) { + if (test.test(container.getItem(slot), slot)) { + return true; -+ } -+ } -+ } + } + } + } + return true; + } + private static final java.util.function.BiPredicate STACK_SIZE_TEST = (itemStack, i) -> itemStack.getCount() >= itemStack.getMaxStackSize(); + private static final java.util.function.BiPredicate IS_EMPTY_TEST = (itemStack, i) -> itemStack.isEmpty(); + // Paper end - Perf: Optimize Hoppers + +- return false; ++ private static boolean ejectItems(final Level level, final BlockPos blockPos, final HopperBlockEntity self) { ++ Container container = getAttachedContainer(level, blockPos, self); ++ if (container == null) { ++ return false; ++ } + - private static boolean ejectItems(final Level level, final BlockPos blockPos, final HopperBlockEntity self) { - Container container = getAttachedContainer(level, blockPos, self); - if (container == null) { -@@ -188,57 +426,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - if (isFullContainer(container, direction)) { - return false; - } else { -- for (int slot = 0; slot < self.getContainerSize(); slot++) { -- ItemStack itemStack = self.getItem(slot); -- if (!itemStack.isEmpty()) { -- int originalCount = itemStack.getCount(); -- // CraftBukkit start - Call event when pushing items into other inventories -- ItemStack original = itemStack.copy(); -- org.bukkit.craftbukkit.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror( -- self.removeItem(slot, level.spigotConfig.hopperAmount) -- ); // Spigot -- -- org.bukkit.inventory.Inventory destinationInventory; -- // Have to special case large chests as they work oddly -- if (container instanceof final net.minecraft.world.CompoundContainer compoundContainer) { -- destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); -- } else if (container.getOwner() != null) { -- destinationInventory = container.getOwner().getInventory(); -- } else { -- destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventory(container); -- } -- -- org.bukkit.event.inventory.InventoryMoveItemEvent event = new org.bukkit.event.inventory.InventoryMoveItemEvent( -- self.getOwner().getInventory(), -- oitemstack, -- destinationInventory, -- true -- ); -- if (!event.callEvent()) { -- self.setItem(slot, original); -- self.setCooldown(level.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot -- return false; -- } -- int origCount = event.getItem().getAmount(); // Spigot -- ItemStack result = HopperBlockEntity.addItem(self, container, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), direction); -- // CraftBukkit end -- -- if (result.isEmpty()) { -- container.setChanged(); -- return true; -- } -- -- itemStack.setCount(originalCount); -- // Spigot start -- itemStack.shrink(origCount - result.getCount()); -- if (originalCount <= level.spigotConfig.hopperAmount) { -- // Spigot end -- self.setItem(slot, itemStack); -- } -- } -- } -- -- return false; -+ return hopperPush(level, container, direction, self); // Paper - Perf: Optimize Hoppers - } - } ++ Direction direction = self.facing.getOpposite(); ++ if (isFullContainer(container, direction)) { ++ return false; ++ } ++ ++ return hopperPush(level, container, direction, self); // Paper - Perf: Optimize Hoppers } -@@ -293,6 +481,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + + private static int[] getSlots(final Container container, final Direction direction) { +@@ -292,6 +481,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen Container container = getSourceContainer(level, hopper, blockPos, blockState); if (container != null) { Direction direction = Direction.DOWN; @@ -441,7 +443,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 for (int slot : getSlots(container, direction)) { if (tryTakeInItemFromSlot(hopper, container, slot, direction, level)) { // Spigot -@@ -320,54 +509,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -319,54 +509,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private static boolean tryTakeInItemFromSlot(final Hopper hopper, final Container container, final int slot, final Direction direction, final Level level) { // Spigot ItemStack itemStack = container.getItem(slot); if (!itemStack.isEmpty() && canTakeItemFromContainer(hopper, container, itemStack, slot, direction)) { @@ -497,7 +499,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 } return false; -@@ -376,13 +518,15 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -375,13 +518,15 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean addItem(final Container container, final ItemEntity entity) { boolean changed = false; // CraftBukkit start @@ -514,7 +516,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 ItemStack copy = entity.getItem().copy(); ItemStack result = addItem(null, container, copy, null); if (result.isEmpty()) { -@@ -441,7 +585,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -440,7 +585,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen itemStack = itemStack.split(container.getMaxStackSize()); } // Spigot end @@ -524,7 +526,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 itemStack = leftover; // Paper - Make hoppers respect inventory max stack size success = true; } else if (canMergeItems(current, itemStack)) { -@@ -527,14 +673,22 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -526,14 +673,22 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } public static @Nullable Container getContainerAt(final Level level, final BlockPos pos) { @@ -549,7 +551,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 result = getEntityContainer(level, x, y, z); } -@@ -558,14 +712,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -559,14 +714,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } private static @Nullable Container getEntityContainer(final Level level, final double x, final double y, final double z) { @@ -568,7 +570,7 @@ index 0703e50ca36fbc084ed06811678efd0eb7d26455..085ed0eecc47cf9c0fa9fc26b3f7b852 @Override diff --git a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 557ef92009f51b54e710f105254eb3e352c6057c..2270b5e5696ef65366c372b9606c5f03b6a11565 100644 +index 9ded208a6e3b86e24a36791f8bb74cec08cd6e9c..5019356f5f29be895d1b2ea8ee9a0e0f6f237a6a 100644 --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -52,7 +52,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc diff --git a/paper-server/patches/features/0030-Anti-Xray.patch b/paper-server/patches/features/0030-Anti-Xray.patch index 7ad1ed261c1d..a5a47c9de6c2 100644 --- a/paper-server/patches/features/0030-Anti-Xray.patch +++ b/paper-server/patches/features/0030-Anti-Xray.patch @@ -55,7 +55,7 @@ index cde895c776c3077292c1a8381461075b1fbc45c7..b817e30a23a0030f948ff6c12175767f if (buffer.writerIndex() != buffer.capacity()) { diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 488d5654f5414c9950f19e86a791507366366e01..42bfd4b3b626ef66b0f2ef8438add5342b367800 100644 +index d7a1dde0452632d46fe594afa158cace71698de8..a52f93d0563f713b1d2b707cdb6ab74e4793a54d 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -41,13 +41,23 @@ public class ClientboundLevelChunkPacketData { @@ -155,7 +155,7 @@ index a94e6ca1d396b6b0781de5d550c4a804274ee003..a1018e9ca9dfb978d6e6633577abd7d5 private ClientboundLevelChunkWithLightPacket(final RegistryFriendlyByteBuf input) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 4ac7ef5a1ed1fac04a9fd246212f59919deb498c..e562aec4366d7724f915e3dd5ae440a77e0947c5 100644 +index ac3c00ccb3025cd45beb3c6b96f11dad38f78366..a9a00f9be49344b17b27f64834102df3a323f03b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -631,7 +631,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -168,10 +168,10 @@ index 4ac7ef5a1ed1fac04a9fd246212f59919deb498c..e562aec4366d7724f915e3dd5ae440a7 this.weatherData.setLevel(this); this.typeKey = typeKey; diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index f1faa0439bf5bce583e70ce37ade4b7e66daaaa4..f7390b91fe1866c6a11beb93711d0fcde4293164 100644 +index 837f8de90fddb5f458d44ee42ea11557463454c3..515dfa9c71333f68d6a42535f98977b5681eb407 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -321,6 +321,7 @@ public class ServerPlayerGameMode { +@@ -320,6 +320,7 @@ public class ServerPlayerGameMode { org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } @@ -196,10 +196,10 @@ index ec40f02032f965f548b0c0a29aa9d9bbad6f439b..373da9d604cfb1614a0618d856aefd2b if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), connection.getPlayer().getBukkitEntity()).callEvent(); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 5e11abcfd681d86b1c0e282cf901108822766ce2..3020a3208b14bb483b08cf59a796fb83c2403d1c 100644 +index bab8c73be9537a1d531871b1b72bed87d2e0956e..02d19fc610e738f5ed12c23ab92bbdcbabaeced3 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -331,7 +331,7 @@ public abstract class PlayerList { +@@ -330,7 +330,7 @@ public abstract class PlayerList { .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket( new net.minecraft.world.level.chunk.EmptyLevelChunk(level, player.chunkPosition(), plains), @@ -209,7 +209,7 @@ index 5e11abcfd681d86b1c0e282cf901108822766ce2..3020a3208b14bb483b08cf59a796fb83 } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 829bb616e5d72b955248bbc150254c239176ce64..4b228b5c563e40b6f301df22b5c8a7f7988cb072 100644 +index 5a5f7cbc0217ab7aa034698802f634d149662da1..f4302e835fa9684d0fc7d6b65075ec3ec40f8f9f 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -145,6 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -238,14 +238,14 @@ index 829bb616e5d72b955248bbc150254c239176ce64..4b228b5c563e40b6f301df22b5c8a7f7 } // Paper start - Cancel hit for vanished players -@@ -1085,6 +1088,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - // CraftBukkit end - capture blockstates - BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); -+ this.chunkPacketBlockController.onBlockChange(this, pos, blockState, oldState, updateFlags, updateLimit); // Paper - Anti-Xray - if (oldState == null) { - // CraftBukkit start - remove blockstate if failed (or the same) - if (this.captureBlockStates && captured) { +@@ -1088,6 +1091,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } + // CraftBukkit end - capture blockstates + BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); ++ this.chunkPacketBlockController.onBlockChange(this, pos, blockState, oldState, updateFlags, updateLimit); // Paper - Anti-Xray + if (oldState == null) { + // CraftBukkit start - remove blockstate if failed (or the same) + if (this.captureBlockStates && captured) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java index c974b1c276d29610cb59566afaad19f5bcf0c602..c73b9871faa87493e081cb54e1bf1dce487359c6 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java @@ -273,10 +273,10 @@ index c974b1c276d29610cb59566afaad19f5bcf0c602..c73b9871faa87493e081cb54e1bf1dce } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index b5b514b292f9fdbe410aba5facec1638682c9075..595e97d2772b504eb6a08e84e4f4a138eb7c5f37 100644 +index 536c24ec46bdf571637376728aee06755a6256ef..b381c4d5a8b981f34852d029bbe46374d24f7879 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -152,7 +152,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot final LevelChunk.@Nullable PostLoadProcessor postLoad, final @Nullable BlendingData blendingData ) { @@ -286,10 +286,10 @@ index b5b514b292f9fdbe410aba5facec1638682c9075..595e97d2772b504eb6a08e84e4f4a138 this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index 398018ad7037669a756f804403fd76cf333a06de..d274149a977ed828b6bd02d88d2850521ede6c60 100644 +index 0e7bb7db9e46b2cade771fa5e94469023d8b47b0..0f807317cc7fa113ee57ab31f91bb6b8df7c4ae0 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -61,8 +61,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -60,8 +60,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ this.recalcBlockCounts(); } @@ -305,7 +305,7 @@ index 398018ad7037669a756f804403fd76cf333a06de..d274149a977ed828b6bd02d88d285052 this.biomes = containerFactory.createForBiomes(); } -@@ -284,11 +290,17 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -283,11 +289,17 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ this.biomes = biomes; } @@ -326,7 +326,7 @@ index 398018ad7037669a756f804403fd76cf333a06de..d274149a977ed828b6bd02d88d285052 public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6953bf0b2 100644 +index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8ef640028 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -26,6 +26,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -421,7 +421,7 @@ index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6 this.data = this.createOrReuseData(null, 0); this.data.palette.idFor(initialValue, this); @@ -123,15 +169,39 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - } + return new PalettedContainer.Data<>(dataConfiguration, storage, palette); } + // Paper start - Anti-Xray @@ -462,7 +462,7 @@ index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6 public synchronized T getAndSet(final int x, final int y, final int z, final T value) { // Paper - synchronize this.acquire(); -@@ -203,6 +273,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -200,6 +270,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer newData.palette.read(buffer, this.strategy.globalMap()); buffer.readFixedSizeLongArray(newData.storage.getRaw()); this.data = newData; @@ -470,7 +470,7 @@ index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6 this.updateData(this.data); // Paper - optimise palette reads } finally { this.release(); -@@ -210,18 +281,31 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -207,18 +278,31 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } @Override @@ -504,16 +504,16 @@ index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6 List paletteEntries = discData.paletteEntries(); int entryCount = strategy.entryCount(); Configuration storedConfiguration = strategy.getConfigurationForPaletteSize(paletteEntries.size()); -@@ -259,7 +343,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - } +@@ -257,7 +341,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } - -- return DataResult.success(new PalettedContainer<>(strategy, storedConfiguration, storage, palette)); -+ return DataResult.success(new PalettedContainer<>(strategy, storedConfiguration, storage, palette, paletteEntries, defaultValue, presetValues)); // Paper - Anti-Xray - Add preset values } + +- return DataResult.success(new PalettedContainer<>(strategy, storedConfiguration, storage, palette)); ++ return DataResult.success(new PalettedContainer<>(strategy, storedConfiguration, storage, palette, paletteEntries, defaultValue, presetValues)); // Paper - Anti-Xray - Add preset values } -@@ -329,12 +413,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer + @Override +@@ -323,12 +407,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @Override public PalettedContainer copy() { @@ -528,7 +528,7 @@ index edf2990bfbe3d6b64eed85446eef207d2506efc5..09111c50cb34b643b7717f107a6f5bf6 } @Override -@@ -404,9 +488,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -398,9 +482,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return 1 + this.palette.getSerializedSize(globalMap) + this.storage.getRaw().length * 8; } @@ -587,7 +587,7 @@ index 9977331d182cbc592f00006aabce23f0f69d2393..cd20a791b101548367ed53080f78e78b } } diff --git a/net/minecraft/world/level/chunk/PalettedContainerRO.java b/net/minecraft/world/level/chunk/PalettedContainerRO.java -index d2a2d435d0eda14a04f2c8582abffb8f98092a59..1498e9a760878f444debac9d4257d096731bb3ba 100644 +index 4607d2d7591a35d09d748d1ecf7582947bb86f39..f5f40aa2fd1b478045cb9a28b5ae11bc19f337f0 100644 --- a/net/minecraft/world/level/chunk/PalettedContainerRO.java +++ b/net/minecraft/world/level/chunk/PalettedContainerRO.java @@ -14,7 +14,11 @@ public interface PalettedContainerRO { @@ -603,7 +603,7 @@ index d2a2d435d0eda14a04f2c8582abffb8f98092a59..1498e9a760878f444debac9d4257d096 int getSerializedSize(); diff --git a/net/minecraft/world/level/chunk/Strategy.java b/net/minecraft/world/level/chunk/Strategy.java -index 45ff1447312f239154930f748637f413e2ea8f87..a0f8b23612f8315eef2aaf4c036c2ec759aafa66 100644 +index 5c518b6ec7da546460884c37e9af682b6ab9fc22..958be147cd940ac430576ca5b4ada70fa5d051e3 100644 --- a/net/minecraft/world/level/chunk/Strategy.java +++ b/net/minecraft/world/level/chunk/Strategy.java @@ -4,7 +4,7 @@ import net.minecraft.core.IdMap; @@ -616,7 +616,7 @@ index 45ff1447312f239154930f748637f413e2ea8f87..a0f8b23612f8315eef2aaf4c036c2ec7 private static final Palette.Factory HASHMAP_PALETTE_FACTORY = HashMapPalette::create; private static final Configuration ZERO_BITS = new Configuration.Simple(SINGLE_VALUE_PALETTE_FACTORY, 0); diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index df0bb06176ad5cce3ed8785d22d68b2dcbf5a8ca..9823f20186679d75444eff2b7a7b9cf8bb2ef575 100644 +index 98fb7a282a33f4391de124ed9be9bcf069178516..7d29fdc6548324d97ec34d476b5b48ec0bdba0d2 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -141,6 +141,7 @@ public record SerializableChunkData( @@ -626,17 +626,17 @@ index df0bb06176ad5cce3ed8785d22d68b2dcbf5a8ca..9823f20186679d75444eff2b7a7b9cf8 + net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) levelHeight; // Paper - Anti-Xray This is is seemingly only called from ChunkMap, where, we have a server level. We'll fight this later if needed. if (chunkData.getString("Status").isEmpty()) { return null; - } else { -@@ -201,9 +202,11 @@ public record SerializableChunkData( - int y = sectionTag.getByteOr("Y", (byte)0); - LevelChunkSection section; - if (y >= levelHeight.getMinSectionY() && y <= levelHeight.getMaxSectionY()) { -+ final BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(serverLevel, chunkPos, y); // Paper - Anti-Xray - Add preset block states -+ final Codec> antiXrayBlockStateCodec = presetBlockStates == null ? blockStatesCodec : PalettedContainer.codecRW(BlockState.CODEC, containerFactory.blockStatesStrategy(), net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), presetBlockStates); // Paper - Anti-Xray - PalettedContainer blocks = sectionTag.getCompound("block_states") - .map( -- container -> blockStatesCodec.parse(NbtOps.INSTANCE, container) -+ container -> antiXrayBlockStateCodec.parse(NbtOps.INSTANCE, container) // Paper - Anti-Xray - .promotePartial(msg -> logErrors(chunkPos, y, msg)) - .getOrThrow(SerializableChunkData.ChunkReadException::new) - ) + } +@@ -202,9 +203,11 @@ public record SerializableChunkData( + int y = sectionTag.getByteOr("Y", (byte)0); + LevelChunkSection section; + if (y >= levelHeight.getMinSectionY() && y <= levelHeight.getMaxSectionY()) { ++ final BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(serverLevel, chunkPos, y); // Paper - Anti-Xray - Add preset block states ++ final Codec> antiXrayBlockStateCodec = presetBlockStates == null ? blockStatesCodec : PalettedContainer.codecRW(BlockState.CODEC, containerFactory.blockStatesStrategy(), net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), presetBlockStates); // Paper - Anti-Xray + PalettedContainer blocks = sectionTag.getCompound("block_states") + .map( +- container -> blockStatesCodec.parse(NbtOps.INSTANCE, container) ++ container -> antiXrayBlockStateCodec.parse(NbtOps.INSTANCE, container) // Paper - Anti-Xray + .promotePartial(msg -> logErrors(chunkPos, y, msg)) + .getOrThrow(SerializableChunkData.ChunkReadException::new) + ) diff --git a/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch b/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch index e65b1832872d..3b09bcfcc182 100644 --- a/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch +++ b/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch @@ -10,13 +10,13 @@ inside an entity status callback) or during shutdown (which has chunk loading restrictions due to the chunk system being halted). diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -index 9eb6cb86ff70f04863cae3def1006f82bcb4fa6b..da5fdf77dd26d97c8b92bac9a6af8d922c31eb9c 100644 +index b39b8176d6b1a1d3f7058387518bcbb71a3631bb..5ba46020b47edfc886ecd5c33483ebb0fa57e5dc 100644 --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -66,6 +66,13 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { - Objects.requireNonNull(BarrelBlockEntity.this); - } - +@@ -61,6 +61,13 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { + private static final Component DEFAULT_NAME = Component.translatable("container.barrel"); + private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { + // Paper start - delay open/close callbacks + @Override + public boolean delayCallbacks() { @@ -28,13 +28,14 @@ index 9eb6cb86ff70f04863cae3def1006f82bcb4fa6b..da5fdf77dd26d97c8b92bac9a6af8d92 protected void onOpen(final Level level, final BlockPos pos, final BlockState state) { BarrelBlockEntity.this.playSound(state, SoundEvents.BARREL_OPEN); diff --git a/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index 81a293cc13653a9a0336cb25d75273969fee4d16..8ebcce4c4971a11d367fb39e9c7fd280f63594e3 100644 +index 3635bd9e9b6292ff4389984eae1ae89ebca4be51..25c7e4dd69702ac89354040be9c471a8738c207c 100644 --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -35,6 +35,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement - Objects.requireNonNull(ChestBlockEntity.this); - } - +@@ -30,6 +30,14 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement + public static final Component DEFAULT_NAME = Component.translatable("container.chest"); + private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { ++ + // Paper start - delay open/close callbacks + @Override + public boolean delayCallbacks() { @@ -100,13 +101,14 @@ index baa8b5aba0500981a191626553d66650c7304b88..52737172ccfa0c7c977e4f2fe1db242e } } diff --git a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -index eeac644f60760570244380d3c454fd33e37b5a7f..751625124a87de63d933d9c7809e46361e3136a5 100644 +index 592d253921d8adb168840edcc1b24b64969e80f2..e0e72ff1a6c811ae843f2e1511628ab562530a0f 100644 --- a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -@@ -18,6 +18,13 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity - Objects.requireNonNull(EnderChestBlockEntity.this); - } - +@@ -13,6 +13,14 @@ import net.minecraft.world.level.block.state.BlockState; + public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity { + private final ChestLidController chestLidController = new ChestLidController(); + public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { ++ + // Paper start - delay open/close callbacks + @Override + public boolean delayCallbacks() { diff --git a/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch index 60ecc236c6a2..ef902bd3347f 100644 --- a/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch +++ b/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch @@ -151,17 +151,17 @@ index 0000000000000000000000000000000000000000..f47c12e9dd6cfa857ca07a764edc22de + } +} diff --git a/net/minecraft/recipebook/ServerPlaceRecipe.java b/net/minecraft/recipebook/ServerPlaceRecipe.java -index 31f8aa58b48aeb64e57480490a449b6c46913880..b7ee9fe694ea37eeb58b5dded7967e7d0f338d0d 100644 +index da0380782a846dbb2657c58668e398f36f191c6e..d5ce83d5abd4de6f014a2827780170d3341eb927 100644 --- a/net/minecraft/recipebook/ServerPlaceRecipe.java +++ b/net/minecraft/recipebook/ServerPlaceRecipe.java -@@ -41,6 +41,7 @@ public class ServerPlaceRecipe> { - return RecipeBookMenu.PostPlaceAction.NOTHING; - } else { - StackedItemContents availableItems = new StackedItemContents(); -+ availableItems.initializeExtras(recipe.value(), null); // Paper - Improve exact choice recipe ingredients - inventory.fillStackedContents(availableItems); - menu.fillCraftSlotsStackedContents(availableItems); - return placer.tryPlaceRecipe(recipe, availableItems); +@@ -42,6 +42,7 @@ public class ServerPlaceRecipe> { + } + + StackedItemContents availableItems = new StackedItemContents(); ++ availableItems.initializeExtras(recipe.value(), null); // Paper - Improve exact choice recipe ingredients + inventory.fillStackedContents(availableItems); + menu.fillCraftSlotsStackedContents(availableItems); + return placer.tryPlaceRecipe(recipe, availableItems); @@ -100,7 +101,7 @@ public class ServerPlaceRecipe> { } @@ -195,7 +195,7 @@ index 31f8aa58b48aeb64e57480490a449b6c46913880..b7ee9fe694ea37eeb58b5dded7967e7d } return value; -@@ -165,7 +168,7 @@ public class ServerPlaceRecipe> { +@@ -167,7 +170,7 @@ public class ServerPlaceRecipe> { } } @@ -205,7 +205,7 @@ index 31f8aa58b48aeb64e57480490a449b6c46913880..b7ee9fe694ea37eeb58b5dded7967e7d int inventorySlotId = this.inventory.findSlotMatchingCraftingIngredient(itemInInventory, itemInTargetSlot); if (inventorySlotId == Inventory.NOT_FOUND_INDEX) { diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index da8bab81e135a9b240fbeac0e9e1d2aa12c6212d..f004911c438e6f89d6e079437e3f4104d6cbacbd 100644 +index 5c083f2ec110c388be951014d8e5a6eb64ded371..cd7714dffcd7e7b6d96d18a97e65fd0914a739d1 100644 --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java @@ -252,12 +252,12 @@ public class Inventory implements Container, Nameable { @@ -225,10 +225,10 @@ index da8bab81e135a9b240fbeac0e9e1d2aa12c6212d..f004911c438e6f89d6e079437e3f4104 return i; } diff --git a/net/minecraft/world/entity/player/StackedContents.java b/net/minecraft/world/entity/player/StackedContents.java -index 889b8e6c3762203deccf657b505f6f29cc893526..6710653d033a48c4b3fc267496f93a2548b5c966 100644 +index 2a8527a2712de71f4c0d6a2e5af8dd3c01b8ff0a..5982b79f6b391ac9c01c452747fc235faf78369e 100644 --- a/net/minecraft/world/entity/player/StackedContents.java +++ b/net/minecraft/world/entity/player/StackedContents.java -@@ -14,7 +14,7 @@ import java.util.Objects; +@@ -13,7 +13,7 @@ import java.util.List; import org.jspecify.annotations.Nullable; public class StackedContents { @@ -237,7 +237,7 @@ index 889b8e6c3762203deccf657b505f6f29cc893526..6710653d033a48c4b3fc267496f93a25 private boolean hasAtLeast(final T item, final int count) { return this.amounts.getInt(item) >= count; -@@ -54,7 +54,7 @@ public class StackedContents { +@@ -53,7 +53,7 @@ public class StackedContents { private List getUniqueAvailableIngredientItems(final Iterable> ingredients) { List result = new ArrayList<>(); @@ -246,7 +246,7 @@ index 889b8e6c3762203deccf657b505f6f29cc893526..6710653d033a48c4b3fc267496f93a25 if (availableItem.getIntValue() > 0 && anyIngredientMatches(ingredients, availableItem.getKey())) { result.add(availableItem.getKey()); } -@@ -76,13 +76,13 @@ public class StackedContents { +@@ -75,13 +75,13 @@ public class StackedContents { @VisibleForTesting public int getResultUpperBound(final List> ingredients) { int min = Integer.MAX_VALUE; @@ -344,7 +344,7 @@ index ffaa8e450a11a01060b6847d1b66a76323f9d8ba..1ace17d8fc7e7b8b4722a1889d49233c } diff --git a/net/minecraft/world/item/crafting/Ingredient.java b/net/minecraft/world/item/crafting/Ingredient.java -index 3a8a07712a15167dabd12d4bfd258de11706ce93..1deeb3fd148c5d59250346147681b7e8f2147574 100644 +index 653fb104bb51fb738aa3ad22093c24f196f33df2..d4601c6a77f89d89ac9f042ee7b8c25461409523 100644 --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java @@ -22,7 +22,7 @@ import net.minecraft.world.item.Items; @@ -383,7 +383,7 @@ index 3a8a07712a15167dabd12d4bfd258de11706ce93..1deeb3fd148c5d59250346147681b7e8 return ingredient; } // CraftBukkit end -@@ -79,21 +83,22 @@ public final class Ingredient implements Predicate, StackedContents.I +@@ -81,21 +85,22 @@ public final class Ingredient implements Predicate, StackedContents.I public boolean test(final ItemStack input) { // CraftBukkit start if (this.isExact()) { @@ -415,7 +415,7 @@ index 3a8a07712a15167dabd12d4bfd258de11706ce93..1deeb3fd148c5d59250346147681b7e8 } @Override -@@ -118,6 +123,11 @@ public final class Ingredient implements Predicate, StackedContents.I +@@ -120,6 +125,11 @@ public final class Ingredient implements Predicate, StackedContents.I } public SlotDisplay display() { From af7394275c986f2c891dcf1b8ff7a2211c5526b1 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 14 May 2026 23:39:54 +0200 Subject: [PATCH 16/16] [ci skip] format file patches --- .../0001-Moonrise-optimisation-patches.patch | 72 +++++++++---------- ...nate-Current-redstone-implementation.patch | 6 +- ...-Incremental-chunk-and-player-saving.patch | 18 ++--- ...025-Optimise-EntityScheduler-ticking.patch | 6 +- ...0026-DataConverter-Moonrise-co-fixes.patch | 4 +- .../features/0029-Optimize-Hoppers.patch | 34 ++++----- .../minecraft/core/HolderLookup.java.patch | 3 +- .../server/MinecraftServer.java.patch | 15 ++-- .../server/commands/TimeCommand.java.patch | 2 +- .../commands/WaypointCommand.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 2 +- .../server/level/ServerLevel.java.patch | 2 +- .../server/level/ServerPlayer.java.patch | 9 +-- .../level/ServerPlayerGameMode.java.patch | 27 +++---- .../network/LegacyQueryHandler.java.patch | 2 +- .../CachedUserNameToIdResolver.java.patch | 2 +- .../server/players/PlayerList.java.patch | 9 +-- .../rcon/thread/QueryThreadGs4.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 6 +- .../world/entity/LivingEntity.java.patch | 70 +++++++++--------- .../entity/ai/behavior/SleepInBed.java.patch | 2 +- .../ai/behavior/VillagerMakeLove.java.patch | 2 +- .../world/entity/animal/fox/Fox.java.patch | 4 +- .../world/entity/animal/goat/Goat.java.patch | 2 +- .../entity/animal/parrot/Parrot.java.patch | 4 +- .../world/entity/monster/EnderMan.java.patch | 5 +- .../npc/villager/AbstractVillager.java.patch | 2 +- .../minecart/MinecartCommandBlock.java.patch | 6 +- .../inventory/EnchantmentMenu.java.patch | 2 +- .../world/item/EnderEyeItem.java.patch | 2 +- .../minecraft/world/level/Level.java.patch | 39 +++++----- .../world/level/block/BedBlock.java.patch | 27 +++---- .../level/block/FlowerPotBlock.java.patch | 5 +- .../level/block/RespawnAnchorBlock.java.patch | 15 ++-- .../entity/CommandBlockEntity.java.patch | 7 +- .../block/entity/HopperBlockEntity.java.patch | 2 +- .../level/chunk/ChunkGenerator.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 8 +-- .../vibrations/VibrationSystem.java.patch | 2 +- .../StructureTemplate.java.patch | 3 +- .../storage/LevelStorageSource.java.patch | 2 +- 41 files changed, 204 insertions(+), 232 deletions(-) diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index d12ba1e460a0..acb000449a4e 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -23830,7 +23830,7 @@ index 9d9fa99ff7694a3356421df711c7b1443047b057..c79206e0eb455081f63cf4de2c974136 } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 8e3169acbdaa8b7538cebb38fc501b48da9b2799..5bdb7d130cc2e47c9b55f85acae64e83d6ee2546 100644 +index f18001d368d74b987b21521ac2ffe75479ba3a87..c809ea1f2620c543d9bc80afdd64489f2fb98744 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -191,7 +191,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; @@ -23935,7 +23935,7 @@ index 8e3169acbdaa8b7538cebb38fc501b48da9b2799..5bdb7d130cc2e47c9b55f85acae64e83 public MinecraftServer( // CraftBukkit start -@@ -849,7 +935,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); @@ -24071,7 +24071,7 @@ index 8e3169acbdaa8b7538cebb38fc501b48da9b2799..5bdb7d130cc2e47c9b55f85acae64e83 this.tickFrame.end(); this.recordEndOfTick(); // Paper - improve tick loop profiler.pop(); -@@ -2608,6 +2727,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop ret = null; - for (ServerPlayer player : this.playerMap.getAllPlayers()) { -- if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot +- if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot - builder.add(player); + final ServerPlayer[] raw = players.getRawDataUnchecked(); + final int len = players.size(); @@ -26987,7 +26987,7 @@ index 160eeda06cd6bfcec60bac43235760d92fe8d63d..a62ec41b1319857f0d6cd223d013a92b List passengers = this.entity.getPassengers(); if (!passengers.equals(this.lastPassengers)) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 97eba37cd2179bec46854f97a1617eae7cb95754..89da20b0682708ba8bfc0d10381eb9784d80c395 100644 +index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580358b8b82 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -182,7 +182,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; @@ -27769,7 +27769,7 @@ index 97eba37cd2179bec46854f97a1617eae7cb95754..89da20b0682708ba8bfc0d10381eb978 "Server weather", () -> String.format( diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 7ef50f10afc8085e24c955e001d989035261cbdd..bf2cc87fcd62c6054472b41353a91527f81527d3 100644 +index 020b63f9d356aadf0bdaf2e34067d15bacd0177a..f35f88da81abb14b393d6fce04054ee40e8d8397 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -202,7 +202,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; @@ -28470,10 +28470,10 @@ index 5576bfd83e101aa81b6f79f7144be69f2fbfda08..f087b290ffbb2cd719b68de98b5381b7 PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), spawnChunk); } diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 581ea052c288ea9d0c40878c38c1506699b75d62..8feac5ea25620b765a4f1e7b1aab00034d860f34 100644 +index 58fb206651471c7fe9781733bf6d489814a68b5d..eb41400b8948d3eecc6fd89e2fefbe638ccbaad1 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -981,8 +981,8 @@ public abstract class PlayerList { +@@ -979,8 +979,8 @@ public abstract class PlayerList { player.connection.send(level.clockManager().createFullSyncPacket(player)); // Paper - per-world time; per-player time player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); // Paper start - view distances @@ -28484,7 +28484,7 @@ index 581ea052c288ea9d0c40878c38c1506699b75d62..8feac5ea25620b765a4f1e7b1aab0003 // Paper end - view distances if (level.isRaining()) { // CraftBukkit start - handle player weather -@@ -1199,7 +1199,7 @@ public abstract class PlayerList { +@@ -1197,7 +1197,7 @@ public abstract class PlayerList { public void setViewDistance(final int viewDistance) { this.viewDistance = viewDistance; @@ -28493,7 +28493,7 @@ index 581ea052c288ea9d0c40878c38c1506699b75d62..8feac5ea25620b765a4f1e7b1aab0003 for (ServerLevel level : this.server.getAllLevels()) { level.getChunkSource().setViewDistance(viewDistance); -@@ -1208,7 +1208,7 @@ public abstract class PlayerList { +@@ -1206,7 +1206,7 @@ public abstract class PlayerList { public void setSimulationDistance(final int simulationDistance) { this.simulationDistance = simulationDistance; @@ -28876,7 +28876,7 @@ index 09b6da207530987b483444cebeadc2f1c9a15247..3666c3efd188508153b6482db425648e + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 8f09dac837a0af6aabba1b312bb0c8520647ec3b..593265d78564b60bacbb4899f18a6e74bf56601d 100644 +index 666bd12677e62046d5f56544cadcbf1164211e0d..516ceeb6c0706528775676f9e9b8bb18d73ec7f8 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -167,7 +167,7 @@ public abstract class Entity @@ -30030,7 +30030,7 @@ index 892b338a2b0a185511c352ca2bb76ee3890836fd..f84e651e2a34e76a0a71993332e4be1b // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01646cf7b3 100644 +index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f716f79ad 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -87,6 +87,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -30713,16 +30713,16 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 } // Paper start - Cancel hit for vanished players -@@ -514,7 +1148,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.setBlocksDirty(pos, blockState, blockState1); +@@ -511,7 +1145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + this.setBlocksDirty(pos, oldState, newState); } -- if ((flags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (flags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ if ((flags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (flags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full - this.sendBlockUpdated(pos, blockState, state, flags); +- if ((updateFlags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (updateFlags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ if ((updateFlags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (updateFlags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full + this.sendBlockUpdated(pos, oldState, blockState, updateFlags); } -@@ -848,6 +1482,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -845,6 +1479,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper - Fix MC-117075 use removeAll - remove iterator in favour of indexed for loop, ensuring compile error if something uses iter incorrectly boolean tickBlockEntities = this.tickRateManager().runsNormally(); @@ -30730,7 +30730,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 // Paper start - Fix MC-117075 use removeAll final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); toRemove.add(null); -@@ -858,6 +1493,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -855,6 +1490,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { toRemove.add(ticker); // Paper - Fix MC-117075 use removeAll } else if (tickBlockEntities && this.shouldTickBlocksAt(ticker.getPos())) { ticker.tick(); @@ -30742,7 +30742,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 } } -@@ -876,6 +1516,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -873,6 +1513,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -30750,7 +30750,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -883,7 +1524,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -880,7 +1521,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public boolean noCollision(@Nullable Entity entity, AABB box) { if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; @@ -30766,7 +30766,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -1028,7 +1676,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1025,7 +1673,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isInValidBounds(pos)) { return null; } else { @@ -30775,7 +30775,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1108,20 +1756,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1105,20 +1753,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(final @Nullable Entity except, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("getEntities"); @@ -30803,7 +30803,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 } @Override -@@ -1137,33 +1780,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1134,33 +1777,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(type, bb, selector, output, Integer.MAX_VALUE); } @@ -30918,7 +30918,7 @@ index 02b798c7e291902288409777597a4c0bfe7447a2..cc492445307ddc08446484d272866f01 public boolean hasEntities(final EntityTypeTest type, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("hasEntities"); -@@ -1472,13 +2176,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1469,13 +2173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper start - allow patching this logic public final int getEntityCount() { @@ -32509,7 +32509,7 @@ index b23c29459a59c136ccd2f8d6bde5464c94206792..c974b1c276d29610cb59566afaad19f5 public static ProblemReporter.PathElement problemPath(final ChunkPos pos) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index 36451b4c17d833b32c36383f8f2dfd2d267d6cc0..07b5bebadfe3eb6704a19cdd8093b40e613ea4c3 100644 +index a2015a6e4e4ab87fe474d388dc3058ec57ff8dac..aed69011d7e1a7819276d4bcd14ec47d367cbeb1 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -119,7 +119,7 @@ public abstract class ChunkGenerator { @@ -32670,7 +32670,7 @@ index 54d57f80b1cca351cac2aa59477a0e57334816e7..94652b00e18ffcbe02f1ad0578d671e2 public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { return this.wrapped.getBlockEntity(pos); diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index cd190763d1d0ee5ecb92a2aa614a0e550147cb4b..536c24ec46bdf571637376728aee06755a6256ef 100644 +index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b1c324fa8 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -63,7 +63,7 @@ import net.minecraft.world.ticks.TickContainerAccess; diff --git a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch index 0589e5cb51f9..e9123d2691af 100644 --- a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch @@ -2321,7 +2321,7 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b5d63d7b848c11ed322d512adeee102886cbb6fd..a30d47d935439896602078c51ba13d13d2109fc2 100644 +index 9fc39230f52f4cf6b44edd34aa9542b9d500538e..965d9f515d0410df3395d07c6cf5e6349c75c923 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -233,6 +233,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -2347,10 +2347,10 @@ index b5d63d7b848c11ed322d512adeee102886cbb6fd..a30d47d935439896602078c51ba13d13 return toLevel.dimension() != Level.NETHER || this.getGameRules().get(GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS); } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index a5d46832d4f8a13b0bf67b523c21d5c3b44209a9..7e72b8c9ba54ce93dcf27c0ff984ab618e470cba 100644 +index 8d1d7582730e05bf605db31e13ee24242592074e..3d20ef3bc4e891e3e6e5f9f6f5efc6c0367369ea 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2159,6 +2159,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2156,6 +2156,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } diff --git a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch index fd72f11fde2a..25138bee13b5 100644 --- a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index c3b14d51240b5f6edfc3ecdea04f50774615b98c..7a194a39aca231d376550bf7196ac27fd2def30f 100644 +index 49be7709026cd75cfcb31715550387f0ba954a16..f9da26656b18327e3bcc1537a5f51e84b32cc43a 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -964,7 +964,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent level.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent level.updateLagCompensationTick(); // Paper - lag compensation @@ -104,7 +104,7 @@ index 0e2b537ff5230e6bdb55e9e99d6b2202479b8fd2..2c9fb60cae8065b1cd70d6ec53122cec } } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 5456e74964117d85232fabef1c2c0e4c0ddca52a..26784d414114876461bdce19c192d00eb2a20639 100644 +index 920eb74888c1692b93eb060f408004f145489d7c..26784d414114876461bdce19c192d00eb2a20639 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -142,6 +142,43 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -219,10 +219,10 @@ index 5456e74964117d85232fabef1c2c0e4c0ddca52a..26784d414114876461bdce19c192d00e + } + origItemStack.setCount(originalItemCount); + } - } ++ } + if (foundItem && level.paperConfig().hopper.cooldownWhenFull) { // Inventory was full - cooldown + hopper.setCooldown(level.spigotConfig.hopperTransfer); -+ } + } + return false; + } @@ -282,16 +282,7 @@ index 5456e74964117d85232fabef1c2c0e4c0ddca52a..26784d414114876461bdce19c192d00e + return true; + } + origItemStack.setCount(originalItemCount); - -- org.bukkit.event.inventory.InventoryMoveItemEvent event = new org.bukkit.event.inventory.InventoryMoveItemEvent( -- self.getOwner().getInventory(), -- oitemstack, -- destinationInventory, -- true -- ); -- if (!event.callEvent()) { -- self.setItem(slot, original); -- self.setCooldown(level.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot ++ + if (level.paperConfig().hopper.cooldownWhenFull) { + applyCooldown(hopper); + } @@ -361,7 +352,16 @@ index 5456e74964117d85232fabef1c2c0e4c0ddca52a..26784d414114876461bdce19c192d00e + } + return sourceInventory; + } -+ + +- org.bukkit.event.inventory.InventoryMoveItemEvent event = new org.bukkit.event.inventory.InventoryMoveItemEvent( +- self.getOwner().getInventory(), +- oitemstack, +- destinationInventory, +- true +- ); +- if (!event.callEvent()) { +- self.setItem(slot, original); +- self.setCooldown(level.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot + private static void applyCooldown(final Hopper hopper) { + if (hopper instanceof HopperBlockEntity blockEntity && blockEntity.getLevel() != null) { + blockEntity.setCooldown(blockEntity.getLevel().spigotConfig.hopperTransfer); @@ -396,7 +396,7 @@ index 5456e74964117d85232fabef1c2c0e4c0ddca52a..26784d414114876461bdce19c192d00e - // Spigot start - itemStack.shrink(origCount - result.getCount()); - if (originalCount <= level.spigotConfig.hopperAmount) { -- // Spigot end +- // Spigot end - self.setItem(slot, itemStack); + private static boolean anyMatch(Container container, Direction direction, java.util.function.BiPredicate test) { + if (container instanceof WorldlyContainer) { diff --git a/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch b/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch index 78b3e1a0b6ac..1971a90b4cc6 100644 --- a/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/HolderLookup.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/core/HolderLookup.java +++ b/net/minecraft/core/HolderLookup.java -@@ -68,6 +_,7 @@ +@@ -68,6 +_,8 @@ } interface RegistryLookup extends HolderLookup, HolderOwner { + Optional getValueForCopying(ResourceKey resourceKey); // Paper - add method to get the value for pre-filling builders in the reg mod API ++ ResourceKey> key(); Lifecycle registryLifecycle(); diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 4da1ad2e1e0e..287219cd7f3b 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -200,7 +200,7 @@ final Thread serverThread, final LevelStorageSource.LevelStorageAccess storageSource, final PackRepository packRepository, -@@ -322,31 +_,34 @@ +@@ -322,28 +_,28 @@ final boolean propagatesCrashes ) { super("Server", propagatesCrashes); @@ -236,14 +236,7 @@ + // Paper - per-level GameRules this.fixerUpper = fixerUpper; this.functionManager = new ServerFunctionManager(this, this.resources.managers.getFunctionLibrary()); -- HolderGetter blockLookup = this.registries.compositeAccess().lookupOrThrow(Registries.BLOCK).filterFeatures(this.worldData.enabledFeatures()); -+ HolderGetter blockLookup = this.registries -+ .compositeAccess() -+ .lookupOrThrow(Registries.BLOCK) -+ .filterFeatures(this.worldData.enabledFeatures()); - this.structureTemplateManager = new StructureTemplateManager(worldStem.resourceManager(), storageSource, fixerUpper, blockLookup); - this.serverThread = serverThread; - this.executor = Util.backgroundExecutor(); + HolderGetter blockLookup = this.registries.compositeAccess().lookupOrThrow(Registries.BLOCK).filterFeatures(this.worldData.enabledFeatures()); @@ -360,7 +_,39 @@ this.clockManager = this.getDataStorage().computeIfAbsent(ServerClockManager.TYPE); this.clockManager.init(this); @@ -512,7 +505,7 @@ + throw new IllegalStateException("Cannot set spawn point for " + levelData.getLevelName() + " to be in another world (" + spawn.getWorld().key().asString() + ")"); + } else { + levelData.setSpawn( -+ net.minecraft.world.level.storage.LevelData.RespawnData.of( ++ LevelData.RespawnData.of( + level.dimension(), + org.bukkit.craftbukkit.util.CraftLocation.toBlockPos(spawn), + spawn.getYaw(), @@ -639,7 +632,7 @@ + io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.shutdown(); // Paper + try { + io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.awaitTermination(30, java.util.concurrent.TimeUnit.SECONDS); // Paper -+ } catch (java.lang.InterruptedException ignored) {} // Paper ++ } catch (InterruptedException _) {} // Paper + if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { + LOGGER.info("Saving usercache.json"); + this.services().nameToIdCache().save(false); // Paper - Perf: Async GameProfileCache saving diff --git a/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch index 1513e4104bbb..12632227b8c6 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/TimeCommand.java.patch @@ -78,7 +78,7 @@ + ServerClockManager clockManager = source.getLevel().clockManager(); + java.util.OptionalLong targetTime = clockManager.getTotalTicksToTimeMarker(clock, timeMarkerId); + if (targetTime.isEmpty()) { -+ // Paper end - per-world time ++ // Paper end - per-world time throw ERROR_NO_TIME_MARKER_FOUND.create(clock.getRegisteredName(), timeMarkerId); } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch index a88eca96a9e1..65d885fc3451 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch @@ -5,7 +5,7 @@ private static void mutateIcon(final CommandSourceStack source, final WaypointTransmitter waypoint, final Consumer iconConsumer) { - ServerLevel level = source.getLevel(); -+ ServerLevel level = (waypoint instanceof LivingEntity livingEntity) ? (net.minecraft.server.level.ServerLevel) livingEntity.level() : source.getLevel(); // Paper - MC-300685 use level of waypoint if it's a living entity for broadcast ++ ServerLevel level = (waypoint instanceof LivingEntity livingEntity) ? (ServerLevel) livingEntity.level() : source.getLevel(); // Paper - MC-300685 use level of waypoint if it's a living entity for broadcast level.getWaypointManager().untrackWaypoint(waypoint); iconConsumer.accept(waypoint.waypointIcon()); level.getWaypointManager().trackWaypoint(waypoint); diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index f84b2e35a3a1..c2584b6efe61 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -239,7 +239,7 @@ for (ServerPlayer player : this.playerMap.getAllPlayers()) { - if (this.playerIsCloseEnoughForSpawning(player, pos)) { -+ if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot ++ if (this.playerIsCloseEnoughForSpawning(player, pos, 16384.0)) { // Spigot builder.add(player); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 134f77c5b1c4..c71e11b9d093 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -436,7 +436,7 @@ AABB search = AABB.encapsulatingFullBlocks(center, center.atY(this.getMaxY() + 1)).inflate(3.0); - List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition())); -+ List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition()) && !input.isSpectator()); // Paper - Fix lightning being able to hit spectators (MC-262422) ++ List entities = this.getEntitiesOfClass(LivingEntity.class, search, input -> input.isAlive() && this.canSeeSky(input.blockPosition()) && !input.isSpectator()); // Paper - Fix lightning being able to hit spectators (MC-262422) if (!entities.isEmpty()) { return entities.get(this.random.nextInt(entities.size())).blockPosition(); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 79221cdf5182..36e80c0dc5b1 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -918,7 +918,7 @@ + } + { + Either result = super.startSleepInBed(pos, force).ifRight(unit -> { -+ // CraftBukkit end ++ // CraftBukkit end this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); @@ -1016,15 +1016,16 @@ if (menu == null) { if (this.isSpectator()) { this.sendOverlayMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED)); -@@ -1331,9 +_,13 @@ +@@ -1331,9 +_,14 @@ return OptionalInt.empty(); } else { - this.connection.send(new ClientboundOpenScreenPacket(menu.containerId, menu.getType(), provider.getDisplayName())); + // CraftBukkit start + this.containerMenu = menu; // Moved up -+ if (!this.isImmobile()) -+ this.connection.send(new net.minecraft.network.protocol.game.ClientboundOpenScreenPacket(menu.containerId, menu.getType(), java.util.Objects.requireNonNullElseGet(title, menu::getTitle))); // Paper - Add titleOverride to InventoryOpenEven ++ if (!this.isImmobile()) { ++ this.connection.send(new ClientboundOpenScreenPacket(menu.containerId, menu.getType(), java.util.Objects.requireNonNullElseGet(title, menu::getTitle))); // Paper - Add titleOverride to InventoryOpenEven ++ } + // CraftBukkit end this.initMenu(menu); - this.containerMenu = menu; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 3b08b045d0c0..00980a49a7e5 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -31,7 +31,7 @@ + org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent( + this.player.getBukkitEntity(), + org.bukkit.GameMode.getByValue(gameModeForPlayer.getId()), -+ playerGameModeChangeCause, // Paper ++ playerGameModeChangeCause, + cancelMessage + ); + if (!event.callEvent()) { @@ -259,31 +259,26 @@ BlockState adjustedState = block.playerWillDestroy(this.level, pos, state, this.player); boolean changed = this.level.removeBlock(pos, false); if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -286,19 +_,44 @@ +@@ -286,17 +_,38 @@ block.destroy(this.level, pos, adjustedState); } -+ ItemStack mainHandStack = null; // Paper - Trigger bee_nest_destroyed trigger in the correct place -+ boolean isCorrectTool = false; // Paper - Trigger bee_nest_destroyed trigger in the correct place - if (this.player.preventsBlockDrops()) { -- return true; -+ // return true; // CraftBukkit +- if (this.player.preventsBlockDrops()) { ++ if (false && this.player.preventsBlockDrops()) { // CraftBukkit + return true; } ItemStack itemStack = this.player.getMainHandItem(); ItemStack destroyedWith = itemStack.copy(); boolean canDestroy = this.player.hasCorrectToolForDrops(adjustedState); -+ mainHandStack = destroyedWith; // Paper - Trigger bee_nest_destroyed trigger in the correct place -+ isCorrectTool = canDestroy; // Paper - Trigger bee_nest_destroyed trigger in the correct place ++ ItemStack mainHandStack = destroyedWith; // Paper - Trigger bee_nest_destroyed trigger in the correct place itemStack.mineBlock(this.level, adjustedState, pos, this.player); -- if (changed && canDestroy) { + if (changed && canDestroy) { - block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith); - } -+ if (changed && canDestroy) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion + block.playerDestroy(this.level, this.player, pos, adjustedState, blockEntity, destroyedWith, event.isDropItems(), false); // Paper - fix drops not preventing stats/food exhaustion + } + -+ // return true; // CraftBukkit + // CraftBukkit start + java.util.List itemsToDrop = this.level.captureDrops; // Paper - capture all item additions to the world + this.level.captureDrops = null; // Paper - capture all item additions to the world; Remove this earlier so that we can actually drop stuff @@ -297,17 +292,15 @@ + } + // Paper start - Trigger bee_nest_destroyed trigger in the correct place (check impls of block#playerDestroy) + if (mainHandStack != null) { -+ if (changed && isCorrectTool && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && blockEntity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above -+ CriteriaTriggers.BEE_NEST_DESTROYED.trigger(player, state, mainHandStack, beehiveBlockEntity.getOccupantCount()); ++ if (changed && canDestroy && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && blockEntity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above ++ CriteriaTriggers.BEE_NEST_DESTROYED.trigger(this.player, state, mainHandStack, beehiveBlockEntity.getOccupantCount()); + } + } + // Paper end - Trigger bee_nest_destroyed trigger in the correct place ++ // CraftBukkit end return true; -+ // CraftBukkit end } - - public InteractionResult useItem(final ServerPlayer player, final Level level, final ItemStack itemStack, final InteractionHand hand) { @@ -312,6 +_,7 @@ int oldCount = itemStack.getCount(); diff --git a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch index 51a37b731551..2decedf75c72 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch @@ -91,8 +91,8 @@ + event.getNumPlayers(), + event.getMaxPlayers() + ); -+ // Paper end - Call PaperServerListPingEvent and use results + } ++ // Paper end - Call PaperServerListPingEvent and use results sendFlushAndClose(ctx, createLegacyDisconnectPacket(ctx.alloc(), body)); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch index 58fa1ee0631f..7a11cc56148c 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch @@ -123,7 +123,7 @@ entryList.forEach(element -> readGameProfile(element, dateFormat).ifPresent(result::add)); } catch (FileNotFoundException var7) { + // Spigot start -+ } catch (com.google.gson.JsonSyntaxException | NullPointerException ex) { ++ } catch (com.google.gson.JsonSyntaxException | NullPointerException e) { + LOGGER.warn("Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues."); + this.file.delete(); + // Spigot end diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index ce6d72589425..cc1ff3d76cab 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -269,7 +269,7 @@ } @Override -@@ -291,66 +_,149 @@ +@@ -291,65 +_,146 @@ } protected void save(final ServerPlayer player) { @@ -427,14 +427,11 @@ } else { - if (!this.isWhiteListed(nameAndId)) { - return Component.translatable("multiplayer.disconnect.not_whitelisted"); -+ // Paper start - whitelist event -+ if ((whitelistEventResult = this.isWhiteListedLogin(nameAndId)).result == org.bukkit.event.player.PlayerLoginEvent.Result.KICK_WHITELIST) { -+ return whitelistEventResult; ++ if ((whitelistEventResult = this.isWhiteListedLogin(nameAndId)).result == org.bukkit.event.player.PlayerLoginEvent.Result.KICK_WHITELIST) { // Paper - whitelist event ++ return whitelistEventResult; // Paper - whitelist event } -+ // Paper end if (this.ipBans.isBanned(address)) { - IpBanListEntry ban = this.ipBans.get(address); @@ -359,20 +_,19 @@ reason.append(Component.translatable("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ban.getExpires()))); } diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch index 97be1ffc6ade..363a23cc964d 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch @@ -83,7 +83,7 @@ + this.rulesResponse.writeString(queryResponse.getGameVersion()); this.rulesResponse.writeString("plugins"); - this.rulesResponse.writeString(this.serverInterface.getPluginNames()); -+ java.lang.StringBuilder pluginsString = new java.lang.StringBuilder(); ++ StringBuilder pluginsString = new StringBuilder(); + pluginsString.append(queryResponse.getServerVersion()); + if (!queryResponse.getPlugins().isEmpty()) { + pluginsString.append(": "); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index f9fe2e48ec56..9953d5da41d4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -242,7 +242,7 @@ + // due to interactions on the client. + public void resendPossiblyDesyncedEntityData(ServerPlayer player) { + if (player.getBukkitEntity().canSee(this.getBukkitEntity())) { -+ ServerLevel level = (net.minecraft.server.level.ServerLevel) this.level(); ++ ServerLevel level = (ServerLevel) this.level(); + net.minecraft.server.level.ChunkMap.TrackedEntity tracker = level == null ? null : level.getChunkSource().chunkMap.entityMap.get(this.getId()); + if (tracker == null) { + return; @@ -970,9 +970,9 @@ } - + // CraftBukkit start - Capture drops for death event -+ if (this instanceof net.minecraft.world.entity.LivingEntity && !this.forceDrops) { ++ if (!this.forceDrops && this instanceof LivingEntity livingEntity) { + // Paper start - Restore vanilla drops behavior -+ ((net.minecraft.world.entity.LivingEntity)this).drops.add(new net.minecraft.world.entity.Entity.DefaultDrop(itemStack, dropStack -> { ++ livingEntity.drops.add(new DefaultDrop(itemStack, dropStack -> { + ItemEntity dropEntity = new ItemEntity(this.level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, dropStack); // stack is copied before consumer + dropEntity.setDefaultPickUpDelay(); + this.level.addFreshEntity(dropEntity); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index b15501d0a383..4fa53fc2e934 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -393,7 +393,7 @@ newEffect.onEffectAdded(this); - } else if (effect.update(newEffect)) { + } else if (override) { // Paper - Don't fire sync event during generation -+ effect.update(newEffect); ++ effect.update(newEffect); // Paper this.onEffectUpdated(effect, true, source); changed = true; + // Paper start - Properly update hidden effects @@ -518,7 +518,7 @@ return false; } -@@ -1177,35 +_,58 @@ +@@ -1177,14 +_,16 @@ float originalDamage = damage; ItemStack itemInUse = this.getUseItem(); @@ -539,12 +539,11 @@ this.hurtHelmet(source, damage); damage *= 0.75F; } - -+ EntityDamageEvent event; // CraftBukkit // Paper - move this into the actual invuln check.... - if (Float.isNaN(damage) || Float.isInfinite(damage)) { +@@ -1193,19 +_,40 @@ damage = Float.MAX_VALUE; } ++ EntityDamageEvent event; // CraftBukkit // Paper - move this into the actual invuln check.... boolean tookFullDamage = true; - if (this.invulnerableTime > 10.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { + if (this.invulnerableTime > (float)this.invulnerableDuration / 2.0F && !source.is(DamageTypeTags.BYPASSES_COOLDOWN)) { // CraftBukkit - restore use of maxNoDamageTicks @@ -672,50 +671,50 @@ + public boolean canBlockAttack(DamageSource source, float damage) { + if (damage <= 0.0F) { + return false; -+ } else { -+ ItemStack blockingWith = this.getItemBlockingWith(); -+ if (blockingWith == null) { ++ } ++ ++ ItemStack blockingWith = this.getItemBlockingWith(); ++ if (blockingWith == null) { ++ return false; ++ } ++ ++ BlocksAttacks blocksAttacks = blockingWith.get(DataComponents.BLOCKS_ATTACKS); ++ if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(t -> t.contains(source.typeHolder())).orElse(false)) { ++ if (source.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) { + return false; + } else { -+ BlocksAttacks blocksAttacks = blockingWith.get(DataComponents.BLOCKS_ATTACKS); -+ if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(t -> t.contains(source.typeHolder())).orElse(false)) { -+ if (source.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) { -+ return false; -+ } else { -+ return true; -+ } -+ } else { -+ return false; -+ } ++ return true; + } ++ } else { ++ return false; + } + } + -+ public float resolveBlockedDamage(DamageSource damageSource, float damageAmount) { -+ Vec3 sourcePosition = damageSource.getSourcePosition(); -+ double acos; ++ public float resolveBlockedDamage(DamageSource source, float damageAmount) { ++ Vec3 sourcePosition = source.getSourcePosition(); ++ double angle; + if (sourcePosition != null) { -+ Vec3 vec3 = this.calculateViewVector(0.0F, this.getYHeadRot()); -+ Vec3 vec31 = sourcePosition.subtract(this.position()); -+ vec31 = new Vec3(vec31.x, 0.0, vec31.z).normalize(); -+ acos = Math.acos(vec31.dot(vec3)); ++ Vec3 viewVector = this.calculateViewVector(0.0F, this.getYHeadRot()); ++ Vec3 vectorTo = sourcePosition.subtract(this.position()); ++ vectorTo = new Vec3(vectorTo.x, 0.0, vectorTo.z).normalize(); ++ angle = Math.acos(vectorTo.dot(viewVector)); + } else { -+ acos = (float) Math.PI; ++ angle = (float) Math.PI; + } + + BlocksAttacks blocksAttacks = this.getItemBlockingWith().get(DataComponents.BLOCKS_ATTACKS); -+ return blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); ++ return blocksAttacks.resolveBlockedDamage(source, damageAmount, angle); + } + -+ public void blockingItemEffects(ServerLevel level, DamageSource damageSource, float f) { -+ ItemStack itemBlockingWith = this.getItemBlockingWith(); -+ if (itemBlockingWith == null) return; ++ public void blockingItemEffects(ServerLevel level, DamageSource source, float damageBlocked) { ++ ItemStack blockingWith = this.getItemBlockingWith(); ++ if (blockingWith == null) return; + -+ BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS); ++ BlocksAttacks blocksAttacks = blockingWith.get(DataComponents.BLOCKS_ATTACKS); + if (blocksAttacks == null) return; + -+ blocksAttacks.hurtBlockingItem(this.level(), itemBlockingWith, this, this.getUsedItemHand(), f); -+ if (f > 0.0F && !damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions ++ blocksAttacks.hurtBlockingItem(this.level(), blockingWith, this, this.getUsedItemHand(), damageBlocked); ++ if (damageBlocked > 0.0F && !source.is(DamageTypeTags.IS_PROJECTILE) && source.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions + this.blockUsingItem(level, livingEntity); + } + } @@ -1200,7 +1199,7 @@ - if (dmg != 0.0F) { + // CraftBukkit start -+ if (dmg > 0 || !human) { ++ if (dmg > 0.0F || !human) { + if (human) { + // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. + ((net.minecraft.world.entity.player.Player)this).causeFoodExhaustion(source.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent @@ -1211,10 +1210,9 @@ + // CraftBukkit end this.getCombatTracker().recordDamage(source, dmg); this.setHealth(this.getHealth() - dmg); -- this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg); + // CraftBukkit start + if (!human) { -+ this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg); + this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg); + } this.gameEvent(GameEvent.ENTITY_DAMAGE); + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch index f5a503d39e59..588370453f24 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/SleepInBed.java.patch @@ -6,7 +6,7 @@ - BlockState blockState = level.getBlockState(target.pos()); + BlockState blockState = level.getBlockStateIfLoaded(target.pos()); // Paper - Prevent sync chunk loads when villagers try to find beds -+ if (blockState == null) { return false; } // Paper - Prevent sync chunk loads when villagers try to find beds ++ if (blockState == null) return false; // Paper - Prevent sync chunk loads when villagers try to find beds return target.pos().closerToCenterThan(body.position(), 2.0) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch index ff6ac4f071d5..2fe52726d4ad 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -6,8 +6,8 @@ - source.setAge(6000); - target.setAge(6000); - child.setAge(-24000); + // Paper - Move age setting down + child.setAge(-24000); child.snapTo(source.getX(), source.getY(), source.getZ(), 0.0F, 0.0F); - level.addFreshEntityWithPassengers(child); + // CraftBukkit start - call EntityBreedEvent diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch index 6455b126ac7d..0a4c063705b7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch @@ -27,14 +27,14 @@ thrownItem.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); - this.level().addFreshEntity(thrownItem); -+ this.spawnAtLocation((net.minecraft.server.level.ServerLevel) this.level(), thrownItem); // Paper - Call EntityDropItemEvent ++ this.spawnAtLocation((ServerLevel) this.level(), thrownItem); // Paper - Call EntityDropItemEvent } } private void dropItemStack(final ItemStack itemStack) { ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); - this.level().addFreshEntity(itemEntity); -+ this.spawnAtLocation((net.minecraft.server.level.ServerLevel) this.level(), itemEntity); // Paper - Call EntityDropItemEvent ++ this.spawnAtLocation((ServerLevel) this.level(), itemEntity); // Paper - Call EntityDropItemEvent } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch index 55be4351a51f..9f0ecb43c037 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -24,7 +24,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), bodyPosition.x(), bodyPosition.y(), bodyPosition.z(), item, deltaX, deltaY, deltaZ); - this.level().addFreshEntity(itemEntity); - return true; -+ return this.spawnAtLocation((net.minecraft.server.level.ServerLevel) this.level(), itemEntity) != null; // Paper - Call EntityDropItemEvent ++ return this.spawnAtLocation((ServerLevel) this.level(), itemEntity) != null; // Paper - Call EntityDropItemEvent } public boolean isScreamingGoat() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index 873d72918306..8eb4f36a6677 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -37,10 +37,10 @@ + if (!super.hurtServer(level, source, damage)) { + return false; + } ++ // CraftBukkit end this.setOrderedToSit(false); - return super.hurtServer(level, source, damage); -+ return true; -+ // CraftBukkit ++ return true; // CraftBukkit } public Parrot.Variant getVariant() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 447399ad416c..98d01196ade7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -64,9 +64,8 @@ + if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { // Paper - EndermanEscapeEvent - diff on change - below logic relies on this path covering non-projectile damage. boolean result = super.hurtServer(level, source, damage); if (!(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0) { -- this.teleport(); -+ if (this.tryEscape(source.is(net.minecraft.tags.DamageTypeTags.IS_DROWNING) ? com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.DROWN : com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper - EndermanEscapeEvent -+ this.teleport(); ++ if (this.tryEscape(source.is(DamageTypeTags.IS_DROWNING) ? com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.DROWN : com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper - EndermanEscapeEvent + this.teleport(); + } // Paper - EndermanEscapeEvent } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch index 2cba8c7b6ee2..2f2138fa9c6a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch @@ -23,7 +23,7 @@ + // Paper start - Villager#resetOffers + public void resetOffers() { + this.offers = new MerchantOffers(); -+ this.updateTrades((net.minecraft.server.level.ServerLevel) this.level()); ++ this.updateTrades((ServerLevel) this.level()); + } + // Paper end - Villager#resetOffers + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch index 21c84db1cc3f..abead85157c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -26,12 +26,12 @@ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock.this.getBukkitEntity(); ++ return MinecartCommandBlock.this.getBukkitEntity(); + } + + @Override -+ public net.minecraft.server.level.ServerLevel getLevel() { -+ return (net.minecraft.server.level.ServerLevel) MinecartCommandBlock.this.level(); ++ public ServerLevel getLevel() { ++ return (ServerLevel) MinecartCommandBlock.this.level(); + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 382ded7cb2e4..c62f1cab4aa6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -160,8 +160,8 @@ + + enchantmentItem.enchant(enchantment, entry.getValue()); } -+ // CraftBukkit end + player.onEnchantmentPerformed(enchantmentItem, enchantmentCost); ++ // CraftBukkit end + // CraftBukkit - TODO: let plugins change this currency.consume(enchantmentCost, player); diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch index fcf926ca2336..2e3644f19f92 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -21,7 +21,7 @@ + // level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); + int viewDistance = level.getCraftServer().getViewDistance() * 16; + BlockPos soundPos = blockPos.offset(1, 0, 1); -+ final net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) level; // Paper - respect global sound events gamerule - ensured by isClientSide check above ++ final ServerLevel serverLevel = (ServerLevel) level; // Paper - respect global sound events gamerule - ensured by isClientSide check above + for (ServerPlayer player : serverLevel.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule + double deltaX = soundPos.getX() - player.getX(); + double deltaZ = soundPos.getZ() - player.getZ(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 1f1bd6bad9c3..8216ce67ef5d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -315,7 +315,7 @@ if (newState == blockState) { if (oldState != newState) { this.setBlocksDirty(pos, oldState, newState); -@@ -260,9 +_,66 @@ +@@ -260,9 +_,63 @@ this.updatePOIOnBlockStateChange(pos, oldState, newState); } @@ -338,44 +338,41 @@ } + + // CraftBukkit start - Split off from above in order to directly send client and physic updates -+ public void notifyAndUpdatePhysics(BlockPos pos, LevelChunk chunkAt, BlockState oldState, BlockState newState, BlockState currentState, @Block.UpdateFlags int flags, int recursionLeft) { -+ BlockState state = newState; -+ BlockState blockState = oldState; -+ BlockState blockState1 = currentState; -+ if (blockState1 == state) { -+ if (blockState != blockState1) { -+ this.setBlocksDirty(pos, blockState, blockState1); ++ public void notifyAndUpdatePhysics(BlockPos pos, LevelChunk chunk, BlockState oldState, BlockState blockState, BlockState newState, @Block.UpdateFlags int updateFlags, int updateLimit) { ++ if (newState == blockState) { ++ if (oldState != newState) { ++ this.setBlocksDirty(pos, oldState, newState); + } + -+ if ((flags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (flags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ this.sendBlockUpdated(pos, blockState, state, flags); ++ if ((updateFlags & Block.UPDATE_CLIENTS) != 0 && (!this.isClientSide() || (updateFlags & Block.UPDATE_INVISIBLE) == 0) && (this.isClientSide() || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ this.sendBlockUpdated(pos, oldState, blockState, updateFlags); + } + -+ if ((flags & Block.UPDATE_NEIGHBORS) != 0) { -+ this.updateNeighborsAt(pos, blockState.getBlock()); -+ if (!this.isClientSide() && state.hasAnalogOutputSignal()) { -+ this.updateNeighbourForOutputSignal(pos, newState.getBlock()); ++ if ((updateFlags & Block.UPDATE_NEIGHBORS) != 0) { ++ this.updateNeighborsAt(pos, oldState.getBlock()); ++ if (!this.isClientSide() && blockState.hasAnalogOutputSignal()) { ++ this.updateNeighbourForOutputSignal(pos, blockState.getBlock()); + } + } + -+ if ((flags & Block.UPDATE_KNOWN_SHAPE) == 0 && recursionLeft > 0) { -+ int i = flags & ~(Block.UPDATE_SUPPRESS_DROPS | Block.UPDATE_NEIGHBORS); ++ if ((updateFlags & Block.UPDATE_KNOWN_SHAPE) == 0 && updateLimit > 0) { ++ int neighbourUpdateFlags = updateFlags & ~(Block.UPDATE_SUPPRESS_DROPS | Block.UPDATE_NEIGHBORS); + + // CraftBukkit start -+ blockState.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); // Don't call an event for the old block to limit event spam ++ oldState.updateIndirectNeighbourShapes(this, pos, neighbourUpdateFlags, updateLimit - 1); // Don't call an event for the old block to limit event spam + boolean cancelledUpdates = false; // Paper - Fix block place logic + if (((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), state.asBlockData()); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), blockState.asBlockData()); + cancelledUpdates = !event.callEvent(); // Paper - Fix block place logic + } + // CraftBukkit end + if (!cancelledUpdates) { // Paper - Fix block place logic -+ state.updateNeighbourShapes(this, pos, i, recursionLeft - 1); -+ state.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); ++ blockState.updateNeighbourShapes(this, pos, neighbourUpdateFlags, updateLimit - 1); ++ blockState.updateIndirectNeighbourShapes(this, pos, neighbourUpdateFlags, updateLimit - 1); + } // Paper - Fix block place logic + } + -+ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); ++ this.updatePOIOnBlockStateChange(pos, oldState, newState); + } + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index 45c3575962ca..bf9483606f7d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -9,7 +9,7 @@ bedRule.errorMessage().ifPresent(player::sendOverlayMessage); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -104,20 +_,59 @@ +@@ -104,21 +_,60 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos), null, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -21,8 +21,8 @@ return InteractionResult.SUCCESS_SERVER; } else { + // CraftBukkit start -+ final BlockState finalBlockState = state; -+ final BlockPos finalBlockPos = pos; ++ final BlockState finalState = state; ++ final BlockPos finalPos = pos; + // CraftBukkit end player.startSleepInBed(pos).ifLeft(problem -> { - if (problem.message() != null) { @@ -31,14 +31,14 @@ player.sendOverlayMessage(problem.message()); } + if (problem != null) { -+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, problem); ++ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalPos, problem); + if (event.isCancelled()) { + return; + } + // Paper end - PlayerBedFailEnterEvent + // CraftBukkit start - handling bed explosion from below here + if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent -+ this.explodeBed(finalBlockState, level, finalBlockPos); ++ this.explodeBed(finalState, level, finalPos); + } + // CraftBukkit end + // Paper start - PlayerBedFailEnterEvent @@ -50,9 +50,9 @@ + // Paper end - PlayerBedFailEnterEvent }); return InteractionResult.SUCCESS_SERVER; -+ } -+ } -+ + } + } + + // CraftBukkit start - Copied from the above method + private InteractionResult explodeBed(BlockState state, Level level, BlockPos pos) { + org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos).getState(); // CraftBukkit - capture BlockState before remove block @@ -60,16 +60,17 @@ + BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); + if (level.getBlockState(blockPos).is(this)) { + level.removeBlock(blockPos, false); - } ++ } + -+ Vec3 center = pos.getCenter(); -+ level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ Vec3 boomPos = pos.getCenter(); ++ level.explode(null, level.damageSources().badRespawnPointExplosion(boomPos).causingBlockSnapshot(blockState), null, boomPos, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state + return InteractionResult.SUCCESS_SERVER; - } ++ } + // CraftBukkit end - ++ private boolean kickVillagerOutOfBed(final Level level, final BlockPos pos) { List villagers = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); + if (villagers.isEmpty()) { @@ -298,6 +_,11 @@ if (!level.isClientSide()) { BlockPos otherPos = pos.relative(state.getValue(FACING)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch index 5e5a61245d77..7210745f1403 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -74,7 +_,18 @@ - if (!this.isEmpty()) { +@@ -75,6 +_,18 @@ return InteractionResult.CONSUME; } -- + + // Paper start - Add PlayerFlowerPotManipulateEvent + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + org.bukkit.inventory.ItemStack placedStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch index 5841077127de..cc22bcf4d953 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -1,23 +1,18 @@ --- a/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -115,11 +_,16 @@ +@@ -115,7 +_,11 @@ LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false ); if (respawnConfig == null || !respawnConfig.isSamePosition(newRespawnConfig)) { - serverPlayer.setRespawnPosition(newRespawnConfig, true); -+ if (serverPlayer.setRespawnPosition(newRespawnConfig, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent - serverLevel.playSound( - null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F - ); - return InteractionResult.SUCCESS_SERVER; + // Paper start - Add PlayerSetSpawnEvent -+ } else { ++ if (!serverPlayer.setRespawnPosition(newRespawnConfig, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { + return InteractionResult.FAIL; + } + // Paper end - Add PlayerSetSpawnEvent - } - } - + serverLevel.playSound( + null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F + ); @@ -157,6 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index c499c7bb49e5..24d455c7d017 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -27,6 +_,19 @@ +@@ -27,6 +_,18 @@ private boolean auto = false; private boolean conditionMet = false; private final BaseCommandBlock commandBlock = new BaseCommandBlock() { -+ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { @@ -12,8 +11,8 @@ + } + + @Override -+ public net.minecraft.server.level.ServerLevel getLevel() { -+ return (net.minecraft.server.level.ServerLevel) CommandBlockEntity.this.getLevel(); ++ public ServerLevel getLevel() { ++ return (ServerLevel) CommandBlockEntity.this.getLevel(); + } + // CraftBukkit end + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index c21f5d8cc865..da4859bb303a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -109,7 +109,7 @@ + // Spigot start + itemStack.shrink(origCount - result.getCount()); + if (originalCount <= level.spigotConfig.hopperAmount) { -+ // Spigot end ++ // Spigot end self.setItem(slot, itemStack); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index 53d9cfcd3596..495df6e567bc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -47,7 +47,7 @@ BlockPos.MutableBlockPos structurePos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : positions) { -+ if (!level.paperConfig().environment.locateStructuresOutsideWorldBorder && !level.getWorldBorder().isChunkInBounds(chunkPos.x(), chunkPos.z())) { continue; } // Paper - Bound treasure maps to world border ++ if (!level.paperConfig().environment.locateStructuresOutsideWorldBorder && !level.getWorldBorder().isChunkInBounds(chunkPos.x(), chunkPos.z())) continue; // Paper - Bound treasure maps to world border structurePos.set(SectionPos.sectionToBlockCoord(chunkPos.x(), 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z(), 8)); double distSqr = structurePos.distSqr(pos); boolean isClosest = closestPos == null || distSqr < closest; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index 62cede9f9b1a..f95a91639fe4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -259,11 +259,11 @@ this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; - } else if (!this.loggedInvalidBlockState) { -+ // Paper start - Remove the Block Entity if it's invalid ++ // Paper start - Remove the Block Entity if it's invalid + } else { + LevelChunk.this.removeBlockEntity(this.getPos()); + if (!this.loggedInvalidBlockState) { -+ // Paper end - Remove the Block Entity if it's invalid ++ // Paper end - Remove the Block Entity if it's invalid this.loggedInvalidBlockState = true; LevelChunk.LOGGER .warn( @@ -282,8 +282,8 @@ - throw new ReportedException(report); + // Paper start - Prevent block entity and entity crashes + final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(LevelChunk.this.getLevel()), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); -+ net.minecraft.server.MinecraftServer.LOGGER.error(msg, t); -+ net.minecraft.world.level.chunk.LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, t))); // Paper - ServerExceptionEvent ++ LevelChunk.LOGGER.error(msg, t); ++ LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, t))); // Paper - ServerExceptionEvent + LevelChunk.this.removeBlockEntity(this.getPos()); + // Paper end - Prevent block entity and entity crashes } diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index e785ad48bc70..ed6d7d93e481 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -21,7 +21,7 @@ + event1.setCancelled(defaultCancel); + level.getCraftServer().getPluginManager().callEvent(event1); + if (event1.isCancelled()) { -+ // CraftBukkit end ++ // CraftBukkit end return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index eb4391e4cdfc..6a0fc5b30501 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -74,10 +74,9 @@ if (blockInfo.getSecond() != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { -- blockEntity.setChanged(); + // Paper start - Fix NBT pieces overriding a block entity during worldgen deadlock + if (!(level instanceof net.minecraft.world.level.WorldGenLevel)) { -+ blockEntity.setChanged(); + blockEntity.setChanged(); + } + // Paper end - Fix NBT pieces overriding a block entity during worldgen deadlock } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 6df0f5e804b9..92dc79032cc4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -29,7 +29,7 @@ CompoundTag fileContents; try { - fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.defaultQuota()); -+ fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.create(net.minecraft.nbt.NbtAccounter.DEFAULT_NBT_QUOTA * 50L)); // Paper - raise quota to account for custom data ++ fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.create(NbtAccounter.DEFAULT_NBT_QUOTA * 50L)); // Paper - raise quota to account for custom data } catch (IOException e) { return DataResult.error(e::getMessage); }